(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/amb#amb-exhausted (lambda () (error '"AMB tree exhausted")))
  (define std/amb#amb-fail (make-parameter std/amb#amb-exhausted))
  (define std/amb#amb-do
    (lambda (_thunks40489_)
      (let ((_fail40491_ (std/amb#amb-fail)))
        (call-with-current-continuation
         (lambda (_return40493_)
           (let _loop40495_ ((_rest40497_
                              (std/misc/shuffle#shuffle _thunks40489_)))
             (let* ((_rest4049840506_ _rest40497_)
                    (_else4050040514_
                     (lambda () (std/amb#amb-fail _fail40491_) (_fail40491_)))
                    (_K4050240521_
                     (lambda (_rest40517_ _thunk40518_)
                       (std/amb#amb-fail (lambda () (_loop40495_ _rest40517_)))
                       (_return40493_ (_thunk40518_)))))
               (if (##pair? _rest4049840506_)
                   (let ((_hd4050340524_ (##car _rest4049840506_))
                         (_tl4050440526_ (##cdr _rest4049840506_)))
                     (let* ((_thunk40529_ _hd4050340524_)
                            (_rest40531_ _tl4050440526_))
                       (_K4050240521_ _rest40531_ _thunk40529_)))
                   (_else4050040514_)))))))))
  (define std/amb#amb-do-find__%
    (lambda (_thunk40470_ _failure40471_)
      (call-with-current-continuation
       (lambda (_return40473_)
         (let ((_fail40476_ (lambda () (_return40473_ (_failure40471_)))))
           (call-with-parameters
            (lambda () (_thunk40470_))
            std/amb#amb-fail
            _fail40476_))))))
  (define std/amb#amb-do-find__0
    (lambda (_thunk40482_)
      (let ((_failure40484_ std/amb#amb-exhausted))
        (std/amb#amb-do-find__% _thunk40482_ _failure40484_))))
  (define std/amb#amb-do-find
    (lambda _g40634_
      (let ((_g40633_ (length _g40634_)))
        (cond ((##fx= _g40633_ 1) (apply std/amb#amb-do-find__0 _g40634_))
              ((##fx= _g40633_ 2) (apply std/amb#amb-do-find__% _g40634_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/amb#amb-do-find
                _g40634_))))))
  (define std/amb#amb-do-collect
    (lambda (_thunk40452_)
      (let ((_fail40454_ '#f))
        (dynamic-wind
         (lambda () (set! _fail40454_ (std/amb#amb-fail)))
         (lambda ()
           (call-with-current-continuation
            (lambda (_return40458_)
              (let* ((_root40460_ (cons '#f '())) (_hd40462_ _root40460_))
                (std/amb#amb-fail
                 (lambda () (_return40458_ (cdr _root40460_))))
                (let ((_tl40466_ (cons (_thunk40452_) '())))
                  (set-cdr! _hd40462_ _tl40466_)
                  (set! _hd40462_ _tl40466_))
                ((std/amb#amb-fail))))))
         (lambda () (std/amb#amb-fail _fail40454_)))))))
