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 option_score(value: (option i32)) -> i32
    if
      is_some
        var value
      int 1
      int 0
  fn option_empty_score(value: (option i32)) -> i32
    if
      is_none
        var value
      int 1
      int 0
  fn option_wide_score(value: (option i64)) -> i32
    if
      is_some
        var value
      int 1
      int 0
  fn option_wide_empty_score(value: (option i64)) -> i32
    if
      is_none
        var value
      int 1
      int 0
  fn option_float_score(value: (option f64)) -> i32
    if
      is_some
        var value
      int 1
      int 0
  fn option_float_empty_score(value: (option f64)) -> i32
    if
      is_none
        var value
      int 1
      int 0
  fn option_flag_score(value: (option bool)) -> i32
    if
      is_some
        var value
      int 1
      int 0
  fn option_flag_empty_score(value: (option bool)) -> i32
    if
      is_none
        var value
      int 1
      int 0
  fn option_string_score(value: (option string)) -> i32
    if
      is_some
        var value
      int 1
      int 0
  fn option_string_empty_score(value: (option string)) -> i32
    if
      is_none
        var value
      int 1
      int 0
  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 result_success_score(value: (result i32 i32)) -> i32
    if
      is_ok
        var value
      int 1
      int 0
  fn result_failure_score(value: (result i32 i32)) -> i32
    if
      is_err
        var value
      int 1
      int 0
  fn option_local_flow() -> i32
    local let value: (option i32)
      call maybe_value
        int 42
    call option_score
      var value
  fn option_wide_local_flow() -> i32
    local let value: (option i64)
      call maybe_wide_value
        i64 2147483648
    call option_wide_score
      var value
  fn option_float_local_flow() -> i32
    local let value: (option f64)
      call maybe_float_value
        float 42.5
    call option_float_score
      var value
  fn option_flag_local_flow() -> i32
    local let value: (option bool)
      call maybe_flag_value
        bool true
    call option_flag_score
      var value
  fn option_string_local_flow() -> i32
    local let value: (option string)
      call maybe_string_value
        string "slovo"
    call option_string_score
      var value
  fn result_local_flow() -> i32
    local let value: (result i32 i32)
      call result_err_value
        int 7
    call result_failure_score
      var value
  fn main() -> i32
    int 0
  test "option local value flow"
    binary =
      call option_local_flow
      int 1
  test "option call observation"
    binary =
      call option_empty_score
        call maybe_empty
      int 1
  test "option i64 local value flow"
    binary =
      call option_wide_local_flow
      int 1
  test "option i64 call observation"
    binary =
      call option_wide_empty_score
        call maybe_wide_empty
      int 1
  test "option f64 local value flow"
    binary =
      call option_float_local_flow
      int 1
  test "option f64 call observation"
    binary =
      call option_float_empty_score
        call maybe_float_empty
      int 1
  test "option bool local value flow"
    binary =
      call option_flag_local_flow
      int 1
  test "option bool call observation"
    binary =
      call option_flag_empty_score
        call maybe_flag_empty
      int 1
  test "option string local value flow"
    binary =
      call option_string_local_flow
      int 1
  test "option string call observation"
    binary =
      call option_string_empty_score
        call maybe_string_empty
      int 1
  test "result call observation"
    binary =
      call result_success_score
        call result_ok_value
          int 42
      int 1
  test "result local value flow"
    binary =
      call result_local_flow
      int 1
