(module $CRC32Hex
  (memory (export "memory") 3 3)
  (global $input_ptr i32 (i32.const 0x10000))
  (func (export "input_ptr") (result i32)
    (global.get $input_ptr))
  (global $input_bytes_cap i32 (i32.const 0x10000))
  (func (export "input_bytes_cap") (result i32)
    (global.get $input_bytes_cap))
  (global $output_ptr i32 (i32.const 0x20000))
  (global $output_utf8_cap i32 (i32.const 8))
  (func (export "output_utf8_cap") (result i32)
    (global.get $output_utf8_cap))
  (func $hex_digit (param $n i32) (result i32)
    (if (result i32)
      (i32.lt_u (local.get $n) (i32.const 10))
      (then
        (i32.add (local.get $n) (i32.const 48))
      )
      (else
        (i32.add (i32.sub (local.get $n) (i32.const 10)) (i32.const 97))
      )
    )
  )
  (func $render_size (param $input_size i32) (result i32)
    (local $ptr i32)
    (local $i i32)
    (local $c i32)
    (local $out i32)
    (if (i32.gt_u (local.get $input_size) (global.get $input_bytes_cap))
      (then unreachable)
    )
    (local.set $ptr (global.get $input_ptr))
    (i32.const 4294967295)
    (local.set $c)
    (if (i32.gt_s (local.get $input_size) (i32.const 0))
      (then
    (loop $EachByte
      (i32.xor
        (local.get $c)
        (i32.load8_u (i32.add (local.get $ptr) (local.get $i)))
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.and
        (local.get $c)
        (i32.const 1)
      )
      (if (result i32)
        (then
          (i32.xor (i32.shr_u (local.get $c) (i32.const 1)) (i32.const 3988292384))
        )
        (else
          (i32.shr_u (local.get $c) (i32.const 1))
        )
      )
      (local.set $c)
      (i32.add (local.get $i) (i32.const 1))
      (local.set $i)
      (i32.lt_s (local.get $i) (local.get $input_size))
      (if
        (then
          (br $EachByte)
        )
      )
    )
      )
    )
    (local.set $out (global.get $output_ptr))
    (local.set $c (i32.xor (local.get $c) (i32.const 4294967295)))
    (i32.store8 (local.get $out) (call $hex_digit (i32.and (i32.shr_u (local.get $c) (i32.const 28)) (i32.const 15))))
    (i32.store8 (i32.add (local.get $out) (i32.const 1)) (call $hex_digit (i32.and (i32.shr_u (local.get $c) (i32.const 24)) (i32.const 15))))
    (i32.store8 (i32.add (local.get $out) (i32.const 2)) (call $hex_digit (i32.and (i32.shr_u (local.get $c) (i32.const 20)) (i32.const 15))))
    (i32.store8 (i32.add (local.get $out) (i32.const 3)) (call $hex_digit (i32.and (i32.shr_u (local.get $c) (i32.const 16)) (i32.const 15))))
    (i32.store8 (i32.add (local.get $out) (i32.const 4)) (call $hex_digit (i32.and (i32.shr_u (local.get $c) (i32.const 12)) (i32.const 15))))
    (i32.store8 (i32.add (local.get $out) (i32.const 5)) (call $hex_digit (i32.and (i32.shr_u (local.get $c) (i32.const 8)) (i32.const 15))))
    (i32.store8 (i32.add (local.get $out) (i32.const 6)) (call $hex_digit (i32.and (i32.shr_u (local.get $c) (i32.const 4)) (i32.const 15))))
    (i32.store8 (i32.add (local.get $out) (i32.const 7)) (call $hex_digit (i32.and (local.get $c) (i32.const 15))))
    (i32.const 8)
  )
  (func (export "render") (param $input_size i32) (result i64)
    (i64.or
      (i64.shl (i64.extend_i32_u (global.get $output_ptr)) (i64.const 32))
      (i64.extend_i32_u (call $render_size (local.get $input_size)))))
)