program main
  enum Status
    variant Ready
    variant Blocked
  struct Pair
    field left: i32
    field right: i32
  struct CompositeRecord
    field ints: (vec i32)
    field wides: (vec i64)
    field ratios: (vec f64)
    field flags: (vec bool)
    field labels: (vec string)
    field maybe_count: (option i32)
    field maybe_wide: (option i64)
    field maybe_ratio: (option f64)
    field maybe_flag: (option bool)
    field maybe_label: (option string)
    field count_result: (result i32 i32)
    field wide_result: (result i64 i32)
    field ratio_result: (result f64 i32)
    field flag_result: (result bool i32)
    field label_result: (result string i32)
    field pair: Pair
    field status: Status
  fn make_pair(left: i32, right: i32) -> Pair
    construct Pair : Pair
      field left
        var left : i32
      field right
        var right : i32
  fn vec_i32_pair(base: i32) -> (vec i32)
    local let values : unit
      call std.vec.i32.empty : (vec i32)
    local let first : unit
      call std.vec.i32.append : (vec i32)
        var values : (vec i32)
        var base : i32
    call std.vec.i32.append : (vec i32)
      var first : (vec i32)
      binary + : i32
        var base : i32
        int 1 : i32
  fn vec_i64_pair(base: i64) -> (vec i64)
    local let values : unit
      call std.vec.i64.empty : (vec i64)
    local let first : unit
      call std.vec.i64.append : (vec i64)
        var values : (vec i64)
        var base : i64
    call std.vec.i64.append : (vec i64)
      var first : (vec i64)
      binary + : i64
        var base : i64
        i64 1 : i64
  fn vec_f64_pair(base: f64) -> (vec f64)
    local let values : unit
      call std.vec.f64.empty : (vec f64)
    local let first : unit
      call std.vec.f64.append : (vec f64)
        var values : (vec f64)
        var base : f64
    call std.vec.f64.append : (vec f64)
      var first : (vec f64)
      binary + : f64
        var base : f64
        float 1 : f64
  fn vec_bool_pair(first: bool, second: bool) -> (vec bool)
    local let values : unit
      call std.vec.bool.empty : (vec bool)
    local let left : unit
      call std.vec.bool.append : (vec bool)
        var values : (vec bool)
        var first : bool
    call std.vec.bool.append : (vec bool)
      var left : (vec bool)
      var second : bool
  fn vec_string_pair(first: string, second: string) -> (vec string)
    local let values : unit
      call std.vec.string.empty : (vec string)
    local let left : unit
      call std.vec.string.append : (vec string)
        var values : (vec string)
        var first : string
    call std.vec.string.append : (vec string)
      var left : (vec string)
      var second : string
  fn make_record() -> CompositeRecord
    construct CompositeRecord : CompositeRecord
      field ints
        call vec_i32_pair : (vec i32)
          int 10 : i32
      field wides
        call vec_i64_pair : (vec i64)
          i64 100 : i64
      field ratios
        call vec_f64_pair : (vec f64)
          float 3.5 : f64
      field flags
        call vec_bool_pair : (vec bool)
          bool false : bool
          bool true : bool
      field labels
        call vec_string_pair : (vec string)
          string "oak" : string
          string "elm" : string
      field maybe_count
        some : (option i32)
          int 7 : i32
      field maybe_wide
        some : (option i64)
          i64 7000000000 : i64
      field maybe_ratio
        some : (option f64)
          float 7.5 : f64
      field maybe_flag
        some : (option bool)
          bool true : bool
      field maybe_label
        some : (option string)
          string "alpha" : string
      field count_result
        ok : (result i32 i32)
          int 9 : i32
      field wide_result
        ok : (result i64 i32)
          i64 9000000000 : i64
      field ratio_result
        ok : (result f64 i32)
          float 9.25 : f64
      field flag_result
        ok : (result bool i32)
          bool true : bool
      field label_result
        ok : (result string i32)
          string "beta" : string
      field pair
        call make_pair : Pair
          int 20 : i32
          int 22 : i32
      field status
        enum-variant Status.Ready #0 : Status
  fn echo_record(record: CompositeRecord) -> CompositeRecord
    var record : CompositeRecord
  fn local_record() -> CompositeRecord
    local let record : unit
      call make_record : CompositeRecord
    call echo_record : CompositeRecord
      var record : CompositeRecord
  fn ints_second(record: CompositeRecord) -> i32
    call std.vec.i32.index : i32
      field-access ints : (vec i32)
        var record : CompositeRecord
      int 1 : i32
  fn wides_second(record: CompositeRecord) -> i64
    call std.vec.i64.index : i64
      field-access wides : (vec i64)
        var record : CompositeRecord
      int 1 : i32
  fn ratios_second(record: CompositeRecord) -> f64
    call std.vec.f64.index : f64
      field-access ratios : (vec f64)
        var record : CompositeRecord
      int 1 : i32
  fn flags_second(record: CompositeRecord) -> bool
    call std.vec.bool.index : bool
      field-access flags : (vec bool)
        var record : CompositeRecord
      int 1 : i32
  fn labels_second(record: CompositeRecord) -> string
    call std.vec.string.index : string
      field-access labels : (vec string)
        var record : CompositeRecord
      int 1 : i32
  fn maybe_count_value(record: CompositeRecord) -> i32
    match : i32
      subject
        field-access maybe_count : (option i32)
          var record : CompositeRecord
      arm some payload
        var payload : i32
      arm none
        int 0 : i32
  fn maybe_wide_value(record: CompositeRecord) -> i64
    match : i64
      subject
        field-access maybe_wide : (option i64)
          var record : CompositeRecord
      arm some payload
        var payload : i64
      arm none
        i64 0 : i64
  fn maybe_ratio_value(record: CompositeRecord) -> f64
    match : f64
      subject
        field-access maybe_ratio : (option f64)
          var record : CompositeRecord
      arm some payload
        var payload : f64
      arm none
        float 0 : f64
  fn maybe_flag_value(record: CompositeRecord) -> bool
    match : bool
      subject
        field-access maybe_flag : (option bool)
          var record : CompositeRecord
      arm some payload
        var payload : bool
      arm none
        bool false : bool
  fn maybe_label_value(record: CompositeRecord) -> string
    match : string
      subject
        field-access maybe_label : (option string)
          var record : CompositeRecord
      arm some payload
        var payload : string
      arm none
        string "missing" : string
  fn count_result_value(record: CompositeRecord) -> i32
    match : i32
      subject
        field-access count_result : (result i32 i32)
          var record : CompositeRecord
      arm ok payload
        var payload : i32
      arm err code
        var code : i32
  fn wide_result_value(record: CompositeRecord) -> i64
    match : i64
      subject
        field-access wide_result : (result i64 i32)
          var record : CompositeRecord
      arm ok payload
        var payload : i64
      arm err code
        i64 0 : i64
  fn ratio_result_value(record: CompositeRecord) -> f64
    match : f64
      subject
        field-access ratio_result : (result f64 i32)
          var record : CompositeRecord
      arm ok payload
        var payload : f64
      arm err code
        float 0 : f64
  fn flag_result_value(record: CompositeRecord) -> bool
    match : bool
      subject
        field-access flag_result : (result bool i32)
          var record : CompositeRecord
      arm ok payload
        var payload : bool
      arm err code
        bool false : bool
  fn label_result_value(record: CompositeRecord) -> string
    match : string
      subject
        field-access label_result : (result string i32)
          var record : CompositeRecord
      arm ok payload
        var payload : string
      arm err code
        string "missing" : string
  fn pair_total(record: CompositeRecord) -> i32
    binary + : i32
      field-access left : i32
        field-access pair : Pair
          var record : CompositeRecord
      field-access right : i32
        field-access pair : Pair
          var record : CompositeRecord
  fn is_ready(record: CompositeRecord) -> bool
    binary = : bool
      field-access status : Status
        var record : CompositeRecord
      enum-variant Status.Ready #0 : Status
  fn main() -> i32
    call pair_total : i32
      call local_record : CompositeRecord
  test "struct vec i32 field access"
    binary = : bool
      call ints_second : i32
        call make_record : CompositeRecord
      int 11 : i32
  test "struct vec i64 field access"
    binary = : bool
      call wides_second : i64
        call make_record : CompositeRecord
      i64 101 : i64
  test "struct vec f64 field access"
    binary = : bool
      call ratios_second : f64
        call make_record : CompositeRecord
      float 4.5 : f64
  test "struct vec bool field access"
    call flags_second : bool
      call make_record : CompositeRecord
  test "struct vec string field access"
    binary = : bool
      call labels_second : string
        call make_record : CompositeRecord
      string "elm" : string
  test "struct option i32 field access"
    binary = : bool
      call maybe_count_value : i32
        call make_record : CompositeRecord
      int 7 : i32
  test "struct option i64 field access"
    binary = : bool
      call maybe_wide_value : i64
        call make_record : CompositeRecord
      i64 7000000000 : i64
  test "struct option f64 field access"
    binary = : bool
      call maybe_ratio_value : f64
        call make_record : CompositeRecord
      float 7.5 : f64
  test "struct option bool field access"
    call maybe_flag_value : bool
      call make_record : CompositeRecord
  test "struct option string field access"
    binary = : bool
      call maybe_label_value : string
        call make_record : CompositeRecord
      string "alpha" : string
  test "struct result i32 field access"
    binary = : bool
      call count_result_value : i32
        call make_record : CompositeRecord
      int 9 : i32
  test "struct result i64 field access"
    binary = : bool
      call wide_result_value : i64
        call make_record : CompositeRecord
      i64 9000000000 : i64
  test "struct result f64 field access"
    binary = : bool
      call ratio_result_value : f64
        call make_record : CompositeRecord
      float 9.25 : f64
  test "struct result bool field access"
    call flag_result_value : bool
      call make_record : CompositeRecord
  test "struct result string field access"
    binary = : bool
      call label_result_value : string
        call make_record : CompositeRecord
      string "beta" : string
  test "nested struct field access"
    binary = : bool
      call pair_total : i32
        call make_record : CompositeRecord
      int 42 : i32
  test "nested struct local param return call flow"
    binary = : bool
      call pair_total : i32
        call local_record : CompositeRecord
      int 42 : i32
  test "direct enum struct field equality"
    call is_ready : bool
      call make_record : CompositeRecord
