// File: /workspace/github_c_makefile_star2_O3/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 0x33b4
movq %rax, %r14
movq %rbx, %rdi
movl $0x3b, %esi
callq 0x45e4
movq %rbx, %rdi
testl %eax, %eax
jne 0x4e00
callq 0x45b6
movq %rax, %r15
movl $0x18, %edi
callq 0x10b0
movq %r15, (%rax)
leaq 0x8(%rax), %rcx
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%r14), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%r14)
jmp 0x4db7
movl $0x3b, %esi
callq 0x46a5
movq %rax, %rdi
callq 0x1e94
movq (%r14), %r13
movq %r13, (%rsp)
testq %r13, %r13
je 0x4e64
leaq 0x31dd(%rip), %r15      # 0x8002
movq %rsp, %r12
movq (%r13), %rax
cmpl $0x1, (%rax)
jne 0x4e57
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq %r15, %rsi
callq 0x1080
testl %eax, %eax
jne 0x4e57
movq %r12, %rdi
callq 0x4cc1
movl $0x1, 0x10(%rax)
movq (%rsp), %r13
movq 0x8(%r13), %r13
movq %r13, (%rsp)
testq %r13, %r13
jne 0x4e28
movq %rbx, %rdi
movq %r14, %rsi
callq 0x38da
movq %rax, %r12
xorl %eax, %eax
callq 0x1e6c
movq %rax, %r13
movl $0x2, %ebx
movl %ebx, (%rax)
leaq 0x2636(%rip), %r14      # 0x74c0
addq $0x40, %r14
movq %r14, 0x8(%rax)
movq 0x10(%rax), %rdi
movl $0x30, %esi
callq 0x1a31
xorl %eax, %eax
callq 0x1e6c
movq %rax, %r15
movl %ebx, (%rax)
movq %r14, 0x8(%rax)
movq 0x10(%rax), %rdi
movl $0x31, %esi
callq 0x1a31
callq 0x33b4
movq %rax, %rbx
movq (%r12), %rbp
movq %rbp, (%rsp)
testq %rbp, %rbp
je 0x4f8a
leaq 0x3124(%rip), %r12      # 0x8002
movq (%rbp), %r14
cmpl $0x1, (%r14)
jne 0x4efe
movq 0x10(%r14), %rax
movq (%rax), %rdi
movq %r12, %rsi
callq 0x1080
movq %r13, %r14
testl %eax, %eax
je 0x4f38
movl $0x18, %edi
callq 0x10b0
movq %r14, (%rax)
leaq 0x8(%rax), %rcx
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%rbx), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%rbx)
movq 0x8(%rbp), %rbp
movq %rbp, (%rsp)
testq %rbp, %rbp
jne 0x4ede
jmp 0x4f8a
movq %rsp, %rdi
callq 0x4cc1
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
callq 0x378b
testq %rax, %rax
movq %r15, %r14
cmoveq %r13, %r14
movl $0x18, %edi
callq 0x10b0
movq %r14, (%rax)
leaq 0x8(%rax), %rcx
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%rbx), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%rbx)
movq (%rsp), %rbp
jmp 0x4f29
movq (%rbx), %rax
testq %rax, %rax
je 0x4fb5
movq %rbx, %rcx
movq (%rax), %rsi
movq 0x8(%rax), %rdx
cmpl $0x3c, (%rsi)
jne 0x4fa6
movq %rdx, (%rcx)
jmp 0x4fad
addq $0x8, %rax
movq %rax, %rcx
movq %rdx, %rax
testq %rdx, %rdx
jne 0x4f95
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x48b2