// File: /workspace/github_c_makefile_star2_O0/takoeight0821[P]hoc_nyan/src/parse.c
// Function: statement
static Node *statement() {
  Token *tok;
  if (is_typename(peek(0))) {
    Node *node = declaration();
    if (!match(";")) {
      parse_error("local variable declaration: ;", peek(0));
    }
    return node;
  } else if ((tok = match("return"))) {
    Node *node = new_node(NRETURN, tok);
    if (!eq_reserved(peek(0), ";")) {
      node->expr = expr();
    }
    if (!match(";")) {
      parse_error("return: ;", peek(0));
    }
    return node;
  } else if ((tok = match("break"))) {
    Node *node = new_node(NBREAK, tok);
    if (!match(";")) {
      parse_error("break: ;", peek(0));
    }
    return node;
  } else if ((tok = match("if"))) {
    if (!match("(")) {
      parse_error("(", peek(0));
    }
    Node *cond = expr();
    if (!match(")")) {
      parse_error(")", peek(0));
    }

    Node *then = statement();

    if (match("else")) {
      Node *els = statement();
      Node *node = new_node(NIFELSE, tok);
      node->cond = cond;
      node->then = then;
      node->els = els;
      return node;
    } else {
      Node *node = new_node(NIF, tok);
      node->cond = cond;
      node->then = then;
      return node;
    }
  } else if ((tok = match("while"))) {
    Node *node = new_node(NWHILE, tok);

    if (!match("(")) {
      parse_error("(", peek(0));
    }
    node->cond = expr();
    if (!match(")")) {
      parse_error(")", peek(0));
    }

    node->body = statement();

    return node;
  } else if ((tok = match("for"))) {
    Node *node = new_node(NFOR, tok);

    LVar *tmp = local_env;
    if (!match("(")) {
      parse_error("(", peek(0));
    }

    if (!(eq_reserved(peek(0), ";"))) {
      if (is_typename(peek(0))) {
        node->init = declaration();
      } else {
        node->init = expr();
      }
    }
    if (!match(";")) {
      parse_error("for init: ;", peek(0));
    }

    if (!(eq_reserved(peek(0), ";"))) {
      node->cond = expr();
    } else {
      node->cond = new_int_node(peek(0), 1);
    }
    if (!match(";")) {
      parse_error("for cond: ;", peek(0));
    }

    if (!(eq_reserved(peek(0), ")"))) {
      node->step = expr();
    }
    if (!match(")")) {
      parse_error(")", peek(0));
    }

    node->body = statement();

    local_env = tmp;

    return node;
  } else if ((tok = match("switch"))) {
    Node *node = new_node(NSWITCH, tok);

    if (!match("(")) {
      parse_error("(", tok);
    }
    node->expr = expr();
    if (!match(")")) {
      parse_error(")", tok);
    }

    node->body = statement();

    return node;
  } else if ((tok = match("case"))) {
    Node *node = new_node(NCASE, tok);
    node->expr = logical_or(); // TODO: support conditional expression
    if (!match(":")) {
      parse_error(":", tok);
    }
    node->body = statement();
    return node;
  } else if ((tok = match("default"))) {
    Node *node = new_node(NDEFAULT, tok);
    if (!match(":")) {
      parse_error(":", tok);
    }
    node->body = statement();
    return node;
  } else if ((tok = match("{"))) {
    Node *node = new_node(NBLOCK, tok);
    node->stmts = new_vec();

    LVar *tmp = local_env; // start scope

    while (!eq_reserved(peek(0), "}")) {
      vec_push(node->stmts, statement());
    }

    if (!match("}")) {
      parse_error("}", peek(0));
    }

    local_env = tmp; // end scope

    return node;
  } else {
    return expr_stmt();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
callq 0xbb60
cmpl $0x0, %eax
je 0xc921
callq 0xd030
movq %rax, -0x18(%rbp)
leaq 0x6a68(%rip), %rdi      # 0x13359
callq 0xa330
cmpq $0x0, %rax
jne 0xc914
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x69f9(%rip), %rdi      # 0x13308
callq 0xaa00
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x6e75(%rip), %rdi      # 0x1379d
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xc9ac
movq -0x10(%rbp), %rsi
movl $0x1d, %edi
callq 0x9d10
movq %rax, -0x20(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
leaq 0x69fd(%rip), %rsi      # 0x13359
callq 0xfe80
testb $0x1, %al
jne 0xc975
callq 0xc7b0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
leaq 0x69dd(%rip), %rdi      # 0x13359
callq 0xa330
cmpq $0x0, %rax
jne 0xc99f
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x698c(%rip), %rdi      # 0x13326
callq 0xaa00
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x5e8d(%rip), %rdi      # 0x12840
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xca0b
movq -0x10(%rbp), %rsi
movl $0x27, %edi
callq 0x9d10
movq %rax, -0x28(%rbp)
leaq 0x697e(%rip), %rdi      # 0x13359
callq 0xa330
cmpq $0x0, %rax
jne 0xc9fe
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6937(%rip), %rdi      # 0x13330
callq 0xaa00
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x5624(%rip), %rdi      # 0x12036
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xcb20
leaq 0x6fa2(%rip), %rdi      # 0x139ce
callq 0xa330
cmpq $0x0, %rax
jne 0xca4f
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6f84(%rip), %rdi      # 0x139ce
callq 0xaa00
callq 0xc7b0
movq %rax, -0x30(%rbp)
leaq 0x68a3(%rip), %rdi      # 0x13302
callq 0xa330
cmpq $0x0, %rax
jne 0xca82
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6885(%rip), %rdi      # 0x13302
callq 0xaa00
callq 0xc8c0
movq %rax, -0x38(%rbp)
leaq 0x5d2b(%rip), %rdi      # 0x127bd
callq 0xa330
cmpq $0x0, %rax
je 0xcae9
callq 0xc8c0
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rsi
movl $0x1f, %edi
callq 0x9d10
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
movq -0x10(%rbp), %rsi
movl $0x1e, %edi
callq 0x9d10
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x38(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x6812(%rip), %rdi      # 0x13339
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xcbd0
movq -0x10(%rbp), %rsi
movl $0x20, %edi
callq 0x9d10
movq %rax, -0x58(%rbp)
leaq 0x6e7b(%rip), %rdi      # 0x139ce
callq 0xa330
cmpq $0x0, %rax
jne 0xcb76
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6e5d(%rip), %rdi      # 0x139ce
callq 0xaa00
callq 0xc7b0
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x58(%rax)
leaq 0x6775(%rip), %rdi      # 0x13302
callq 0xa330
cmpq $0x0, %rax
jne 0xcbb0
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6757(%rip), %rdi      # 0x13302
callq 0xaa00
callq 0xc8c0
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x6768(%rip), %rdi      # 0x1333f
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xcdab
movq -0x10(%rbp), %rsi
movl $0x21, %edi
callq 0x9d10
movq %rax, -0x60(%rbp)
movq 0xaaa5(%rip), %rax      # 0x176a8
movq %rax, -0x68(%rbp)
leaq 0x6dc0(%rip), %rdi      # 0x139ce
callq 0xa330
cmpq $0x0, %rax
jne 0xcc31
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6da2(%rip), %rdi      # 0x139ce
callq 0xaa00
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
leaq 0x6715(%rip), %rsi      # 0x13359
callq 0xfe80
testb $0x1, %al
jne 0xcc87
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
callq 0xbb60
cmpl $0x0, %eax
je 0xcc75
callq 0xd030
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x70(%rax)
jmp 0xcc85
callq 0xc7b0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x70(%rax)
jmp 0xcc87
leaq 0x66cb(%rip), %rdi      # 0x13359
callq 0xa330
cmpq $0x0, %rax
jne 0xccb1
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6697(%rip), %rdi      # 0x13343
callq 0xaa00
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
leaq 0x6695(%rip), %rsi      # 0x13359
callq 0xfe80
testb $0x1, %al
jne 0xccdf
callq 0xc7b0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0xcd00
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
movl $0x1, %esi
callq 0xb170
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x58(%rax)
leaq 0x6652(%rip), %rdi      # 0x13359
callq 0xa330
cmpq $0x0, %rax
jne 0xcd2a
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x662a(%rip), %rdi      # 0x1334f
callq 0xaa00
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
leaq 0x65c5(%rip), %rsi      # 0x13302
callq 0xfe80
testb $0x1, %al
jne 0xcd56
callq 0xc7b0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x78(%rax)
leaq 0x65a5(%rip), %rdi      # 0x13302
callq 0xa330
cmpq $0x0, %rax
jne 0xcd80
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x6587(%rip), %rdi      # 0x13302
callq 0xaa00
callq 0xc8c0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x68(%rbp), %rax
movq %rax, 0xa90a(%rip)      # 0x176a8
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x65a9(%rip), %rdi      # 0x1335b
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xce4b
movq -0x10(%rbp), %rsi
movl $0x24, %edi
callq 0x9d10
movq %rax, -0x70(%rbp)
leaq 0x6bf0(%rip), %rdi      # 0x139ce
callq 0xa330
cmpq $0x0, %rax
jne 0xcdf9
movq -0x10(%rbp), %rsi
leaq 0x6bda(%rip), %rdi      # 0x139ce
callq 0xaa00
callq 0xc7b0
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x38(%rax)
leaq 0x64f2(%rip), %rdi      # 0x13302
callq 0xa330
cmpq $0x0, %rax
jne 0xce2b
movq -0x10(%rbp), %rsi
leaq 0x64dc(%rip), %rdi      # 0x13302
callq 0xaa00
callq 0xc8c0
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x70(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x6510(%rip), %rdi      # 0x13362
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xcec5
movq -0x10(%rbp), %rsi
movl $0x25, %edi
callq 0x9d10
movq %rax, -0x78(%rbp)
callq 0xb420
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x38(%rax)
leaq 0x6614(%rip), %rdi      # 0x1349e
callq 0xa330
cmpq $0x0, %rax
jne 0xcea5
movq -0x10(%rbp), %rsi
leaq 0x65fe(%rip), %rdi      # 0x1349e
callq 0xaa00
callq 0xc8c0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x78(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x649b(%rip), %rdi      # 0x13367
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xcf2f
movq -0x10(%rbp), %rsi
movl $0x26, %edi
callq 0x9d10
movq %rax, -0x80(%rbp)
leaq 0x65aa(%rip), %rdi      # 0x1349e
callq 0xa330
cmpq $0x0, %rax
jne 0xcf0f
movq -0x10(%rbp), %rsi
leaq 0x6594(%rip), %rdi      # 0x1349e
callq 0xaa00
callq 0xc8c0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x80(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
leaq 0x6325(%rip), %rdi      # 0x1325b
callq 0xa330
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0xd00e
movq -0x10(%rbp), %rsi
movl $0x22, %edi
callq 0x9d10
movq %rax, -0x88(%rbp)
movb $0x0, %al
callq 0x2280
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x30(%rax)
movq 0xa72e(%rip), %rax      # 0x176a8
movq %rax, -0x90(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rdi
leaq 0x6205(%rip), %rsi      # 0x13199
callq 0xfe80
xorb $-0x1, %al
testb $0x1, %al
jne 0xcfa1
jmp 0xcfc9
movq -0x88(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x98(%rbp)
callq 0xc8c0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x22e0
jmp 0xcf81
leaq 0x61c9(%rip), %rdi      # 0x13199
callq 0xa330
cmpq $0x0, %rax
jne 0xcff3
xorl %eax, %eax
movl %eax, %edi
callq 0xa990
movq %rax, %rsi
leaq 0x61ab(%rip), %rdi      # 0x13199
callq 0xaa00
movq -0x90(%rbp), %rax
movq %rax, 0xa6a7(%rip)      # 0x176a8
movq -0x88(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd017
callq 0xd2c0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)