// File: /workspace/github_c_makefile_star2_O3/ShinyaKato[P]skcc/preprocess.c
// Function: define_directive
void define_directive(struct preprocessor *pp) {
  struct macro_entry *macro = allocate_macro_entry();

  macro->identifier = expect_pp_token(pp, PP_IDENT)->text->head;

  if(check_pp_token(pp, PP_SPACE) || check_pp_token(pp, PP_NEW_LINE)) {
    macro->type = MACRO_OBJECT;
    remove_white_space(pp);
  } else if(check_pp_token(pp, PP_LPAREN)) {
    macro->type = MACRO_FUNCTION;
    macro->parameter_size = 0;

    skip_pp_token_with_space(pp);

    if(check_pp_token(pp, PP_RPAREN)) {
      macro->parameter_ellipsis = 0;
      skip_pp_token_with_space(pp);
    } else {
      while(1) {
        if(check_pp_token(pp, PP_IDENT)) {
          if(macro->parameter_size == MACRO_PARAMS_LIMIT) {
            error("too many macro parameters.\n");
          }

          struct pp_token *token = read_pp_token_with_space(pp);
          macro->parameters[macro->parameter_size++] = token->text;

          if(check_pp_token(pp, PP_COMMA)) {
            skip_pp_token_with_space(pp);
          } else if(check_pp_token(pp, PP_RPAREN)) {
            macro->parameter_ellipsis = 0;
            skip_pp_token_with_space(pp);
            break;
          } else {
            unexpected_pp_token(pp);
          }
        } else if(check_pp_token(pp, PP_ELLIPSIS)) {
          skip_pp_token_with_space(pp);

          struct string *va_args = allocate_string();
          write_string(va_args, "__VA_ARGS__");
          macro->parameters[macro->parameter_size] = va_args;
          macro->parameter_ellipsis = 1;

          if(check_pp_token(pp, PP_RPAREN)) {
            skip_pp_token_with_space(pp);
            break;
          } else {
            unexpected_pp_token(pp);
          }
        }
        else {
          unexpected_pp_token(pp);
        }
      }
    }
  } else {
    unexpected_pp_token(pp);
  }

  while(!check_pp_token(pp, PP_NEW_LINE)) {
    struct pp_token *token = read_pp_token(pp);
    append_pp_list(macro->replacement_list, token);
  }

  discard_new_line(pp);

  if(macro->type == MACRO_FUNCTION && !check_stringify_operator(macro)) {
    error("invalid # operator.\n");
  }
  if(!check_concat_operator(macro)) {
    error("invalid ## operator.\n");
  }

  insert_macro_table(macro);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x345a
movq %rax, %rbx
movq %r14, %rdi
movl $0x1, %esi
callq 0x46a5
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, 0x8(%rbx)
movq %r14, %rdi
movl $0x3c, %esi
callq 0x45e4
testl %eax, %eax
jne 0x5ace
movq %r14, %rdi
movl $0x3b, %esi
callq 0x45e4
testl %eax, %eax
je 0x5ae1
movl $0x0, (%rbx)
movq %r14, %rdi
callq 0x4680
jmp 0x5bb5
movq %r14, %rdi
movl $0x7, %esi
callq 0x45e4
testl %eax, %eax
je 0x5b45
movl $0x1, (%rbx)
movl $0x0, 0x10(%rbx)
movq %r14, %rdi
callq 0x45b6
movq %rax, %rdi
callq 0x1e94
movq %r14, %rdi
callq 0x4680
movq %r14, %rdi
movl $0x8, %esi
callq 0x45e4
testl %eax, %eax
je 0x5c6b
movl $0x0, 0x14(%rbx)
movq %r14, %rdi
callq 0x45b6
movq %rax, %rdi
callq 0x1e94
jmp 0x5ad4
movq %r14, %rdi
callq 0x45b6
movl (%rax), %ecx
shlq $0x5, %rcx
addq 0x5486(%rip), %rcx      # 0xafe0
leaq 0x23af(%rip), %rdi      # 0x7f10
leaq 0x2552(%rip), %rdx      # 0x80ba
movl $0x472, %esi            # imm = 0x472
xorl %eax, %eax
callq 0x142c
jmp 0x5bb5
movq %r14, %rdi
callq 0x45b6
movq %rax, %r15
movq 0x418(%rbx), %r12
movl $0x18, %edi
callq 0x10b0
movq %r15, (%rax)
leaq 0x8(%rax), %rcx
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%r12), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%r12)
movq %r14, %rdi
movl $0x3b, %esi
callq 0x45e4
testl %eax, %eax
je 0x5b76
movq %r14, %rdi
movl $0x3b, %esi
callq 0x46a5
movq %rax, %rdi
callq 0x1e94
cmpl $0x1, (%rbx)
jne 0x5c06
movq %rbx, %rdi
callq 0x59ea
testl %eax, %eax
jne 0x5c06
leaq 0x231d(%rip), %rdi      # 0x7f10
leaq 0x24f0(%rip), %rdx      # 0x80ea
movl $0x47d, %esi            # imm = 0x47D
xorl %eax, %eax
callq 0x142c
movq 0x418(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x5c55
movq %rax, %rcx
movq (%rcx), %rdx
cmpl $0x3a, (%rdx)
jne 0x5c30
cmpq %rax, %rcx
je 0x5c3b
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
jne 0x5c34
jmp 0x5c3b
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
jne 0x5c18
jmp 0x5c55
leaq 0x22ce(%rip), %rdi      # 0x7f10
leaq 0x24b6(%rip), %rdx      # 0x80ff
movl $0x480, %esi            # imm = 0x480
xorl %eax, %eax
callq 0x142c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x35bf
leaq 0x184e(%rip), %r13      # 0x74c0
leaq 0x2297(%rip), %r15      # 0x7f10
leaq 0x243a(%rip), %r12      # 0x80ba
xorl %ebp, %ebp
movl %ebp, %eax
movq %rax, (%rsp)
movq %r14, %rdi
movl $0x1, %esi
callq 0x45e4
testl %eax, %eax
jne 0x5d40
movq %r14, %rdi
movl $0xc, %esi
callq 0x45e4
movl %eax, %ebp
movq %r14, %rdi
callq 0x45b6
testl %ebp, %ebp
jne 0x5cd5
movl (%rax), %ecx
shlq $0x5, %rcx
addq %r13, %rcx
movq %r15, %rdi
movl $0x46d, %esi            # imm = 0x46D
movq %r12, %rdx
xorl %eax, %eax
callq 0x142c
jmp 0x5c88
movq %rax, %rdi
callq 0x1e94
movq %r14, %rdi
callq 0x4680
xorl %eax, %eax
callq 0x1a00
movq %rax, %rbp
movq %rax, %rdi
leaq 0x23e5(%rip), %rsi      # 0x80de
callq 0x1abc
movq (%rsp), %rax
movq %rbp, 0x18(%rbx,%rax,8)
movl $0x1, 0x14(%rbx)
movq %r14, %rdi
movl $0x8, %esi
callq 0x45e4
movl %eax, %ebp
movq %r14, %rdi
callq 0x45b6
testl %ebp, %ebp
jne 0x5b3b
movl (%rax), %ecx
shlq $0x5, %rcx
addq %r13, %rcx
movq %r15, %rdi
movl $0x469, %esi            # imm = 0x469
jmp 0x5cc9
cmpl $0x7f, (%rsp)
jne 0x5d5c
movq %r15, %rdi
movl $0x44e, %esi            # imm = 0x44E
leaq 0x2349(%rip), %rdx      # 0x809e
xorl %eax, %eax
callq 0x142c
movq %r14, %rdi
callq 0x45b6
movq %rax, %rbp
movq %r14, %rdi
callq 0x4680
movq 0x10(%rbp), %rax
movq (%rsp), %rcx
leal 0x1(%rcx), %ebp
movl %ebp, 0x10(%rbx)
movq %rax, 0x18(%rbx,%rcx,8)
movq %r14, %rdi
movl $0xd, %esi
callq 0x45e4
movq %r14, %rdi
testl %eax, %eax
je 0x5db0
callq 0x45b6
movq %rax, %rdi
callq 0x1e94
movq %r14, %rdi
callq 0x4680
jmp 0x5c82
movl $0x8, %esi
callq 0x45e4
testl %eax, %eax
jne 0x5b2c
movq %r14, %rdi
callq 0x45b6
movl (%rax), %ecx
shlq $0x5, %rcx
addq %r13, %rcx
movq %r15, %rdi
movl $0x45b, %esi            # imm = 0x45B
movq %r12, %rdx
xorl %eax, %eax
callq 0x142c
jmp 0x5c82