// File: /workspace/github_c_makefile_star2_O1/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 0x3b76
movq %rax, %rbx
movq %r14, %rdi
movl $0x1, %esi
callq 0x4dda
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, 0x8(%rbx)
movq %r14, %rdi
movl $0x3c, %esi
callq 0x4d19
testl %eax, %eax
jne 0x628a
movq %r14, %rdi
movl $0x3b, %esi
callq 0x4d19
testl %eax, %eax
je 0x629d
movl $0x0, (%rbx)
movq %r14, %rdi
callq 0x4db5
jmp 0x6506
movq %r14, %rdi
movl $0x7, %esi
callq 0x4d19
testl %eax, %eax
je 0x62fd
movl $0x1, (%rbx)
movl $0x0, 0x10(%rbx)
movq %r14, %rdi
callq 0x4ce7
movq %rax, %rdi
callq 0x1e5a
movq %r14, %rdi
callq 0x4db5
movq %r14, %rdi
movl $0x8, %esi
callq 0x4d19
testl %eax, %eax
je 0x6331
movl $0x0, 0x14(%rbx)
movq %r14, %rdi
callq 0x4ce7
movq %rax, %rdi
callq 0x1e5a
jmp 0x6290
movq %r14, %rdi
callq 0x4ce7
movl (%rax), %ecx
shlq $0x5, %rcx
addq 0x4cce(%rip), %rcx      # 0xafe0
leaq 0x1b17(%rip), %rdi      # 0x7e30
leaq 0x1cba(%rip), %rdx      # 0x7fda
movl $0x472, %esi            # imm = 0x472
xorl %eax, %eax
callq 0x140c
jmp 0x6506
leaq 0x10a8(%rip), %rbp      # 0x73e0
leaq 0x1af1(%rip), %r15      # 0x7e30
leaq 0x1c94(%rip), %r12      # 0x7fda
movq %r14, %rdi
movl $0x1, %esi
callq 0x4d19
testl %eax, %eax
je 0x63cb
cmpl $0x7f, 0x10(%rbx)
jne 0x6373
movq %r15, %rdi
movl $0x44e, %esi            # imm = 0x44E
leaq 0x1c52(%rip), %rdx      # 0x7fbe
xorl %eax, %eax
callq 0x140c
movq %r14, %rdi
callq 0x4ce7
movq %rax, %r13
movq %r14, %rdi
callq 0x4db5
movq 0x10(%r13), %rax
movslq 0x10(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%rbx)
movq %rax, 0x18(%rbx,%rcx,8)
movq %r14, %rdi
movl $0xd, %esi
callq 0x4d19
movq %r14, %rdi
testl %eax, %eax
je 0x6454
callq 0x4ce7
movq %rax, %rdi
callq 0x1e5a
movq %r14, %rdi
callq 0x4db5
jmp 0x6346
movq %r14, %rdi
movl $0xc, %esi
callq 0x4d19
movl %eax, %r13d
movq %r14, %rdi
callq 0x4ce7
testl %r13d, %r13d
je 0x6481
movq %rax, %rdi
callq 0x1e5a
movq %r14, %rdi
callq 0x4db5
xorl %eax, %eax
callq 0x19e8
movq %rax, %r13
movq %rax, %rdi
leaq 0x1bee(%rip), %rsi      # 0x7ffe
callq 0x1a93
movslq 0x10(%rbx), %rax
movq %r13, 0x18(%rbx,%rax,8)
movl $0x1, 0x14(%rbx)
movq %r14, %rdi
movl $0x8, %esi
callq 0x4d19
movl %eax, %r13d
movq %r14, %rdi
callq 0x4ce7
testl %r13d, %r13d
je 0x64a1
movq %rax, %rdi
callq 0x1e5a
movq %r14, %rdi
callq 0x4db5
jmp 0x64bc
movl $0x8, %esi
callq 0x4d19
testl %eax, %eax
jne 0x62e4
movq %r14, %rdi
callq 0x4ce7
movl (%rax), %ecx
shlq $0x5, %rcx
addq %rbp, %rcx
movq %r15, %rdi
movl $0x45b, %esi            # imm = 0x45B
jmp 0x6492
movl (%rax), %ecx
shlq $0x5, %rcx
addq %rbp, %rcx
movq %r15, %rdi
movl $0x46d, %esi            # imm = 0x46D
movq %r12, %rdx
xorl %eax, %eax
callq 0x140c
jmp 0x6346
movl (%rax), %ecx
shlq $0x5, %rcx
addq %rbp, %rcx
movq %r15, %rdi
movl $0x469, %esi            # imm = 0x469
movq %r12, %rdx
xorl %eax, %eax
callq 0x140c
testl %r13d, %r13d
je 0x6346
jmp 0x6506
movq %r14, %rdi
callq 0x4ce7
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 0x4d19
testl %eax, %eax
je 0x64c7
movq %r14, %rdi
movl $0x3b, %esi
callq 0x4dda
movq %rax, %rdi
callq 0x1e5a
cmpl $0x1, (%rbx)
jne 0x6557
movq %rbx, %rdi
callq 0x618e
testl %eax, %eax
jne 0x6557
leaq 0x18ec(%rip), %rdi      # 0x7e30
leaq 0x1abf(%rip), %rdx      # 0x800a
movl $0x47d, %esi            # imm = 0x47D
xorl %eax, %eax
callq 0x140c
movq %rbx, %rdi
callq 0x6207
testl %eax, %eax
jne 0x657d
leaq 0x18c6(%rip), %rdi      # 0x7e30
leaq 0x1aae(%rip), %rdx      # 0x801f
movl $0x480, %esi            # imm = 0x480
xorl %eax, %eax
callq 0x140c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3d12