(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/misc/channel#channel::t
    (make-struct-type
     'std/misc/channel#channel::t
     '#f
     '5
     'channel
     '((final: . #t))
     ':init!
     '(q mx cv limit eof)))
  (define std/misc/channel#channel?
    (make-struct-predicate std/misc/channel#channel::t))
  (define std/misc/channel#make-channel
    (lambda _$args1113_
      (apply make-struct-instance std/misc/channel#channel::t _$args1113_)))
  (define std/misc/channel#channel-q
    (make-struct-field-accessor std/misc/channel#channel::t '0))
  (define std/misc/channel#channel-mx
    (make-struct-field-accessor std/misc/channel#channel::t '1))
  (define std/misc/channel#channel-cv
    (make-struct-field-accessor std/misc/channel#channel::t '2))
  (define std/misc/channel#channel-limit
    (make-struct-field-accessor std/misc/channel#channel::t '3))
  (define std/misc/channel#channel-eof
    (make-struct-field-accessor std/misc/channel#channel::t '4))
  (define std/misc/channel#channel-q-set!
    (make-struct-field-mutator std/misc/channel#channel::t '0))
  (define std/misc/channel#channel-mx-set!
    (make-struct-field-mutator std/misc/channel#channel::t '1))
  (define std/misc/channel#channel-cv-set!
    (make-struct-field-mutator std/misc/channel#channel::t '2))
  (define std/misc/channel#channel-limit-set!
    (make-struct-field-mutator std/misc/channel#channel::t '3))
  (define std/misc/channel#channel-eof-set!
    (make-struct-field-mutator std/misc/channel#channel::t '4))
  (define std/misc/channel#&channel-q
    (make-struct-field-unchecked-accessor std/misc/channel#channel::t '0))
  (define std/misc/channel#&channel-mx
    (make-struct-field-unchecked-accessor std/misc/channel#channel::t '1))
  (define std/misc/channel#&channel-cv
    (make-struct-field-unchecked-accessor std/misc/channel#channel::t '2))
  (define std/misc/channel#&channel-limit
    (make-struct-field-unchecked-accessor std/misc/channel#channel::t '3))
  (define std/misc/channel#&channel-eof
    (make-struct-field-unchecked-accessor std/misc/channel#channel::t '4))
  (define std/misc/channel#&channel-q-set!
    (make-struct-field-unchecked-mutator std/misc/channel#channel::t '0))
  (define std/misc/channel#&channel-mx-set!
    (make-struct-field-unchecked-mutator std/misc/channel#channel::t '1))
  (define std/misc/channel#&channel-cv-set!
    (make-struct-field-unchecked-mutator std/misc/channel#channel::t '2))
  (define std/misc/channel#&channel-limit-set!
    (make-struct-field-unchecked-mutator std/misc/channel#channel::t '3))
  (define std/misc/channel#&channel-eof-set!
    (make-struct-field-unchecked-mutator std/misc/channel#channel::t '4))
  (define std/misc/channel#channel:::init!__%
    (lambda (_self1100_ _limit1101_)
      (if (let ((__tmp4753
                 (let () (declare (not safe)) (##vector-length _self1100_))))
            (declare (not safe))
            (##fx< '5 __tmp4753))
          (begin
            (let ((__tmp4754
                   (let ((__obj4751 (make-object std/misc/queue#queue::t '3)))
                     (std/misc/queue#queue:::init! __obj4751)
                     __obj4751)))
              (declare (not safe))
              (##vector-set! _self1100_ '1 __tmp4754))
            (let ((__tmp4755 (make-mutex 'channel)))
              (declare (not safe))
              (##vector-set! _self1100_ '2 __tmp4755))
            (let ((__tmp4756 (make-condition-variable 'channel)))
              (declare (not safe))
              (##vector-set! _self1100_ '3 __tmp4756))
            (let ()
              (declare (not safe))
              (##vector-set! _self1100_ '4 _limit1101_))
            (let () (declare (not safe)) (##vector-set! _self1100_ '5 '#f)))
          (error '"struct-instance-init!: too many arguments for struct"
                 _self1100_))))
  (define std/misc/channel#channel:::init!__0
    (lambda (_self1106_)
      (let ((_limit1108_ '#f))
        (std/misc/channel#channel:::init!__% _self1106_ _limit1108_))))
  (define std/misc/channel#channel:::init!
    (lambda _g4758_
      (let ((_g4757_ (let () (declare (not safe)) (##length _g4758_))))
        (cond ((let () (declare (not safe)) (##fx= _g4757_ 1))
               (apply std/misc/channel#channel:::init!__0 _g4758_))
              ((let () (declare (not safe)) (##fx= _g4757_ 2))
               (apply std/misc/channel#channel:::init!__% _g4758_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/misc/channel#channel:::init!
                _g4758_))))))
  (bind-method!
   std/misc/channel#channel::t
   ':init!
   std/misc/channel#channel:::init!
   '#f)
  (define std/misc/channel#channel-put__%
    (lambda (_ch910_ _val911_ _timeo912_)
      (let* ((_timeo914_ (std/misc/timeout#make-timeout__0 _timeo912_))
             (_ch915924_ _ch910_)
             (_E917928_ (lambda () (error '"No clause matching" _ch915924_)))
             (_K918942_
              (lambda (_limit931_ _cv932_ _mx933_ _q934_)
                (let _lp936_ ()
                  (mutex-lock! _mx933_)
                  (if (let ()
                        (declare (not safe))
                        (##unchecked-structure-ref
                         _ch910_
                         '5
                         std/misc/channel#channel::t
                         '#f))
                      (begin
                        (mutex-unlock! _mx933_)
                        (std/error#raise-io-error
                         'channel-put
                         '"channel is closed"
                         _ch910_))
                      (if (or (not _limit931_)
                              (let ((__tmp4759
                                     (##direct-structure-ref
                                      _q934_
                                      '3
                                      std/misc/queue#queue::t
                                      '#f)))
                                (declare (not safe))
                                (##fx< __tmp4759 _limit931_)))
                          (begin
                            (std/misc/queue#enqueue! _q934_ _val911_)
                            (if (let ((__tmp4760
                                       (##direct-structure-ref
                                        _q934_
                                        '3
                                        std/misc/queue#queue::t
                                        '#f)))
                                  (declare (not safe))
                                  (##fx= __tmp4760 '1))
                                (condition-variable-broadcast! _cv932_)
                                '#!void)
                            (mutex-unlock! _mx933_)
                            '#t)
                          (if (mutex-unlock! _mx933_ _cv932_ _timeo914_)
                              (_lp936_)
                              '#f)))))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _ch915924_
               'std/misc/channel#channel::t))
            (let* ((_e919945_
                    (let () (declare (not safe)) (##vector-ref _ch915924_ '1)))
                   (_q948_ _e919945_)
                   (_e920950_
                    (let () (declare (not safe)) (##vector-ref _ch915924_ '2)))
                   (_mx953_ _e920950_)
                   (_e921955_
                    (let () (declare (not safe)) (##vector-ref _ch915924_ '3)))
                   (_cv958_ _e921955_)
                   (_e922960_
                    (let () (declare (not safe)) (##vector-ref _ch915924_ '4)))
                   (_limit963_ _e922960_))
              (_K918942_ _limit963_ _cv958_ _mx953_ _q948_))
            (_E917928_)))))
  (define std/misc/channel#channel-put__0
    (lambda (_ch968_ _val969_)
      (let ((_timeo971_ '#f))
        (std/misc/channel#channel-put__% _ch968_ _val969_ _timeo971_))))
  (define std/misc/channel#channel-put
    (lambda _g4762_
      (let ((_g4761_ (let () (declare (not safe)) (##length _g4762_))))
        (cond ((let () (declare (not safe)) (##fx= _g4761_ 2))
               (apply std/misc/channel#channel-put__0 _g4762_))
              ((let () (declare (not safe)) (##fx= _g4761_ 3))
               (apply std/misc/channel#channel-put__% _g4762_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/misc/channel#channel-put
                _g4762_))))))
  (define std/misc/channel#channel-try-put
    (lambda (_ch860_ _val861_)
      (let* ((_ch862871_ _ch860_)
             (_E864875_ (lambda () (error '"No clause matching" _ch862871_)))
             (_K865886_
              (lambda (_limit878_ _cv879_ _mx880_ _q881_)
                (mutex-lock! _mx880_)
                (if (let ()
                      (declare (not safe))
                      (##unchecked-structure-ref
                       _ch860_
                       '5
                       std/misc/channel#channel::t
                       '#f))
                    (begin
                      (mutex-unlock! _mx880_)
                      (std/error#raise-io-error
                       'channel-try-put
                       '"channel is closed"
                       _ch860_))
                    (if (or (not _limit878_)
                            (let ((__tmp4763
                                   (##direct-structure-ref
                                    _q881_
                                    '3
                                    std/misc/queue#queue::t
                                    '#f)))
                              (declare (not safe))
                              (##fx< __tmp4763 _limit878_)))
                        (begin
                          (std/misc/queue#enqueue! _q881_ _val861_)
                          (if (let ((__tmp4764
                                     (##direct-structure-ref
                                      _q881_
                                      '3
                                      std/misc/queue#queue::t
                                      '#f)))
                                (declare (not safe))
                                (##fx= __tmp4764 '1))
                              (condition-variable-broadcast! _cv879_)
                              '#!void)
                          (mutex-unlock! _mx880_)
                          '#t)
                        (begin (mutex-unlock! _mx880_) '#f))))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _ch862871_
               'std/misc/channel#channel::t))
            (let* ((_e866889_
                    (let () (declare (not safe)) (##vector-ref _ch862871_ '1)))
                   (_q892_ _e866889_)
                   (_e867894_
                    (let () (declare (not safe)) (##vector-ref _ch862871_ '2)))
                   (_mx897_ _e867894_)
                   (_e868899_
                    (let () (declare (not safe)) (##vector-ref _ch862871_ '3)))
                   (_cv902_ _e868899_)
                   (_e869904_
                    (let () (declare (not safe)) (##vector-ref _ch862871_ '4)))
                   (_limit907_ _e869904_))
              (_K865886_ _limit907_ _cv902_ _mx897_ _q892_))
            (_E864875_)))))
  (define std/misc/channel#channel-sync
    (lambda (_ch810_ . _vals811_)
      (let* ((_ch812821_ _ch810_)
             (_E814825_ (lambda () (error '"No clause matching" _ch812821_)))
             (_K815837_
              (lambda (_limit828_ _cv829_ _mx830_ _q831_)
                (mutex-lock! _mx830_)
                (if (let ()
                      (declare (not safe))
                      (##unchecked-structure-ref
                       _ch810_
                       '5
                       std/misc/channel#channel::t
                       '#f))
                    (begin
                      (mutex-unlock! _mx830_)
                      (std/error#raise-io-error
                       'channel-sync
                       '"channel is closed"
                       _ch810_))
                    (begin
                      (if (null? _vals811_)
                          '#!void
                          (begin
                            (for-each
                             (lambda (_g832834_)
                               (std/misc/queue#enqueue! _q831_ _g832834_))
                             _vals811_)
                            (condition-variable-broadcast! _cv829_)))
                      (mutex-unlock! _mx830_))))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _ch812821_
               'std/misc/channel#channel::t))
            (let* ((_e816840_
                    (let () (declare (not safe)) (##vector-ref _ch812821_ '1)))
                   (_q843_ _e816840_)
                   (_e817845_
                    (let () (declare (not safe)) (##vector-ref _ch812821_ '2)))
                   (_mx848_ _e817845_)
                   (_e818850_
                    (let () (declare (not safe)) (##vector-ref _ch812821_ '3)))
                   (_cv853_ _e818850_)
                   (_e819855_
                    (let () (declare (not safe)) (##vector-ref _ch812821_ '4)))
                   (_limit858_ _e819855_))
              (_K815837_ _limit858_ _cv853_ _mx848_ _q843_))
            (_E814825_)))))
  (define std/misc/channel#channel-get__%
    (lambda (_ch738_ _timeo739_ _default740_)
      (let* ((_timeo742_ (std/misc/timeout#make-timeout__0 _timeo739_))
             (_ch743752_ _ch738_)
             (_E745756_ (lambda () (error '"No clause matching" _ch743752_)))
             (_K746769_
              (lambda (_limit759_ _cv760_ _mx761_ _q762_)
                (let _lp764_ ()
                  (mutex-lock! _mx761_)
                  (if (std/misc/queue#queue-empty? _q762_)
                      (if (let ()
                            (declare (not safe))
                            (##unchecked-structure-ref
                             _ch738_
                             '5
                             std/misc/channel#channel::t
                             '#f))
                          (begin (mutex-unlock! _mx761_) '#!eof)
                          (if (mutex-unlock! _mx761_ _cv760_ _timeo742_)
                              (_lp764_)
                              _default740_))
                      (let ((_next767_ (std/misc/queue#dequeue!__0 _q762_)))
                        (if (and _limit759_
                                 (let ((__tmp4766
                                        (##direct-structure-ref
                                         _q762_
                                         '3
                                         std/misc/queue#queue::t
                                         '#f))
                                       (__tmp4765
                                        (let ()
                                          (declare (not safe))
                                          (##fx- _limit759_ '1))))
                                   (declare (not safe))
                                   (##fx= __tmp4766 __tmp4765)))
                            (condition-variable-broadcast! _cv760_)
                            '#!void)
                        (mutex-unlock! _mx761_)
                        _next767_))))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _ch743752_
               'std/misc/channel#channel::t))
            (let* ((_e747772_
                    (let () (declare (not safe)) (##vector-ref _ch743752_ '1)))
                   (_q775_ _e747772_)
                   (_e748777_
                    (let () (declare (not safe)) (##vector-ref _ch743752_ '2)))
                   (_mx780_ _e748777_)
                   (_e749782_
                    (let () (declare (not safe)) (##vector-ref _ch743752_ '3)))
                   (_cv785_ _e749782_)
                   (_e750787_
                    (let () (declare (not safe)) (##vector-ref _ch743752_ '4)))
                   (_limit790_ _e750787_))
              (_K746769_ _limit790_ _cv785_ _mx780_ _q775_))
            (_E745756_)))))
  (define std/misc/channel#channel-get__0
    (lambda (_ch795_)
      (let* ((_timeo797_ '#f) (_default799_ '#f))
        (std/misc/channel#channel-get__% _ch795_ _timeo797_ _default799_))))
  (define std/misc/channel#channel-get__1
    (lambda (_ch801_ _timeo802_)
      (let ((_default804_ '#f))
        (std/misc/channel#channel-get__% _ch801_ _timeo802_ _default804_))))
  (define std/misc/channel#channel-get
    (lambda _g4768_
      (let ((_g4767_ (let () (declare (not safe)) (##length _g4768_))))
        (cond ((let () (declare (not safe)) (##fx= _g4767_ 1))
               (apply std/misc/channel#channel-get__0 _g4768_))
              ((let () (declare (not safe)) (##fx= _g4767_ 2))
               (apply std/misc/channel#channel-get__1 _g4768_))
              ((let () (declare (not safe)) (##fx= _g4767_ 3))
               (apply std/misc/channel#channel-get__% _g4768_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/misc/channel#channel-get
                _g4768_))))))
  (define std/misc/channel#channel-try-get__%
    (lambda (_ch679_ _default680_)
      (let* ((_ch681690_ _ch679_)
             (_E683694_ (lambda () (error '"No clause matching" _ch681690_)))
             (_K684704_
              (lambda (_limit697_ _cv698_ _mx699_ _q700_)
                (mutex-lock! _mx699_)
                (if (std/misc/queue#queue-empty? _q700_)
                    (begin
                      (mutex-unlock! _mx699_)
                      (if (let ()
                            (declare (not safe))
                            (##unchecked-structure-ref
                             _ch679_
                             '5
                             std/misc/channel#channel::t
                             '#f))
                          '#!eof
                          _default680_))
                    (let ((_next702_ (std/misc/queue#dequeue!__0 _q700_)))
                      (if (and _limit697_
                               (let ((__tmp4770
                                      (##direct-structure-ref
                                       _q700_
                                       '3
                                       std/misc/queue#queue::t
                                       '#f))
                                     (__tmp4769
                                      (let ()
                                        (declare (not safe))
                                        (##fx- _limit697_ '1))))
                                 (declare (not safe))
                                 (##fx= __tmp4770 __tmp4769)))
                          (condition-variable-broadcast! _cv698_)
                          '#!void)
                      (mutex-unlock! _mx699_)
                      _next702_)))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _ch681690_
               'std/misc/channel#channel::t))
            (let* ((_e685707_
                    (let () (declare (not safe)) (##vector-ref _ch681690_ '1)))
                   (_q710_ _e685707_)
                   (_e686712_
                    (let () (declare (not safe)) (##vector-ref _ch681690_ '2)))
                   (_mx715_ _e686712_)
                   (_e687717_
                    (let () (declare (not safe)) (##vector-ref _ch681690_ '3)))
                   (_cv720_ _e687717_)
                   (_e688722_
                    (let () (declare (not safe)) (##vector-ref _ch681690_ '4)))
                   (_limit725_ _e688722_))
              (_K684704_ _limit725_ _cv720_ _mx715_ _q710_))
            (_E683694_)))))
  (define std/misc/channel#channel-try-get__0
    (lambda (_ch730_)
      (let ((_default732_ '#f))
        (std/misc/channel#channel-try-get__% _ch730_ _default732_))))
  (define std/misc/channel#channel-try-get
    (lambda _g4772_
      (let ((_g4771_ (let () (declare (not safe)) (##length _g4772_))))
        (cond ((let () (declare (not safe)) (##fx= _g4771_ 1))
               (apply std/misc/channel#channel-try-get__0 _g4772_))
              ((let () (declare (not safe)) (##fx= _g4771_ 2))
               (apply std/misc/channel#channel-try-get__% _g4772_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/misc/channel#channel-try-get
                _g4772_))))))
  (define std/misc/channel#channel-close
    (lambda (_ch629_)
      (let* ((_ch630640_ _ch629_)
             (_E632644_ (lambda () (error '"No clause matching" _ch630640_)))
             (_K633652_
              (lambda (_eof647_ _cv648_ _mx649_ _q650_)
                (if _eof647_
                    '#!void
                    (begin
                      (mutex-lock! _mx649_)
                      (let ()
                        (declare (not safe))
                        (##unchecked-structure-set!
                         _ch629_
                         '#t
                         '5
                         std/misc/channel#channel::t
                         '#f))
                      (condition-variable-broadcast!
                       (##direct-structure-ref
                        _ch629_
                        '3
                        std/misc/channel#channel::t
                        '#f))
                      (mutex-unlock! _mx649_))))))
        (if (let ()
              (declare (not safe))
              (##structure-direct-instance-of?
               _ch630640_
               'std/misc/channel#channel::t))
            (let* ((_e634655_
                    (let () (declare (not safe)) (##vector-ref _ch630640_ '1)))
                   (_q658_ _e634655_)
                   (_e635660_
                    (let () (declare (not safe)) (##vector-ref _ch630640_ '2)))
                   (_mx663_ _e635660_)
                   (_e636665_
                    (let () (declare (not safe)) (##vector-ref _ch630640_ '3)))
                   (_cv668_ _e636665_)
                   (_e637670_
                    (let () (declare (not safe)) (##vector-ref _ch630640_ '4)))
                   (_e638673_
                    (let () (declare (not safe)) (##vector-ref _ch630640_ '5)))
                   (_eof676_ _e638673_))
              (_K633652_ _eof676_ _cv668_ _mx663_ _q658_))
            (_E632644_)))))
  (define std/misc/channel#channel::destroy std/misc/channel#channel-close)
  (bind-method!
   std/misc/channel#channel::t
   'destroy
   std/misc/channel#channel::destroy
   '#f)
  (define std/misc/channel#channel-closed?
    (lambda (_ch505_)
      (##direct-structure-ref _ch505_ '5 std/misc/channel#channel::t '#f)))
  (define std/misc/channel#:iter::channel
    (lambda (_ch503_) (std/misc/channel#iter-channel _ch503_)))
  (std/generic/dispatch#generic-bind!
   std/iter#:iter::t
   (cons (std/generic/dispatch#type-linearize-class
          std/misc/channel#channel::t)
         '())
   std/misc/channel#:iter::channel)
  (define std/misc/channel#iter-channel
    (lambda (_ch406_)
      (letrec ((_next408_
                (lambda (_it410_)
                  (let* ((_it411417_ _it410_)
                         (_E413421_
                          (lambda () (error '"No clause matching" _it411417_)))
                         (_K414428_
                          (lambda (_ch424_)
                            (let ((_val426_
                                   (std/misc/channel#channel-get__0 _ch424_)))
                              (if (eof-object? _val426_)
                                  std/iter#iter-end
                                  _val426_)))))
                    (if (let ()
                          (declare (not safe))
                          (##structure-direct-instance-of?
                           _it411417_
                           'std/iter#iterator::t))
                        (let* ((_e415431_
                                (let ()
                                  (declare (not safe))
                                  (##vector-ref _it411417_ '1)))
                               (_ch434_ _e415431_))
                          (_K414428_ _ch434_))
                        (_E413421_))))))
        (let ((__obj4752 (make-object std/iter#iterator::t '3)))
          (std/iter#iterator:::init!__0 __obj4752 _ch406_ _next408_)
          __obj4752)))))
