(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/os/fd#open-raw-device
    (lambda (_direction418_ _id419_ _fd420_)
      (letrec ((_fail422_
                (lambda ()
                  (let ()
                    (declare (not safe))
                    (##fail-check-settings
                     '1
                     std/os/fd#open-raw-device
                     _direction418_
                     _id419_
                     _fd420_)))))
        (let ((__tmp4027
               (lambda (_psettings424_)
                 (let ((_device426_
                        (let ((__tmp4028
                               (let ()
                                 (declare (not safe))
                                 (##psettings->device-flags _psettings424_))))
                          (declare (not safe))
                          (##os-device-open-raw-from-fd _fd420_ __tmp4028))))
                   (if (let () (declare (not safe)) (##fixnum? _device426_))
                       (let ()
                         (declare (not safe))
                         (##raise-os-exception
                          '#f
                          _device426_
                          std/os/fd#open-raw-device
                          _direction418_
                          _id419_
                          _fd420_))
                       (let ((__tmp4029 (cons _id419_ (cons _fd420_ '()))))
                         (declare (not safe))
                         (##make-raw-device-port
                          _direction418_
                          _device426_
                          _id419_
                          __tmp4029
                          _fd420_)))))))
          (declare (not safe))
          (##make-psettings _direction418_ '() '() _fail422_ __tmp4027)))))
  (define std/os/fd#direction
    (lambda (_dir413_)
      (let ((_$e415_ _dir413_))
        (if (eq? 'in _$e415_)
            (macro-direction-in)
            (if (eq? 'out _$e415_)
                (macro-direction-out)
                (if (eq? 'inout _$e415_)
                    (macro-direction-inout)
                    (error '"Bad direction; must be in, out, or inout"
                           _dir413_)))))))
  (define std/os/fd#fdopen
    (lambda (_fd407_ _dir408_ _t409_)
      (let ((_dirx411_ (std/os/fd#direction _dir408_)))
        (std/os/fd#open-raw-device _dirx411_ _t409_ _fd407_))))
  (define std/os/fd#fdopen-port
    (lambda (_fd401_ _dir402_ _name403_)
      (let ((_dirx405_ (std/os/fd#direction _dir402_)))
        (declare (not safe))
        (##open-predefined _dirx405_ _name403_ _fd401_))))
  (define std/os/fd#fd-e
    (lambda (_raw399_) (values (macro-raw-device-port-specific _raw399_))))
  (define std/os/fd#fd-io-in
    (lambda (_raw397_)
      (values (macro-raw-device-port-rdevice-condvar _raw397_))))
  (define std/os/fd#fd-io-out
    (lambda (_raw395_)
      (values (macro-raw-device-port-wdevice-condvar _raw395_))))
  (define std/os/fd#fd-type
    (lambda (_raw393_) (values (macro-raw-device-port-type _raw393_))))
  (define std/os/fd#fd?
    (lambda (_obj391_) (values (macro-raw-device-port? _obj391_))))
  (define std/os/fd#fd-type?
    (lambda (_obj388_ _t389_)
      (if (macro-raw-device-port? _obj388_)
          (eq? (std/os/fd#fd-type _obj388_) _t389_)
          '#f))))
