(declare (block) (standard-bindings) (extended-bindings))
(begin
  (declare (not safe))
  (define std/text/base58#alphabet::t
    (make-struct-type
     'std/text/base58#alphabet::t
     '#f
     '2
     'alphabet
     '((final: . #t))
     ':init!
     '(enc dec)))
  (define std/text/base58#alphabet?
    (make-struct-predicate std/text/base58#alphabet::t))
  (define std/text/base58#make-alphabet
    (lambda _$args626_
      (apply make-struct-instance std/text/base58#alphabet::t _$args626_)))
  (define std/text/base58#alphabet-enc
    (make-struct-field-accessor std/text/base58#alphabet::t '0))
  (define std/text/base58#alphabet-dec
    (make-struct-field-accessor std/text/base58#alphabet::t '1))
  (define std/text/base58#alphabet-enc-set!
    (make-struct-field-mutator std/text/base58#alphabet::t '0))
  (define std/text/base58#alphabet-dec-set!
    (make-struct-field-mutator std/text/base58#alphabet::t '1))
  (define std/text/base58#&alphabet-enc
    (make-struct-field-unchecked-accessor std/text/base58#alphabet::t '0))
  (define std/text/base58#&alphabet-dec
    (make-struct-field-unchecked-accessor std/text/base58#alphabet::t '1))
  (define std/text/base58#&alphabet-enc-set!
    (make-struct-field-unchecked-mutator std/text/base58#alphabet::t '0))
  (define std/text/base58#&alphabet-dec-set!
    (make-struct-field-unchecked-mutator std/text/base58#alphabet::t '1))
  (define std/text/base58#alphabet:::init!
    (lambda (_self613_ _str614_)
      (let* ((_alpha616_ (string->list _str614_))
             (_enc618_ (list->vector _alpha616_))
             (_dec620_ (make-vector '128 '#f)))
        (for-each
         (lambda (_i623_ _a624_)
           (vector-set! _dec620_ (char->integer _a624_) _i623_))
         (iota (string-length _str614_))
         _alpha616_)
        (if (##fx< '2 (##vector-length _self613_))
            (begin
              (##vector-set! _self613_ '1 _enc618_)
              (##vector-set! _self613_ '2 _dec620_))
            (error '"struct-instance-init!: too many arguments for struct"
                   _self613_)))))
  (bind-method!
   std/text/base58#alphabet::t
   ':init!
   std/text/base58#alphabet:::init!
   '#f)
  (define std/text/base58#alphabet-encode
    (lambda (_ab486_ _i487_)
      (vector-ref
       (##unchecked-structure-ref _ab486_ '1 std/text/base58#alphabet::t '#f)
       _i487_)))
  (define std/text/base58#alphabet-decode
    (lambda (_ab481_ _char482_)
      (let ((_i484_ (char->integer _char482_)))
        (if (fx< _i484_ '128)
            (vector-ref
             (##unchecked-structure-ref
              _ab481_
              '2
              std/text/base58#alphabet::t
              '#f)
             _i484_)
            '#f))))
  (define std/text/base58#base58-btc-alphabet
    (let ((__obj4264 (make-object std/text/base58#alphabet::t '2)))
      (std/text/base58#alphabet:::init!
       __obj4264
       '"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
      __obj4264))
  (define std/text/base58#base58-flickr-alphabet
    (let ((__obj4265 (make-object std/text/base58#alphabet::t '2)))
      (std/text/base58#alphabet:::init!
       __obj4265
       '"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")
      __obj4265))
  (define std/text/base58#base58-encode__%
    (lambda (_bytes445_ _ab446_)
      (let* ((_idx448_
              (fx+ (fxquotient (fx* (u8vector-length _bytes445_) '138) '100)
                   '1))
             (_str450_ (make-string _idx448_)))
        (let _lp453_ ((_bn455_ (std/text/base58#bytes->integer _bytes445_))
                      (_idx456_ _idx448_))
          (if (zero? _bn455_)
              (let ((_zero458_ (std/text/base58#alphabet-encode _ab446_ '0)))
                (let _pad460_ ((_i462_ '0) (_idx463_ _idx456_))
                  (if (and (fx< _i462_ (u8vector-length _bytes445_))
                           (fxzero? (u8vector-ref _bytes445_ _i462_)))
                      (let ((_idx465_ (fx- _idx463_ '1)))
                        (string-set! _str450_ _idx465_ _zero458_)
                        (_pad460_ (fx+ _i462_ '1) _idx465_))
                      (substring _str450_ _idx463_ (string-length _str450_)))))
              (let ((_bn467_ (quotient _bn455_ '58))
                    (_mo468_ (modulo _bn455_ '58))
                    (_idx469_ (fx- _idx456_ '1)))
                (string-set!
                 _str450_
                 _idx469_
                 (std/text/base58#alphabet-encode _ab446_ _mo468_))
                (_lp453_ _bn467_ _idx469_)))))))
  (define std/text/base58#base58-encode__0
    (lambda (_bytes474_)
      (let ((_ab476_ std/text/base58#base58-btc-alphabet))
        (std/text/base58#base58-encode__% _bytes474_ _ab476_))))
  (define std/text/base58#base58-encode
    (lambda _g4267_
      (let ((_g4266_ (##length _g4267_)))
        (cond ((##fx= _g4266_ 1)
               (apply std/text/base58#base58-encode__0 _g4267_))
              ((##fx= _g4266_ 2)
               (apply std/text/base58#base58-encode__% _g4267_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/text/base58#base58-encode
                _g4267_))))))
  (define std/text/base58#base58-decode__%
    (lambda (_str407_ _ab408_)
      (letrec* ((_leading-zeros410_
                 (let ((_zero428_
                        (std/text/base58#alphabet-encode _ab408_ '0)))
                   (let _lp430_ ((_i432_ '0))
                     (if (and (fx< _i432_ (string-length _str407_))
                              (eq? _zero428_ (string-ref _str407_ _i432_)))
                         (_lp430_ (fx+ _i432_ '1))
                         (make-u8vector _i432_))))))
        (let _lp412_ ((_i414_ '0) (_bn415_ '0))
          (if (fx< _i414_ (string-length _str407_))
              (let* ((_char417_ (string-ref _str407_ _i414_))
                     (_int419_ (char->integer _char417_))
                     (_g4268_ (if (fx< _int419_ '128)
                                  '#!void
                                  (std/error#raise-io-error
                                   'base58-decode
                                   '"Invalid character"
                                   _str407_
                                   _char417_))))
                (let ((_$e423_ (std/text/base58#alphabet-decode
                                _ab408_
                                _int419_)))
                  (if _$e423_
                      ((lambda (_c426_)
                         (_lp412_ (fx+ _i414_ '1) (+ (* _bn415_ '58) _c426_)))
                       _$e423_)
                      (std/error#raise-io-error
                       'base58-decode
                       '"Invalid character"
                       _str407_
                       _char417_))))
              (u8vector-append
               _leading-zeros410_
               (std/text/base58#integer->bytes _bn415_)))))))
  (define std/text/base58#base58-decode__0
    (lambda (_str437_)
      (let ((_ab439_ std/text/base58#base58-btc-alphabet))
        (std/text/base58#base58-decode__% _str437_ _ab439_))))
  (define std/text/base58#base58-decode
    (lambda _g4270_
      (let ((_g4269_ (##length _g4270_)))
        (cond ((##fx= _g4269_ 1)
               (apply std/text/base58#base58-decode__0 _g4270_))
              ((##fx= _g4269_ 2)
               (apply std/text/base58#base58-decode__% _g4270_))
              (else
               (##raise-wrong-number-of-arguments-exception
                std/text/base58#base58-decode
                _g4270_))))))
  (define std/text/base58#bytes->integer
    (lambda (_bytes397_)
      (let _lp399_ ((_i401_ '0) (_r402_ '0))
        (if (fx< _i401_ (u8vector-length _bytes397_))
            (let ((_b404_ (u8vector-ref _bytes397_ _i401_)))
              (_lp399_ (fx+ _i401_ '1)
                       (bitwise-ior (arithmetic-shift _r402_ '8) _b404_)))
            _r402_))))
  (define std/text/base58#integer->bytes
    (lambda (_x390_)
      (let _lp392_ ((_x394_ _x390_) (_r395_ '()))
        (if (positive? _x394_)
            (_lp392_ (arithmetic-shift _x394_ '-8)
                     (cons (bitwise-and _x394_ '255) _r395_))
            (list->u8vector _r395_))))))
