// File: /workspace/github_c_makefile_star2_O0/pocari[P]compilerbook-9cc/parser.c
// Function: unary
static Node *unary() {
  Token *tk;
  if (consume("+")) {
    return cast();
  } else if (tk = consume("-")) {
    return new_bin_node(ND_SUB, new_num_node(0, tk), cast(), tk);
  } else if (tk = consume("&")) {
    return new_unary_node(ND_ADDR, cast(), tk);
  } else if (tk = consume("*")) {
    return new_unary_node(ND_DEREF, cast(), tk);
  } else if (tk = consume("++")) {
    return new_unary_node(ND_PRE_INC, cast(), tk);
  } else if (tk = consume("--")) {
    return new_unary_node(ND_PRE_DEC, cast(), tk);
  } else if (tk = consume("!")) {
    return new_unary_node(ND_NOT, cast(), tk);
  } else if (tk = consume("~")) {
    return new_unary_node(ND_BIT_NOT, cast(), tk);
  } else if (tk = consume_kind(TK_ALIGNOF)) {
    expect("(");
    Type *ty = type_name();
    expect(")");
    return new_num_node(ty->align, tk);
  } else if (consume_kind(TK_SIZEOF)) {
    Token *tmp = token;
    if (consume("(")) {
      if (is_type(token)) {
        Token *tk = token;
        Type *ty = type_name();

        // fprintf(stderr, "ty->kind:%d\n", ty->kind);
        // fprintf(stderr, "ty->isincomplete:%d\n", ty->is_incomplete);
        if (ty->is_incomplete) {
          error_at(tk->str, "incomplete element type(sizeof1)");
        }

        expect(")");
        return new_num_node(ty->size, tk);
      }
      // 型名じゃなかったらまた再度 "(" からパースやり直すためにconsume("(")の直前まで戻す
      token = tmp;
    }

    Token *tk = token;
    Node *n = cast();
    add_type(n);
    if (n->ty->is_incomplete) {
      error_at(tk->str, "incomplete element type(sizeof2)");
    }
    return new_num_node(node_type_size(n), tk);
  }
  return postfix();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
leaq 0x7c29(%rip), %rdi      # 0x10888
callq 0x6780
cmpq $0x0, %rax
je 0x8c78
callq 0x8960
movq %rax, -0x8(%rbp)
jmp 0x8f81
leaq 0x7c0c(%rip), %rdi      # 0x1088b
callq 0x6780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8cc2
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x8f90
movq %rax, -0x48(%rbp)
callq 0x8960
movq -0x48(%rbp), %rsi
movq %rax, %rdx
movq -0x10(%rbp), %rcx
movl $0x3, %edi
callq 0x8140
movq %rax, -0x8(%rbp)
jmp 0x8f81
leaq 0x7b85(%rip), %rdi      # 0x1084e
callq 0x6780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8cf7
callq 0x8960
movq %rax, %rsi
movq -0x10(%rbp), %rdx
movl $0x1e, %edi
callq 0x8a80
movq %rax, -0x8(%rbp)
jmp 0x8f81
leaq 0x8116(%rip), %rdi      # 0x10e14
callq 0x6780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8d2c
callq 0x8960
movq %rax, %rsi
movq -0x10(%rbp), %rdx
movl $0x1f, %edi
callq 0x8a80
movq %rax, -0x8(%rbp)
jmp 0x8f81
leaq 0x7b54(%rip), %rdi      # 0x10887
callq 0x6780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8d61
callq 0x8960
movq %rax, %rsi
movq -0x10(%rbp), %rdx
movl $0x28, %edi
callq 0x8a80
movq %rax, -0x8(%rbp)
jmp 0x8f81
leaq 0x7b22(%rip), %rdi      # 0x1088a
callq 0x6780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8d96
callq 0x8960
movq %rax, %rsi
movq -0x10(%rbp), %rdx
movl $0x29, %edi
callq 0x8a80
movq %rax, -0x8(%rbp)
jmp 0x8f81
leaq 0x7af0(%rip), %rdi      # 0x1088d
callq 0x6780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8dcb
callq 0x8960
movq %rax, %rsi
movq -0x10(%rbp), %rdx
movl $0x14, %edi
callq 0x8a80
movq %rax, -0x8(%rbp)
jmp 0x8f81
leaq 0x7abd(%rip), %rdi      # 0x1088f
callq 0x6780
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8e00
callq 0x8960
movq %rax, %rsi
movq -0x10(%rbp), %rdx
movl $0x15, %edi
callq 0x8a80
movq %rax, -0x8(%rbp)
jmp 0x8f81
movl $0x13, %edi
callq 0x7060
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x8e4f
leaq 0x76e7(%rip), %rdi      # 0x10502
callq 0x7730
callq 0x8a40
movq %rax, -0x18(%rbp)
leaq 0x77dd(%rip), %rdi      # 0x1060d
callq 0x7730
movq -0x18(%rbp), %rax
movslq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x8f90
movq %rax, -0x8(%rbp)
jmp 0x8f81
movl $0x12, %edi
callq 0x7060
cmpq $0x0, %rax
je 0x8f66
leaq 0xc766(%rip), %rax      # 0x155d0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
leaq 0x768a(%rip), %rdi      # 0x10502
callq 0x6780
cmpq $0x0, %rax
je 0x8f07
leaq 0xc742(%rip), %rax      # 0x155d0
movq (%rax), %rdi
callq 0x6fc0
testb $0x1, %al
jne 0x8e9c
jmp 0x8ef9
leaq 0xc72d(%rip), %rax      # 0x155d0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
callq 0x8a40
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
testb $0x1, 0xc(%rax)
je 0x8ed3
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x79c5(%rip), %rsi      # 0x10891
movb $0x0, %al
callq 0x6370
leaq 0x7733(%rip), %rdi      # 0x1060d
callq 0x7730
movq -0x30(%rbp), %rax
movslq 0x4(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x8f90
movq %rax, -0x8(%rbp)
jmp 0x8f81
movq -0x20(%rbp), %rcx
leaq 0xc6cc(%rip), %rax      # 0x155d0
movq %rcx, (%rax)
leaq 0xc6c2(%rip), %rax      # 0x155d0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x8960
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xdb80
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
testb $0x1, 0xc(%rax)
je 0x8f4b
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x796e(%rip), %rsi      # 0x108b2
movb $0x0, %al
callq 0x6370
movq -0x40(%rbp), %rdi
callq 0xdb60
movslq %eax, %rdi
movq -0x38(%rbp), %rsi
callq 0x8f90
movq %rax, -0x8(%rbp)
jmp 0x8f81
jmp 0x8f68
jmp 0x8f6a
jmp 0x8f6c
jmp 0x8f6e
jmp 0x8f70
jmp 0x8f72
jmp 0x8f74
jmp 0x8f76
jmp 0x8f78
callq 0x8fd0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)