// File: /workspace/github_c_makefile_star2_O0/sisshiki1969[P]monocc/src/parse.c
// Function: parse_program
void parse_program() {
  ext_declarations = vec_new();
  while (!at_eof()) {
    locals = NULL;
    scope = NULL;
    switch_level = 0;
    Node *decl;
    if (consume_if(TK_MACRO)) continue;
    if (consume_if(TK_TYPEDEF)) {
      MemberInfo *ty_ident = parse_decl(true);
      if (!ty_ident->ident) error_at_token(token, "Expected identifier.");
      new_typedef(ty_ident->ident, ty_ident->type);
      expect(TK_SEMI);
      continue;
    }
    bool is_extern = false;
    if (consume_if(TK_EXTERN)) {
      is_extern = true;
    }
    MemberInfo *ty_ident = parse_decl(false);
    Token *ident = ty_ident->ident;
    Type *type = ty_ident->type;
    if (!ident) {
      if (is_struct(type) || is_enum(type)) {
        // struct XXX { ... };
        expect(TK_SEMI);
        continue;
      } else
        // error for "int;"
        error_at_token(token, "Expected an identifier.");
    }

    if (!is_func(type)) {
      // gloval var declaration
      Token *op_token = token;
      Global *gvar = find_gvar(ident);
      if (gvar) {
        if (gvar->body)
          error_at_token(ident, "Reinitialization of global variable.");
        if (!is_identical_type(gvar->type, type))
          error_at_token(ident, "Conflicting types.");
      } else
        gvar = new_gvar(ident, type);
      gvar->is_extern = is_extern;
      if (consume_if(TK_ASSIGN)) {
        if (is_extern)
          error_at_token(op_token,
                         "Can not initialize variables with 'extern'.");
        gvar->body = parse_initializer(gvar->type);
      }
      if (is_array_of_char(gvar->type)) {
        if (!gvar->body) {
          // char s[];
          if (gvar->type->array_size == 0)
            error_at_token(gvar->token, "Incomplete type is not allowed.");
        } else if (gvar->body->kind == ND_STR) {
          // char s[] = "...";
          if (gvar->type->array_size == 0)
            gvar->type->array_size = gvar->body->offset;
        } else
          error_at_node(gvar->body, "Parse error: Unsupported initializer.");
      }
      expect(TK_SEMI);
      continue;
    } else if (consume_if(TK_SEMI)) {
      // function declaration
      Function *func = new_func(ident, type, NULL);
      continue;
    } else if (peek(TK_OP_BRACE)) {
      // function definition

      decl = parse_func_definition(ty_ident);
      if (verbose) {
        fprintf(output, "// ");
        print_node(decl);
        fprintf(output, "\n");
        print_locals();
      }
      vec_push(ext_declarations, decl);
    } else
      error_at_token(token, "Unexpected token.");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb $0x0, %al
callq 0x3fb0
movq %rax, %rcx
leaq 0xa8ef(%rip), %rax      # 0x15228
movq %rcx, (%rax)
callq 0x7810
xorb $-0x1, %al
testb $0x1, %al
jne 0xa94c
jmp 0xacb0
leaq 0xa8e5(%rip), %rax      # 0x15238
movq $0x0, (%rax)
leaq 0xa8df(%rip), %rax      # 0x15240
movq $0x0, (%rax)
movl $0x0, 0xa8f6(%rip)      # 0x15268
movl $0x42, %edi
callq 0x7860
testb $0x1, %al
jne 0xa982
jmp 0xa984
jmp 0xa93c
movl $0x40, %edi
callq 0x7860
testb $0x1, %al
jne 0xa994
jmp 0xa9e9
movl $0x1, %edi
callq 0x8b40
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xa9c5
leaq 0xa864(%rip), %rax      # 0x15218
movq (%rax), %rdi
leaq 0x5a27(%rip), %rsi      # 0x103e5
movb $0x0, %al
callq 0x5d20
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x7f60
movl $0x1c, %edi
callq 0x7980
jmp 0xa93c
movb $0x0, -0x11(%rbp)
movl $0x3f, %edi
callq 0x7860
testb $0x1, %al
jne 0xa9fd
jmp 0xaa01
movb $0x1, -0x11(%rbp)
xorl %edi, %edi
callq 0x8b40
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xaa70
movq -0x30(%rbp), %rdi
callq 0xd3b0
testb $0x1, %al
jne 0xaa47
movq -0x30(%rbp), %rdi
callq 0xd3d0
testb $0x1, %al
jne 0xaa47
jmp 0xaa56
movl $0x1c, %edi
callq 0x7980
jmp 0xa93c
leaq 0xa7bb(%rip), %rax      # 0x15218
movq (%rax), %rdi
leaq 0x5bf6(%rip), %rsi      # 0x1065d
movb $0x0, %al
callq 0x5d20
jmp 0xaa70
movq -0x30(%rbp), %rdi
callq 0xd390
testb $0x1, %al
jne 0xabe7
leaq 0xa790(%rip), %rax      # 0x15218
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x7cf0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xaae9
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xaac0
movq -0x28(%rbp), %rdi
leaq 0x5d24(%rip), %rsi      # 0x107dd
movb $0x0, %al
callq 0x5d20
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0xd920
testb $0x1, %al
jne 0xaae7
movq -0x28(%rbp), %rdi
leaq 0x5d22(%rip), %rsi      # 0x10802
movb $0x0, %al
callq 0x5d20
jmp 0xaafa
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x7c80
movq %rax, -0x40(%rbp)
movb -0x11(%rbp), %cl
movq -0x40(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x20(%rax)
movl $0xd, %edi
callq 0x7860
testb $0x1, %al
jne 0xab17
jmp 0xab47
testb $0x1, -0x11(%rbp)
je 0xab2f
movq -0x38(%rbp), %rdi
leaq 0x5ced(%rip), %rsi      # 0x10815
movb $0x0, %al
callq 0x5d20
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x9af0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xd450
testb $0x1, %al
jne 0xab5a
jmp 0xabd8
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0xab8b
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x0, 0x10(%rax)
jne 0xab89
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x4ea0(%rip), %rsi      # 0xfa22
movb $0x0, %al
callq 0x5d20
jmp 0xabd6
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x2, (%rax)
jne 0xabbe
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x0, 0x10(%rax)
jne 0xabbc
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x38(%rax), %ecx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl %ecx, 0x10(%rax)
jmp 0xabd4
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x5c74(%rip), %rsi      # 0x10841
movb $0x0, %al
callq 0x6040
jmp 0xabd6
jmp 0xabd8
movl $0x1c, %edi
callq 0x7980
jmp 0xa93c
movl $0x1c, %edi
callq 0x7860
testb $0x1, %al
jne 0xabf7
jmp 0xac11
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x7d60
movq %rax, -0x48(%rbp)
jmp 0xa93c
movl $0x1f, %edi
callq 0x77d0
testb $0x1, %al
jne 0xac21
jmp 0xac8f
movq -0x20(%rbp), %rdi
callq 0xa650
movq %rax, -0x8(%rbp)
leaq 0xa5bb(%rip), %rax      # 0x151f0
testb $0x1, (%rax)
je 0xac7a
leaq 0xa5cf(%rip), %rax      # 0x15210
movq (%rax), %rdi
leaq 0x5060(%rip), %rsi      # 0xfcab
movb $0x0, %al
callq 0x10f0
movq -0x8(%rbp), %rdi
callq 0x4300
leaq 0xa5ae(%rip), %rax      # 0x15210
movq (%rax), %rdi
leaq 0x5465(%rip), %rsi      # 0x100d1
movb $0x0, %al
callq 0x10f0
movb $0x0, %al
callq 0x5390
leaq 0xa5a7(%rip), %rax      # 0x15228
movq (%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x4020
jmp 0xaca7
leaq 0xa582(%rip), %rax      # 0x15218
movq (%rax), %rdi
leaq 0x582a(%rip), %rsi      # 0x104ca
movb $0x0, %al
callq 0x5d20
jmp 0xaca9
jmp 0xacab
jmp 0xa93c
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)