compilation_unit {
  package_statement {
    package_name: "ExplorerTest"
  }
  is_api: true
  declarations {
    variable {
      binding {
        name: "current"
        type {
          expression_pattern {
            expression {
              int_type_literal {
              }
            }
          }
        }
      }
      initializer {
        int_literal {
          value: 0
        }
      }
    }
  }
  declarations {
    function {
      name: "CountUpTo"
      param_pattern {
        fields {
          binding_pattern {
            name: "x"
            type {
              expression_pattern {
                expression {
                  int_type_literal {
                  }
                }
              }
            }
          }
        }
      }
      return_term {
        kind: Expression
        type {
          int_type_literal {
          }
        }
      }
      body {
        statements {
          if_statement {
            condition {
              primitive_operator {
                op: Eq
                arguments {
                  identifier {
                    name: "x"
                  }
                }
                arguments {
                  int_literal {
                    value: 0
                  }
                }
              }
            }
            then_block {
              statements {
                assign {
                  lhs {
                    identifier {
                      name: "current"
                    }
                  }
                  rhs {
                    int_literal {
                      value: 0
                    }
                  }
                }
              }
              statements {
                await_statement {
                }
              }
              statements {
                return_statement {
                  expression {
                    int_literal {
                      value: 0
                    }
                  }
                }
              }
            }
            else_block {
              statements {
                assign {
                  lhs {
                    identifier {
                      name: "current"
                    }
                  }
                  rhs {
                    primitive_operator {
                      op: Add
                      arguments {
                        int_literal {
                          value: 1
                        }
                      }
                      arguments {
                        call {
                          function {
                            identifier {
                              name: "CountUpTo"
                            }
                          }
                          argument {
                            tuple_literal {
                              fields {
                                primitive_operator {
                                  op: Sub
                                  arguments {
                                    identifier {
                                      name: "x"
                                    }
                                  }
                                  arguments {
                                    int_literal {
                                      value: 1
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
              statements {
                await_statement {
                }
              }
              statements {
                return_statement {
                  expression {
                    identifier {
                      name: "current"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  declarations {
    function {
      name: "Main"
      param_pattern {
      }
      return_term {
        kind: Expression
        type {
          int_type_literal {
          }
        }
      }
      body {
        statements {
          continuation {
            name: "k"
            body {
              statements {
                expression_statement {
                  expression {
                    call {
                      function {
                        identifier {
                          name: "CountUpTo"
                        }
                      }
                      argument {
                        tuple_literal {
                          fields {
                            int_literal {
                              value: 5
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        statements {
          variable_definition {
            pattern {
              binding_pattern {
                name: "sum"
                type {
                  expression_pattern {
                    expression {
                      int_type_literal {
                      }
                    }
                  }
                }
              }
            }
            init {
              int_literal {
                value: 0
              }
            }
          }
        }
        statements {
          variable_definition {
            pattern {
              binding_pattern {
                name: "count"
                type {
                  expression_pattern {
                    expression {
                      int_type_literal {
                      }
                    }
                  }
                }
              }
            }
            init {
              int_literal {
                value: 5
              }
            }
          }
        }
        statements {
          while_statement {
            condition {
              primitive_operator {
                op: Not
                arguments {
                  primitive_operator {
                    op: Eq
                    arguments {
                      identifier {
                        name: "count"
                      }
                    }
                    arguments {
                      int_literal {
                        value: 0
                      }
                    }
                  }
                }
              }
            }
            body {
              statements {
                run {
                  argument {
                    identifier {
                      name: "k"
                    }
                  }
                }
              }
              statements {
                assign {
                  lhs {
                    identifier {
                      name: "sum"
                    }
                  }
                  rhs {
                    primitive_operator {
                      op: Add
                      arguments {
                        identifier {
                          name: "sum"
                        }
                      }
                      arguments {
                        identifier {
                          name: "current"
                        }
                      }
                    }
                  }
                }
              }
              statements {
                assign {
                  lhs {
                    identifier {
                      name: "count"
                    }
                  }
                  rhs {
                    primitive_operator {
                      op: Sub
                      arguments {
                        identifier {
                          name: "count"
                        }
                      }
                      arguments {
                        int_literal {
                          value: 1
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        statements {
          return_statement {
            expression {
              identifier {
                name: "sum"
              }
            }
          }
        }
      }
    }
  }
}
