program main
  fn maybe_value(value: i32) -> (option i32)
    some i32
      var value
  fn maybe_empty() -> (option i32)
    none i32
  fn maybe_wide_value(value: i64) -> (option i64)
    some i64
      var value
  fn maybe_wide_empty() -> (option i64)
    none i64
  fn maybe_float_value(value: f64) -> (option f64)
    some f64
      var value
  fn maybe_float_empty() -> (option f64)
    none f64
  fn maybe_flag_value(value: bool) -> (option bool)
    some bool
      var value
  fn maybe_flag_empty() -> (option bool)
    none bool
  fn maybe_string_value(value: string) -> (option string)
    some string
      var value
  fn maybe_string_empty() -> (option string)
    none string
  fn result_ok_value(value: i32) -> (result i32 i32)
    ok i32 i32
      var value
  fn result_err_value(code: i32) -> (result i32 i32)
    err i32 i32
      var code
  fn option_direct_payload() -> i32
    unwrap_some
      some i32
        int 42
  fn option_param_payload(value: (option i32)) -> i32
    unwrap_some
      var value
  fn option_local_payload() -> i32
    local let value: (option i32)
      call maybe_value
        int 21
    unwrap_some
      var value
  fn option_call_payload() -> i32
    unwrap_some
      call maybe_value
        int 22
  fn option_guarded_payload(value: (option i32)) -> i32
    if
      is_some
        var value
      unwrap_some
        var value
      int 0
  fn option_wide_direct_payload() -> i64
    unwrap_some
      some i64
        i64 2147483648
  fn option_wide_param_payload(value: (option i64)) -> i64
    unwrap_some
      var value
  fn option_wide_local_payload() -> i64
    local let value: (option i64)
      call maybe_wide_value
        i64 21
    unwrap_some
      var value
  fn option_wide_call_payload() -> i64
    unwrap_some
      call maybe_wide_value
        i64 22
  fn option_wide_guarded_payload(value: (option i64)) -> i64
    if
      is_some
        var value
      unwrap_some
        var value
      i64 0
  fn option_float_direct_payload() -> f64
    unwrap_some
      some f64
        float 42.5
  fn option_float_param_payload(value: (option f64)) -> f64
    unwrap_some
      var value
  fn option_float_local_payload() -> f64
    local let value: (option f64)
      call maybe_float_value
        float 21.5
    unwrap_some
      var value
  fn option_float_call_payload() -> f64
    unwrap_some
      call maybe_float_value
        float 22.5
  fn option_float_guarded_payload(value: (option f64)) -> f64
    if
      is_some
        var value
      unwrap_some
        var value
      float 0
  fn option_flag_direct_payload() -> bool
    unwrap_some
      some bool
        bool true
  fn option_flag_param_payload(value: (option bool)) -> bool
    unwrap_some
      var value
  fn option_flag_local_payload() -> bool
    local let value: (option bool)
      call maybe_flag_value
        bool true
    unwrap_some
      var value
  fn option_flag_call_payload() -> bool
    unwrap_some
      call maybe_flag_value
        bool true
  fn option_flag_guarded_payload(value: (option bool)) -> bool
    if
      is_some
        var value
      unwrap_some
        var value
      bool false
  fn option_string_direct_payload() -> string
    unwrap_some
      some string
        string "slovo"
  fn option_string_param_payload(value: (option string)) -> string
    unwrap_some
      var value
  fn option_string_local_payload() -> string
    local let value: (option string)
      call maybe_string_value
        string "oak"
    unwrap_some
      var value
  fn option_string_call_payload() -> string
    unwrap_some
      call maybe_string_value
        string "pine"
  fn option_string_guarded_payload(value: (option string)) -> string
    if
      is_some
        var value
      unwrap_some
        var value
      string "fallback"
  fn result_ok_direct_payload() -> i32
    unwrap_ok
      ok i32 i32
        int 30
  fn result_err_direct_payload() -> i32
    unwrap_err
      err i32 i32
        int 7
  fn result_ok_param_payload(value: (result i32 i32)) -> i32
    unwrap_ok
      var value
  fn result_err_param_payload(value: (result i32 i32)) -> i32
    unwrap_err
      var value
  fn result_ok_local_payload() -> i32
    local let value: (result i32 i32)
      call result_ok_value
        int 31
    unwrap_ok
      var value
  fn result_err_call_payload() -> i32
    unwrap_err
      call result_err_value
        int 9
  fn main() -> i32
    int 0
  test "unwrap some direct constructor"
    binary =
      call option_direct_payload
      int 42
  test "unwrap some local"
    binary =
      call option_local_payload
      int 21
  test "unwrap some call"
    binary =
      call option_call_payload
      int 22
  test "unwrap some parameter"
    binary =
      call option_param_payload
        call maybe_value
          int 23
      int 23
  test "guarded unwrap some present"
    binary =
      call option_guarded_payload
        call maybe_value
          int 24
      int 24
  test "guarded unwrap some absent"
    binary =
      call option_guarded_payload
        call maybe_empty
      int 0
  test "unwrap some i64 direct constructor"
    binary =
      call option_wide_direct_payload
      i64 2147483648
  test "unwrap some i64 local"
    binary =
      call option_wide_local_payload
      i64 21
  test "unwrap some i64 call"
    binary =
      call option_wide_call_payload
      i64 22
  test "unwrap some i64 parameter"
    binary =
      call option_wide_param_payload
        call maybe_wide_value
          i64 23
      i64 23
  test "guarded unwrap some i64 present"
    binary =
      call option_wide_guarded_payload
        call maybe_wide_value
          i64 24
      i64 24
  test "guarded unwrap some i64 absent"
    binary =
      call option_wide_guarded_payload
        call maybe_wide_empty
      i64 0
  test "unwrap some f64 direct constructor"
    binary =
      call option_float_direct_payload
      float 42.5
  test "unwrap some f64 local"
    binary =
      call option_float_local_payload
      float 21.5
  test "unwrap some f64 call"
    binary =
      call option_float_call_payload
      float 22.5
  test "unwrap some f64 parameter"
    binary =
      call option_float_param_payload
        call maybe_float_value
          float 23.5
      float 23.5
  test "guarded unwrap some f64 present"
    binary =
      call option_float_guarded_payload
        call maybe_float_value
          float 24.5
      float 24.5
  test "guarded unwrap some f64 absent"
    binary =
      call option_float_guarded_payload
        call maybe_float_empty
      float 0
  test "unwrap some bool direct constructor"
    call option_flag_direct_payload
  test "unwrap some bool local"
    call option_flag_local_payload
  test "unwrap some bool call"
    call option_flag_call_payload
  test "unwrap some bool parameter"
    call option_flag_param_payload
      call maybe_flag_value
        bool true
  test "guarded unwrap some bool present"
    call option_flag_guarded_payload
      call maybe_flag_value
        bool true
  test "guarded unwrap some bool absent"
    if
      call option_flag_guarded_payload
        call maybe_flag_empty
      bool false
      bool true
  test "unwrap some string direct constructor"
    binary =
      call option_string_direct_payload
      string "slovo"
  test "unwrap some string local"
    binary =
      call option_string_local_payload
      string "oak"
  test "unwrap some string call"
    binary =
      call option_string_call_payload
      string "pine"
  test "unwrap some string parameter"
    binary =
      call option_string_param_payload
        call maybe_string_value
          string "birch"
      string "birch"
  test "guarded unwrap some string present"
    binary =
      call option_string_guarded_payload
        call maybe_string_value
          string "cedar"
      string "cedar"
  test "guarded unwrap some string absent"
    binary =
      call option_string_guarded_payload
        call maybe_string_empty
      string "fallback"
  test "unwrap ok direct constructor"
    binary =
      call result_ok_direct_payload
      int 30
  test "unwrap err direct constructor"
    binary =
      call result_err_direct_payload
      int 7
  test "unwrap ok parameter"
    binary =
      call result_ok_param_payload
        call result_ok_value
          int 32
      int 32
  test "unwrap err parameter"
    binary =
      call result_err_param_payload
        call result_err_value
          int 8
      int 8
  test "unwrap ok local"
    binary =
      call result_ok_local_payload
      int 31
  test "unwrap err call"
    binary =
      call result_err_call_payload
      int 9
