(module io (export print_i32_zero print_u32_zero print_i64_zero print_u64_zero print_f64_zero print_string_zero print_bool_zero print_i32_value print_u32_value print_i64_value print_u64_value print_f64_value print_string_value print_bool_value read_stdin_result read_stdin_option read_stdin_or read_stdin_i32_result read_stdin_i32_option read_stdin_i32_or_zero read_stdin_i32_or read_stdin_u32_result read_stdin_u32_option read_stdin_u32_or_zero read_stdin_u32_or read_stdin_i64_result read_stdin_i64_option read_stdin_i64_or_zero read_stdin_i64_or read_stdin_u64_result read_stdin_u64_option read_stdin_u64_or_zero read_stdin_u64_or read_stdin_f64_result read_stdin_f64_option read_stdin_f64_or_zero read_stdin_f64_or read_stdin_bool_result read_stdin_bool_option read_stdin_bool_or_false read_stdin_bool_or))

(import result (ok_or_none_string ok_or_none_i32 ok_or_none_u32 ok_or_none_i64 ok_or_none_u64 ok_or_none_f64 ok_or_none_bool))

(import string (parse_i32_result parse_u32_result parse_i64_result parse_u64_result parse_f64_result parse_bool_result))

(fn print_i32_zero ((value i32)) -> i32
  (std.io.print_i32 value)
  0)

(fn print_u32_zero ((value u32)) -> i32
  (std.io.print_u32 value)
  0)

(fn print_i64_zero ((value i64)) -> i32
  (std.io.print_i64 value)
  0)

(fn print_u64_zero ((value u64)) -> i32
  (std.io.print_u64 value)
  0)

(fn print_f64_zero ((value f64)) -> i32
  (std.io.print_f64 value)
  0)

(fn print_string_zero ((value string)) -> i32
  (std.io.print_string value)
  0)

(fn print_bool_zero ((value bool)) -> i32
  (std.io.print_bool value)
  0)

(fn print_i32_value ((value i32)) -> i32
  (std.io.print_i32 value)
  value)

(fn print_u32_value ((value u32)) -> u32
  (std.io.print_u32 value)
  value)

(fn print_i64_value ((value i64)) -> i64
  (std.io.print_i64 value)
  value)

(fn print_u64_value ((value u64)) -> u64
  (std.io.print_u64 value)
  value)

(fn print_f64_value ((value f64)) -> f64
  (std.io.print_f64 value)
  value)

(fn print_string_value ((value string)) -> string
  (std.io.print_string value)
  value)

(fn print_bool_value ((value bool)) -> bool
  (std.io.print_bool value)
  value)

(fn read_stdin_result () -> (result string i32)
  (std.io.read_stdin_result))

(fn read_stdin_option () -> (option string)
  (ok_or_none_string (read_stdin_result)))

(fn read_stdin_or ((fallback string)) -> string
  (match (read_stdin_result)
    ((ok payload)
      payload)
    ((err code)
      fallback)))

(fn read_stdin_i32_result () -> (result i32 i32)
  (match (read_stdin_result)
    ((ok text)
      (parse_i32_result text))
    ((err code)
      (err i32 i32 code))))

(fn read_stdin_i32_option () -> (option i32)
  (ok_or_none_i32 (read_stdin_i32_result)))

(fn read_stdin_i32_or_zero () -> i32
  (match (read_stdin_i32_result)
    ((ok value)
      value)
    ((err code)
      0)))

(fn read_stdin_i32_or ((fallback i32)) -> i32
  (match (read_stdin_i32_result)
    ((ok value)
      value)
    ((err code)
      fallback)))

(fn read_stdin_u32_result () -> (result u32 i32)
  (match (read_stdin_result)
    ((ok text)
      (parse_u32_result text))
    ((err code)
      (err u32 i32 code))))

(fn read_stdin_u32_option () -> (option u32)
  (ok_or_none_u32 (read_stdin_u32_result)))

(fn read_stdin_u32_or_zero () -> u32
  (match (read_stdin_u32_result)
    ((ok value)
      value)
    ((err code)
      0u32)))

(fn read_stdin_u32_or ((fallback u32)) -> u32
  (match (read_stdin_u32_result)
    ((ok value)
      value)
    ((err code)
      fallback)))

(fn read_stdin_i64_result () -> (result i64 i32)
  (match (read_stdin_result)
    ((ok text)
      (parse_i64_result text))
    ((err code)
      (err i64 i32 code))))

(fn read_stdin_i64_option () -> (option i64)
  (ok_or_none_i64 (read_stdin_i64_result)))

(fn read_stdin_i64_or_zero () -> i64
  (match (read_stdin_i64_result)
    ((ok value)
      value)
    ((err code)
      0i64)))

(fn read_stdin_i64_or ((fallback i64)) -> i64
  (match (read_stdin_i64_result)
    ((ok value)
      value)
    ((err code)
      fallback)))

(fn read_stdin_u64_result () -> (result u64 i32)
  (match (read_stdin_result)
    ((ok text)
      (parse_u64_result text))
    ((err code)
      (err u64 i32 code))))

(fn read_stdin_u64_option () -> (option u64)
  (ok_or_none_u64 (read_stdin_u64_result)))

(fn read_stdin_u64_or_zero () -> u64
  (match (read_stdin_u64_result)
    ((ok value)
      value)
    ((err code)
      0u64)))

(fn read_stdin_u64_or ((fallback u64)) -> u64
  (match (read_stdin_u64_result)
    ((ok value)
      value)
    ((err code)
      fallback)))

(fn read_stdin_f64_result () -> (result f64 i32)
  (match (read_stdin_result)
    ((ok text)
      (parse_f64_result text))
    ((err code)
      (err f64 i32 code))))

(fn read_stdin_f64_option () -> (option f64)
  (ok_or_none_f64 (read_stdin_f64_result)))

(fn read_stdin_f64_or_zero () -> f64
  (match (read_stdin_f64_result)
    ((ok value)
      value)
    ((err code)
      0.0)))

(fn read_stdin_f64_or ((fallback f64)) -> f64
  (match (read_stdin_f64_result)
    ((ok value)
      value)
    ((err code)
      fallback)))

(fn read_stdin_bool_result () -> (result bool i32)
  (match (read_stdin_result)
    ((ok text)
      (parse_bool_result text))
    ((err code)
      (err bool i32 code))))

(fn read_stdin_bool_option () -> (option bool)
  (ok_or_none_bool (read_stdin_bool_result)))

(fn read_stdin_bool_or_false () -> bool
  (match (read_stdin_bool_result)
    ((ok value)
      value)
    ((err code)
      false)))

(fn read_stdin_bool_or ((fallback bool)) -> bool
  (match (read_stdin_bool_result)
    ((ok value)
      value)
    ((err code)
      fallback)))
