// File: /workspace/github_c_makefile_star2_O2/ShinyaKato[P]skcc/preprocess.c
// Function: if_control
int if_control(struct preprocessor *pp) {
  struct pp_list *list = allocate_pp_list();
  while(!check_pp_token(pp, PP_NEW_LINE)) {
    struct pp_token *token = read_pp_token(pp);
    append_pp_list(list, token);
  }
  discard_new_line(pp);

  for(struct pp_node *node = list->head; node != NULL; node = node->next) {
    if(node->token->type == PP_IDENT && strcmp(node->token->text->head, "defined") == 0) {
      struct pp_node *ident = check_defined_operator(&node);
      ident->skip = 1;
    }
  }

  list = scan_macro(pp, list);

  struct pp_token *zero = allocate_pp_token();
  zero->type = PP_NUM;
  zero->name = pp_token_name[PP_NUM];
  append_string(zero->text, '0');

  struct pp_token *one = allocate_pp_token();
  one->type = PP_NUM;
  one->name = pp_token_name[PP_NUM];
  append_string(one->text, '1');

  struct pp_list *replaced = allocate_pp_list();
  for(struct pp_node *node = list->head; node != NULL; node = node->next) {
    if(node->token->type == PP_IDENT && strcmp(node->token->text->head, "defined") == 0) {
      struct pp_node *ident = check_defined_operator(&node);
      struct macro_entry *macro = search_macro_table(ident->token->text->head);
      append_pp_list(replaced, macro == NULL ? zero : one);
    } else {
      append_pp_list(replaced, node->token->type != PP_IDENT ? node->token : zero);
    }
  }

  for(struct pp_node **node = &(replaced->head); *node != NULL;) {
    if((*node)->token->type == PP_SPACE || (*node)->token->type == PP_SPACE) {
      *node = (*node)->next;
    } else {
       node = &((*node)->next);
    }
  }

  return conditional_expression(&(replaced->head));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x325c
movq %rax, %r14
pushq $0x3b
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3ffb
movq %rbx, %rdi
testl %eax, %eax
jne 0x4765
callq 0x3fcd
movq %r14, %rdi
movq %rax, %rsi
callq 0x32b4
jmp 0x4742
callq 0x40a7
leaq 0x2891(%rip), %r15      # 0x7002
movq %rsp, %r12
movq %r14, %r13
movq (%r13), %r13
movq %r13, (%rsp)
testq %r13, %r13
je 0x47b9
movq (%r13), %rax
cmpl $0x1, (%rax)
jne 0x47b3
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq %r15, %rsi
callq 0x1080
testl %eax, %eax
jne 0x47b3
movq %r12, %rdi
callq 0x4649
movl $0x1, 0x10(%rax)
movq (%rsp), %r13
addq $0x8, %r13
jmp 0x4777
movq %rbx, %rdi
movq %r14, %rsi
callq 0x368f
movq %rax, %r15
xorl %eax, %eax
callq 0x1d2f
movq %rax, %rbx
pushq $0x2
popq %rbp
movl %ebp, (%rax)
leaq 0x1ce3(%rip), %r14      # 0x64c0
addq $0x40, %r14
movq %r14, 0x8(%rax)
movq 0x10(%rax), %rdi
pushq $0x30
popq %rsi
callq 0x1931
xorl %eax, %eax
callq 0x1d2f
movq %rax, %r12
movl %ebp, (%rax)
movq %r14, 0x8(%rax)
movq 0x10(%rax), %rdi
pushq $0x31
popq %rsi
callq 0x1931
callq 0x325c
movq %rax, %r14
leaq 0x27e6(%rip), %r13      # 0x7002
movq %rsp, %rbp
movq (%r15), %r15
movq %r15, (%rsp)
testq %r15, %r15
je 0x4886
movq (%r15), %rsi
cmpl $0x1, (%rsi)
jne 0x4849
movq 0x10(%rsi), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0x1080
movq %rbx, %rsi
testl %eax, %eax
je 0x4857
movq %r14, %rdi
callq 0x32b4
addq $0x8, %r15
jmp 0x481f
movq %rbp, %rdi
callq 0x4649
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
callq 0x357e
testq %rax, %rax
movq %r12, %rsi
cmoveq %rbx, %rsi
movq %r14, %rdi
callq 0x32b4
movq (%rsp), %r15
jmp 0x4851
movq %r14, %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x48aa
movq (%rcx), %rdx
addq $0x8, %rcx
cmpl $0x3c, (%rdx)
jne 0x48a5
movq (%rcx), %rcx
movq %rcx, (%rax)
jmp 0x488c
movq %rcx, %rax
jmp 0x4889
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4265