(declare (block) (standard-bindings) (extended-bindings))
(define std/net/socket/basic-socket#basic-socket
  (lambda (_sock422_)
    (letrec ((_wait-io!424_
              (lambda (_io500_ _timeo501_)
                (let ((__tmp5562
                       (if _timeo501_ (time->seconds _timeo501_) '#t)))
                  (declare (not safe))
                  (##wait-for-io! _io500_ __tmp5562))))
             (_shutdown!425_
              (lambda (_sock496_ _how497_)
                (if _how497_
                    (with-exception-catcher
                     void
                     (lambda ()
                       (std/os/socket#socket-shutdown _sock496_ _how497_)))
                    '#!void)))
             (_close426_
              (lambda (_ssock449_ _dir450_ _shutdown451_)
                (let* ((_ssock452461_ _ssock449_)
                       (_E454465_
                        (lambda ()
                          (error '"No clause matching" _ssock452461_)))
                       (_K455475_
                        (lambda (_wait-out468_ _wait-in469_ _sock470_)
                          (let ((_$e472_ _dir450_))
                            (if (eq? 'in _$e472_)
                                (if _wait-in469_
                                    (begin
                                      (##direct-structure-set!
                                       _ssock449_
                                       '#f
                                       '2
                                       std/net/socket/base#!socket::t
                                       '#f)
                                      (_shutdown!425_ _sock470_ _shutdown451_)
                                      (if _wait-out468_
                                          (close-input-port _sock470_)
                                          (close-port _sock470_)))
                                    '#!void)
                                (if (eq? 'out _$e472_)
                                    (if _wait-out468_
                                        (begin
                                          (##direct-structure-set!
                                           _ssock449_
                                           '#f
                                           '3
                                           std/net/socket/base#!socket::t
                                           '#f)
                                          (_shutdown!425_
                                           _sock470_
                                           _shutdown451_)
                                          (if _wait-in469_
                                              (close-output-port _sock470_)
                                              (close-port _sock470_)))
                                        '#!void)
                                    (if (eq? 'inout _$e472_)
                                        (begin
                                          (##direct-structure-set!
                                           _ssock449_
                                           '#f
                                           '2
                                           std/net/socket/base#!socket::t
                                           '#f)
                                          (##direct-structure-set!
                                           _ssock449_
                                           '#f
                                           '3
                                           std/net/socket/base#!socket::t
                                           '#f)
                                          (close-port _sock470_))
                                        (error '"Bad direction"
                                               _dir450_))))))))
                  (if (let ()
                        (declare (not safe))
                        (##structure-direct-instance-of?
                         _ssock452461_
                         'std/net/socket/base#!socket::t))
                      (let* ((_e456478_
                              (let ()
                                (declare (not safe))
                                (##vector-ref _ssock452461_ '1)))
                             (_sock481_ _e456478_)
                             (_e457483_
                              (let ()
                                (declare (not safe))
                                (##vector-ref _ssock452461_ '2)))
                             (_e458486_
                              (let ()
                                (declare (not safe))
                                (##vector-ref _ssock452461_ '3)))
                             (_wait-in489_ _e458486_)
                             (_e459491_
                              (let ()
                                (declare (not safe))
                                (##vector-ref _ssock452461_ '4)))
                             (_wait-out494_ _e459491_))
                        (_K455475_ _wait-out494_ _wait-in489_ _sock481_))
                      (_E454465_))))))
      (let* ((_io-in428_ (std/os/fd#fd-io-in _sock422_))
             (_wait-in433_
              (if _io-in428_
                  (lambda (_ssock430_ _timeo431_)
                    (_wait-io!424_ _io-in428_ _timeo431_))
                  '#f))
             (_io-out435_ (std/os/fd#fd-io-out _sock422_))
             (_wait-out440_
              (if _io-out435_
                  (lambda (_ssock437_ _timeo438_)
                    (_wait-io!424_ _io-out435_ _timeo438_))
                  '#f))
             (_ssock442_
              (let ()
                (declare (not safe))
                (##structure
                 std/net/socket/base#!socket::t
                 _sock422_
                 _wait-in433_
                 _wait-out440_
                 _close426_))))
        (make-will
         _ssock442_
         (lambda (_g444446_) (_close426_ _g444446_ 'inout '#f)))
        _ssock442_))))
