// File: /workspace/github_c_makefile_star2_O3/hikalium[P]compilium/token.c
// Function: InsertTokensWithIdentReplace
void InsertTokensWithIdentReplace(struct Node *seq, struct Node *rep_list) {
  // Insert token sequece (seq) at current cursor pos.
  // if seq contains token in rep_list, replace it with tokens rep_list[token];
  // elements of seq will be inserted directly.
  if (!IsToken(seq)) return;
  struct Node **next_holder = next_token_holder;
  while (seq) {
    struct Node *e;
    if (IsEqualTokenWithCStr(seq, "#") && seq->next_token &&
        (e = GetNodeByTokenKey(rep_list, seq->next_token))) {
      struct Node *st = CreateStringLiteralOfTokens(e->value);
      seq = seq->next_token->next_token;
      //
      st->next_token = *next_holder;
      *next_holder = st;
      next_holder = &st->next_token;
      continue;
    }
    if (!(e = GetNodeByTokenKey(rep_list, seq))) {
      // no replace
      struct Node *n = seq;
      seq = seq->next_token;
      //
      n->next_token = *next_holder;
      *next_holder = n;
      next_holder = &(*next_holder)->next_token;
      continue;
    }
    struct Node *n = DuplicateTokenSequence(e->value);
    struct Node *n_last = n;
    while (n_last->next_token) n_last = n_last->next_token;
    seq = seq->next_token;
    //
    n_last->next_token = *next_holder;
    *next_holder = n;
    next_holder = &n_last->next_token;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x97f6
movq %rdi, %r15
cmpl $0x1, (%rdi)
jne 0x97f6
movq %rsi, %rbx
movq 0x7d7b(%rip), %r13      # 0x11388
leaq 0x2cf3(%rip), %rbp      # 0xc307
movq %rsi, 0x10(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x9210
testl %eax, %eax
je 0x9747
movq 0x110(%r15), %rsi
testq %rsi, %rsi
je 0x9747
movq %rbx, %rdi
callq 0x496e
testq %rax, %rax
je 0x9747
movq %rbp, %rbx
movq 0xa0(%rax), %rbp
testq %rbp, %rbp
je 0x9805
cmpl $0x1, (%rbp)
jne 0x9805
xorl %r14d, %r14d
movq %rbp, %rax
movslq 0x120(%rax), %rcx
movslq %r14d, %r14
addq %rcx, %r14
movq 0x110(%rax), %rax
testq %rax, %rax
jne 0x9670
movq %r14, %rdi
addq $0x3, %rdi
callq 0x2140
testq %rax, %rax
je 0x981d
movq %rax, %r12
movb $0x22, (%rax)
incq %rax
cmpl $0x0, 0x120(%rbp)
jle 0x96d1
xorl %ecx, %ecx
movq 0x118(%rbp), %rdx
movb (%rdx,%rcx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
movslq 0x120(%rbp), %rdx
cmpq %rdx, %rcx
jl 0x96b2
addq %rcx, %rax
movq 0x110(%rbp), %rbp
testq %rbp, %rbp
jne 0x96a7
movw $0x22, (%rax)
leal 0x2(%r14), %ebp
movl $0x1, %edi
callq 0x3f11
movq %r12, 0x118(%rax)
movl %ebp, 0x120(%rax)
movl $0x18, 0x108(%rax)
movq %r12, 0x128(%rax)
movl $0x0, 0x130(%rax)
movq 0x110(%r15), %rcx
movq 0x110(%rcx), %rcx
movq (%r13), %rdx
movq %rdx, 0x110(%rax)
movq %rax, %r15
addq $0x110, %rax            # imm = 0x110
movq %rbx, %rbp
movq 0x10(%rsp), %rbx
jmp 0x97e3
movq %rbx, %rdi
movq %r15, %rsi
callq 0x496e
testq %rax, %rax
je 0x9799
movq 0xa0(%rax), %r12
movq $0x0, 0x8(%rsp)
testq %r12, %r12
je 0x97b4
leaq 0x8(%rsp), %r14
movq %r12, %rdi
callq 0x9134
movq %rax, (%r14)
addq $0x110, %rax            # imm = 0x110
movq 0x110(%r12), %r12
movq %rax, %r14
testq %r12, %r12
jne 0x9771
movq 0x8(%rsp), %rdx
jmp 0x97b6
leaq 0x110(%r15), %rax
movq 0x110(%r15), %rcx
movq (%r13), %rdx
movq %rdx, 0x110(%r15)
jmp 0x97e3
xorl %edx, %edx
movq %rdx, %rcx
movq %rcx, %rax
movq 0x110(%rcx), %rcx
testq %rcx, %rcx
jne 0x97b9
movq 0x110(%r15), %rcx
movq (%r13), %rsi
movq %rsi, 0x110(%rax)
addq $0x110, %rax            # imm = 0x110
movq %rdx, %r15
movq %r15, (%r13)
movq %rcx, %r15
movq %rax, %r13
testq %rcx, %rcx
jne 0x9619
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f11(%rip), %rdi      # 0xc71d
leaq 0x2e8a(%rip), %rsi      # 0xc69d
movl $0xb7, %edx
callq 0x46d0
leaq 0x2bbf(%rip), %rdi      # 0xc3e3
leaq 0x2e72(%rip), %rsi      # 0xc69d
movl $0xbd, %edx
callq 0x46d0