(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/misc/pqueue#pqueue::t
    (make-struct-type
     'std/misc/pqueue#pqueue::t
     '#f
     '3
     'pqueue
     '((final: . #t))
     ':init!
     '(e cmp prio)))
  (define std/misc/pqueue#pqueue?
    (make-struct-predicate std/misc/pqueue#pqueue::t))
  (define std/misc/pqueue#make-pqueue
    (lambda _$args803_
      (apply make-struct-instance std/misc/pqueue#pqueue::t _$args803_)))
  (define std/misc/pqueue#pqueue-e
    (make-struct-field-accessor std/misc/pqueue#pqueue::t '0))
  (define std/misc/pqueue#pqueue-cmp
    (make-struct-field-accessor std/misc/pqueue#pqueue::t '1))
  (define std/misc/pqueue#pqueue-prio
    (make-struct-field-accessor std/misc/pqueue#pqueue::t '2))
  (define std/misc/pqueue#pqueue-e-set!
    (make-struct-field-mutator std/misc/pqueue#pqueue::t '0))
  (define std/misc/pqueue#pqueue-cmp-set!
    (make-struct-field-mutator std/misc/pqueue#pqueue::t '1))
  (define std/misc/pqueue#pqueue-prio-set!
    (make-struct-field-mutator std/misc/pqueue#pqueue::t '2))
  (define std/misc/pqueue#pqueue:::init!__%
    (lambda (_self775_ _prio776_ _cmp777_ _isz778_)
      (let ((_e780_ (make-vector (fx+ _isz778_ '1))))
        (std/misc/pqueue#heap-size-set! _e780_ '0)
        (if (let ((__tmp4403
                   (let () (declare (not safe)) (##vector-length _self775_))))
              (declare (not safe))
              (##fx< '3 __tmp4403))
            (begin
              (let () (declare (not safe)) (##vector-set! _self775_ '1 _e780_))
              (let ()
                (declare (not safe))
                (##vector-set! _self775_ '2 _cmp777_))
              (let ()
                (declare (not safe))
                (##vector-set! _self775_ '3 _prio776_)))
            (error '"struct-instance-init!: too many arguments for struct"
                   _self775_)))))
  (define std/misc/pqueue#pqueue:::init!__0
    (lambda (_self785_ _prio786_)
      (let* ((_cmp788_ <) (_isz790_ '15))
        (std/misc/pqueue#pqueue:::init!__%
         _self785_
         _prio786_
         _cmp788_
         _isz790_))))
  (define std/misc/pqueue#pqueue:::init!__1
    (lambda (_self792_ _prio793_ _cmp794_)
      (let ((_isz796_ '15))
        (std/misc/pqueue#pqueue:::init!__%
         _self792_
         _prio793_
         _cmp794_
         _isz796_))))
  (define std/misc/pqueue#pqueue:::init!
    (lambda _g4405_
      (let ((_g4404_ (let () (declare (not safe)) (##length _g4405_))))
        (cond ((let () (declare (not safe)) (##fx= _g4404_ 2))
               (apply std/misc/pqueue#pqueue:::init!__0 _g4405_))
              ((let () (declare (not safe)) (##fx= _g4404_ 3))
               (apply std/misc/pqueue#pqueue:::init!__1 _g4405_))
              ((let () (declare (not safe)) (##fx= _g4404_ 4))
               (apply std/misc/pqueue#pqueue:::init!__% _g4405_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/misc/pqueue#pqueue:::init!
                _g4405_))))))
  (bind-method!
   std/misc/pqueue#pqueue::t
   ':init!
   std/misc/pqueue#pqueue:::init!
   '#f)
  (define std/misc/pqueue#pqueue-empty?
    (lambda (_pq626_)
      (let* ((_pq627633_ _pq626_)
             (_E629637_ (lambda () (error '"No clause matching" _pq627633_)))
             (_K630642_
              (lambda (_e640_)
                (let ((__tmp4406 (std/misc/pqueue#heap-size _e640_)))
                  (declare (not safe))
                  (##fxzero? __tmp4406)))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _pq627633_
               'std/misc/pqueue#pqueue::t))
            (let* ((_e631645_
                    (let () (declare (not safe)) (##vector-ref _pq627633_ '1)))
                   (_e648_ _e631645_))
              (_K630642_ _e648_))
            (_E629637_)))))
  (define std/misc/pqueue#pqueue-size
    (lambda (_pq602_)
      (let* ((_pq603609_ _pq602_)
             (_E605613_ (lambda () (error '"No clause matching" _pq603609_)))
             (_K606618_ (lambda (_e616_) (std/misc/pqueue#heap-size _e616_))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _pq603609_
               'std/misc/pqueue#pqueue::t))
            (let* ((_e607621_
                    (let () (declare (not safe)) (##vector-ref _pq603609_ '1)))
                   (_e624_ _e607621_))
              (std/misc/pqueue#heap-size _e624_))
            (_E605613_)))))
  (define std/misc/pqueue#pqueue-peek__%
    (lambda (_pq553_ _default554_)
      (let* ((_pq555563_ _pq553_)
             (_E557567_ (lambda () (error '"No clause matching" _pq555563_)))
             (_K558574_
              (lambda (_prio570_ _cmp571_ _e572_)
                (if (let ((__tmp4407 (std/misc/pqueue#heap-size _e572_)))
                      (declare (not safe))
                      (##fxzero? __tmp4407))
                    (if (eq? _default554_ absent-obj)
                        (error '"empty pqueue")
                        _default554_)
                    (std/misc/pqueue#heap-top _e572_)))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _pq555563_
               'std/misc/pqueue#pqueue::t))
            (let* ((_e559577_
                    (let () (declare (not safe)) (##vector-ref _pq555563_ '1)))
                   (_e580_ _e559577_)
                   (_e560582_
                    (let () (declare (not safe)) (##vector-ref _pq555563_ '2)))
                   (_cmp585_ _e560582_)
                   (_e561587_
                    (let () (declare (not safe)) (##vector-ref _pq555563_ '3)))
                   (_prio590_ _e561587_))
              (_K558574_ _prio590_ _cmp585_ _e580_))
            (_E557567_)))))
  (define std/misc/pqueue#pqueue-peek__0
    (lambda (_pq595_)
      (let ((_default597_ absent-obj))
        (std/misc/pqueue#pqueue-peek__% _pq595_ _default597_))))
  (define std/misc/pqueue#pqueue-peek
    (lambda _g4409_
      (let ((_g4408_ (let () (declare (not safe)) (##length _g4409_))))
        (cond ((let () (declare (not safe)) (##fx= _g4408_ 1))
               (apply std/misc/pqueue#pqueue-peek__0 _g4409_))
              ((let () (declare (not safe)) (##fx= _g4408_ 2))
               (apply std/misc/pqueue#pqueue-peek__% _g4409_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/misc/pqueue#pqueue-peek
                _g4409_))))))
  (define std/misc/pqueue#pqueue-pop!__%
    (lambda (_pq508_ _default509_)
      (let* ((_pq510517_ _pq508_)
             (_E512521_ (lambda () (error '"No clause matching" _pq510517_)))
             (_K513529_
              (lambda (_cmp524_ _e525_)
                (if (let ((__tmp4410 (std/misc/pqueue#heap-size _e525_)))
                      (declare (not safe))
                      (##fxzero? __tmp4410))
                    (if (eq? _default509_ absent-obj)
                        (error '"Cannot pop; empty pqueue")
                        _default509_)
                    (let ((_obj527_ (std/misc/pqueue#heap-top _e525_)))
                      (std/misc/pqueue#heap-pop! _e525_ _cmp524_)
                      _obj527_)))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _pq510517_
               'std/misc/pqueue#pqueue::t))
            (let* ((_e514532_
                    (let () (declare (not safe)) (##vector-ref _pq510517_ '1)))
                   (_e535_ _e514532_)
                   (_e515537_
                    (let () (declare (not safe)) (##vector-ref _pq510517_ '2)))
                   (_cmp540_ _e515537_))
              (_K513529_ _cmp540_ _e535_))
            (_E512521_)))))
  (define std/misc/pqueue#pqueue-pop!__0
    (lambda (_pq545_)
      (let ((_default547_ absent-obj))
        (std/misc/pqueue#pqueue-pop!__% _pq545_ _default547_))))
  (define std/misc/pqueue#pqueue-pop!
    (lambda _g4412_
      (let ((_g4411_ (let () (declare (not safe)) (##length _g4412_))))
        (cond ((let () (declare (not safe)) (##fx= _g4411_ 1))
               (apply std/misc/pqueue#pqueue-pop!__0 _g4412_))
              ((let () (declare (not safe)) (##fx= _g4411_ 2))
               (apply std/misc/pqueue#pqueue-pop!__% _g4412_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/misc/pqueue#pqueue-pop!
                _g4412_))))))
  (define std/misc/pqueue#pqueue-push!
    (lambda (_pq466_ _obj467_)
      (let* ((_pq468476_ _pq466_)
             (_E470480_ (lambda () (error '"No clause matching" _pq468476_)))
             (_K471489_
              (lambda (_prio483_ _cmp484_ _e485_)
                (let ((_e*487_ (std/misc/pqueue#heap-push!
                                _e485_
                                _cmp484_
                                (_prio483_ _obj467_)
                                _obj467_)))
                  (if (eq? _e485_ _e*487_)
                      '#!void
                      (##direct-structure-set!
                       _pq466_
                       _e*487_
                       '1
                       std/misc/pqueue#pqueue::t
                       '#f))))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _pq468476_
               'std/misc/pqueue#pqueue::t))
            (let* ((_e472492_
                    (let () (declare (not safe)) (##vector-ref _pq468476_ '1)))
                   (_e495_ _e472492_)
                   (_e473497_
                    (let () (declare (not safe)) (##vector-ref _pq468476_ '2)))
                   (_cmp500_ _e473497_)
                   (_e474502_
                    (let () (declare (not safe)) (##vector-ref _pq468476_ '3)))
                   (_prio505_ _e474502_))
              (_K471489_ _prio505_ _cmp500_ _e495_))
            (_E470480_)))))
  (define std/misc/pqueue#pqueue-contents
    (lambda (_pq457_)
      (letrec* ((_e459_ (##direct-structure-ref
                         _pq457_
                         '1
                         std/misc/pqueue#pqueue::t
                         '#f)))
        (let _loop461_ ((_i463_ (vector-ref _e459_ '0)) (_a464_ '()))
          (if (zero? _i463_)
              _a464_
              (_loop461_
               (- _i463_ '1)
               (cons (cdr (vector-ref _e459_ _i463_)) _a464_)))))))
  (define std/misc/pqueue#heap-size
    (lambda (_e455_) (let () (declare (not safe)) (##vector-ref _e455_ '0))))
  (define std/misc/pqueue#heap-size-set!
    (lambda (_e452_ _sz453_)
      (let () (declare (not safe)) (##vector-set! _e452_ '0 _sz453_))))
  (define std/misc/pqueue#heap-top
    (lambda (_e450_)
      (cdr (let () (declare (not safe)) (##vector-ref _e450_ '1)))))
  (define std/misc/pqueue#heap-prio
    (lambda (_e447_ _i448_)
      (car (let () (declare (not safe)) (##vector-ref _e447_ _i448_)))))
  (define std/misc/pqueue#heap-parent
    (lambda (_i445_) (let () (declare (not safe)) (##fxquotient _i445_ '2))))
  (define std/misc/pqueue#heap-left
    (lambda (_i443_) (let () (declare (not safe)) (##fx* _i443_ '2))))
  (define std/misc/pqueue#heap-right
    (lambda (_i441_)
      (let ((__tmp4413 (std/misc/pqueue#heap-left _i441_)))
        (declare (not safe))
        (##fx+ __tmp4413 '1))))
  (define std/misc/pqueue#heap-pop!
    (lambda (_e420_ _cmp421_)
      (let* ((_sz423_ (std/misc/pqueue#heap-size _e420_))
             (_sz-1425_ (let () (declare (not safe)) (##fx- _sz423_ '1))))
        (std/misc/pqueue#heap-size-set! _e420_ _sz-1425_)
        (if (let () (declare (not safe)) (##fxzero? _sz-1425_))
            '#!void
            (begin
              (let ((__tmp4414
                     (let ()
                       (declare (not safe))
                       (##vector-ref _e420_ _sz423_))))
                (declare (not safe))
                (##vector-set! _e420_ '1 __tmp4414))
              (let _lp428_ ((_i430_ '1))
                (let* ((_l432_ (std/misc/pqueue#heap-left _i430_))
                       (_r434_ (std/misc/pqueue#heap-right _i430_))
                       (_xchg436_
                        (if (and (let ()
                                   (declare (not safe))
                                   (##fx<= _l432_ _sz-1425_))
                                 (_cmp421_
                                  (std/misc/pqueue#heap-prio _e420_ _l432_)
                                  (std/misc/pqueue#heap-prio _e420_ _i430_)))
                            _l432_
                            _i430_))
                       (_xchg438_
                        (if (and (let ()
                                   (declare (not safe))
                                   (##fx<= _r434_ _sz-1425_))
                                 (_cmp421_
                                  (std/misc/pqueue#heap-prio _e420_ _r434_)
                                  (std/misc/pqueue#heap-prio
                                   _e420_
                                   _xchg436_)))
                            _r434_
                            _xchg436_)))
                  (if (not (let ()
                             (declare (not safe))
                             (##fx= _xchg438_ _i430_)))
                      (begin
                        (std/misc/pqueue#heap-swap! _e420_ _xchg438_ _i430_)
                        (_lp428_ _xchg438_))
                      '#!void))))))))
  (define std/misc/pqueue#heap-push!
    (lambda (_e402_ _cmp403_ _prio404_ _obj405_)
      (let* ((_sz407_ (std/misc/pqueue#heap-size _e402_))
             (_sz+1409_ (let () (declare (not safe)) (##fx+ _sz407_ '1)))
             (_e411_ (std/misc/pqueue#heap-resize! _e402_ _sz+1409_)))
        (let ((__tmp4415 (cons _prio404_ _obj405_)))
          (declare (not safe))
          (##vector-set! _e411_ _sz+1409_ __tmp4415))
        (let _lp414_ ((_i416_ _sz+1409_))
          (if (let () (declare (not safe)) (##fx> _i416_ '1))
              (let ((_parent418_ (std/misc/pqueue#heap-parent _i416_)))
                (if (_cmp403_
                     (std/misc/pqueue#heap-prio _e411_ _i416_)
                     (std/misc/pqueue#heap-prio _e411_ _parent418_))
                    (begin
                      (std/misc/pqueue#heap-swap! _e411_ _parent418_ _i416_)
                      (_lp414_ _parent418_))
                    _e411_))
              _e411_)))))
  (define std/misc/pqueue#heap-swap!
    (lambda (_e396_ _i397_ _j398_)
      (let ((_tmp400_
             (let () (declare (not safe)) (##vector-ref _e396_ _j398_))))
        (let ((__tmp4416
               (let () (declare (not safe)) (##vector-ref _e396_ _i397_))))
          (declare (not safe))
          (##vector-set! _e396_ _j398_ __tmp4416))
        (let () (declare (not safe)) (##vector-set! _e396_ _i397_ _tmp400_)))))
  (define std/misc/pqueue#heap-resize!
    (lambda (_e389_ _sz+1390_)
      (let ((_len392_ (let () (declare (not safe)) (##vector-length _e389_))))
        (if (let () (declare (not safe)) (##fx< _sz+1390_ _len392_))
            (begin (std/misc/pqueue#heap-size-set! _e389_ _sz+1390_) _e389_)
            (let ((_new394_
                   (make-vector
                    (let ((__tmp4417
                           (let () (declare (not safe)) (##fx* '3 _len392_))))
                      (declare (not safe))
                      (##fxquotient __tmp4417 '2)))))
              (std/misc/pqueue#heap-size-set! _new394_ _sz+1390_)
              (let ()
                (declare (not safe))
                (##subvector-move! _e389_ '1 _len392_ _new394_ '1))
              _new394_))))))
