// File: /workspace/github_c_makefile_star2_O3/ShinyaKato[P]skcc/preprocess.c
// Function: concat_macro_token
struct pp_list *concat_macro_token(struct pp_list *list) {
  struct pp_list *result = allocate_pp_list();

  for(struct pp_node *node = list->head; node != NULL; node = node->next) {
    struct pp_node *left = node;
    struct pp_node *middle = left->next;
    if(middle != NULL && middle->token->type == PP_SPACE) {
      middle = middle->next;
    }
    struct pp_node *right = middle != NULL ? middle->next : NULL;
    if(right != NULL && right->token->type == PP_SPACE) {
      right = right->next;
    }

    if(middle != NULL && right != NULL && middle->token->type == PP_CONCAT && !middle->token->concat) {
      struct pp_token *l = left->token;
      struct pp_token *r = right->token;

      struct string *str = allocate_string();
      concat_string(str, l->text);
      concat_string(str, r->text);

      struct pp_token_lexer lexer;
      lexer.queue = (struct utf8c *) malloc(sizeof(struct utf8c) * (str->size + 1));
      lexer.queue_head = 0;
      lexer.queue_size = 0;
      lexer.queue_allocate_size = str->size + 1;
      lexer.context = CTX_NORMAL;

      for(int i = 0; i < str->size;) {
        struct utf8c uc;
        uc.bytes = count_bytes(str->head[i]);
        for(int j = 0; j < uc.bytes; j++) {
          uc.sequence[j] = str->head[i++];
        }
        uc.sequence[uc.bytes] = '\0';
        lexer.queue[lexer.queue_size++] = uc;
      }
      lexer.queue[lexer.queue_size++] = ueof;

      struct pp_token *new_token = next_pp_token(&lexer);
      new_token->concat = 1;
      if(lexer.queue_size > 1) {
        error("invalid token concatnation: %s ## %s\n", l->text->head, r->text->head);
      }
      append_pp_list(result, new_token);

      node = right;
    } else {
      append_pp_list(result, node->token);
    }
  }

  // remove place marker
  for(struct pp_node **node = &(result->head); *node != NULL;) {
    if((*node)->token->type == PP_PLACE_MARKER) {
      *node = (*node)->next;
    } else {
      node = &((*node)->next);
    }
  }

  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r14
callq 0x33b4
movq %rax, %r13
movq (%r14), %r12
testq %r12, %r12
je 0x4551
movq 0x8(%r12), %rax
testq %rax, %rax
je 0x437a
movq (%rax), %rcx
cmpl $0x3c, (%rcx)
jne 0x4352
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x437a
movq 0x8(%rax), %r15
testq %r15, %r15
je 0x437a
movq (%r15), %rcx
cmpl $0x3c, (%rcx)
jne 0x436c
movq 0x8(%r15), %r15
testq %r15, %r15
je 0x437a
movq (%rax), %rax
cmpl $0x3a, (%rax)
jne 0x437a
cmpl $0x0, 0x18(%rax)
je 0x43b3
movq (%r12), %rbx
movl $0x18, %edi
callq 0x10b0
movq %rbx, (%rax)
leaq 0x8(%rax), %rcx
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%r13), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%r13)
movq 0x8(%r12), %r12
jmp 0x432e
movq (%r12), %r14
movq (%r15), %rbx
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x1a00
movq %rax, %rbp
movq %r14, 0x18(%rsp)
movq 0x10(%r14), %rsi
movq %rax, %rdi
callq 0x1aeb
movq %rbx, 0x20(%rsp)
movq 0x10(%rbx), %rsi
movq %rbp, %rdi
callq 0x1aeb
movslq 0x8(%rbp), %rbx
leaq 0x1(%rbx), %r14
leaq 0x4(,%rbx,4), %rax
leaq (%rax,%rax,2), %rdi
callq 0x10b0
movq %rax, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
movl %r14d, 0x60(%rsp)
movl $0x3, 0x64(%rsp)
testq %rbx, %rbx
jle 0x44ac
movq %r13, 0x10(%rsp)
xorl %r14d, %r14d
movq (%rbp), %rax
movslq %r14d, %rbx
movzbl (%rax,%rbx), %edi
callq 0x14c0
movl %eax, %r12d
movl %eax, 0x4(%rsp)
testl %eax, %eax
jle 0x4468
movq (%rbp), %rsi
addq %rbx, %rsi
movl %r12d, %r13d
leaq 0x8(%rsp), %rdi
movq %r13, %rdx
callq 0x10a0
addl %r12d, %ebx
movl %ebx, %r14d
jmp 0x446b
movslq %r12d, %r13
movb $0x0, 0x8(%rsp,%r13)
movq 0x50(%rsp), %rax
movslq 0x5c(%rsp), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x5c(%rsp)
leaq (%rcx,%rcx,2), %rcx
movl 0xc(%rsp), %edx
movl %edx, 0x8(%rax,%rcx,4)
movq 0x4(%rsp), %rdx
movq %rdx, (%rax,%rcx,4)
cmpl 0x8(%rbp), %r14d
jl 0x442e
movq 0x50(%rsp), %rax
movl 0x5c(%rsp), %r12d
movq 0x10(%rsp), %r13
leal 0x1(%r12), %ecx
movl %ecx, 0x5c(%rsp)
movslq %r12d, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x6bd5(%rip), %rsi      # 0xb098
movl 0x8(%rsi), %edx
movl %edx, 0x8(%rax,%rcx,4)
movq (%rsi), %rdx
movq %rdx, (%rax,%rcx,4)
leaq 0x28(%rsp), %rdi
callq 0x2163
movq %rax, %rbp
movl $0x1, 0x18(%rax)
cmpl $0x1, 0x5c(%rsp)
jle 0x451e
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %r8
leaq 0x3a05(%rip), %rdi      # 0x7f10
movl $0x153, %esi            # imm = 0x153
leaq 0x3a65(%rip), %rdx      # 0x7f7c
xorl %eax, %eax
callq 0x142c
movl $0x18, %edi
callq 0x10b0
movq %rbp, (%rax)
leaq 0x8(%rax), %rcx
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%r13), %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%r13)
movq %r15, %r12
jmp 0x43a9
movq (%r13), %rax
testq %rax, %rax
je 0x457d
movq %r13, %rcx
movq (%rax), %rsi
movq 0x8(%rax), %rdx
cmpl $0x3f, (%rsi)
jne 0x456e
movq %rdx, (%rcx)
jmp 0x4575
addq $0x8, %rax
movq %rax, %rcx
movq %rdx, %rax
testq %rdx, %rdx
jne 0x455d
movq %r13, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq