// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
testq %rdi, %rdi
je 0x8db1
movq %rdi, %r15
cmpl $0x1, (%rdi)
jne 0x8db1
movq %rsi, %rbx
movq 0x8756(%rip), %r13      # 0x11388
leaq 0x36ce(%rip), %r14      # 0xc307
testq %r15, %r15
je 0x8db1
movq %r15, %rdi
movq %r14, %rsi
callq 0x87de
testl %eax, %eax
je 0x8c9f
movq 0x110(%r15), %rsi
testq %rsi, %rsi
je 0x8c9f
movq %rbx, %rdi
callq 0x4035
testq %rax, %rax
je 0x8c9f
movq 0xa0(%rax), %rbp
testq %rbp, %rbp
je 0x8dc0
cmpl $0x1, (%rbp)
jne 0x8dc0
xorl %r12d, %r12d
movq %rbp, %rax
testq %rax, %rax
je 0x8d0c
addl 0x120(%rax), %r12d
movq 0x110(%rax), %rax
jmp 0x8c8a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4035
testq %rax, %rax
je 0x8cee
movq 0xa0(%rax), %rdi
callq 0x876b
movq %rax, %rdx
movq %rdx, %rcx
movq 0x110(%rdx), %rdx
testq %rdx, %rdx
jne 0x8cbe
movq 0x110(%r15), %rdx
movq (%r13), %rsi
movq %rsi, 0x110(%rcx)
addq $0x110, %rcx            # imm = 0x110
movq %rax, %r15
jmp 0x8da2
leaq 0x110(%r15), %rcx
movq 0x110(%r15), %rdx
movq (%r13), %rax
movq %rax, 0x110(%r15)
jmp 0x8da2
leal 0x3(%r12), %eax
movslq %eax, %rdi
callq 0x2140
testq %rax, %rax
je 0x8dd8
movb $0x22, (%rax)
movq %rax, %rcx
incq %rcx
testq %rbp, %rbp
je 0x8d5e
xorl %edx, %edx
movslq 0x120(%rbp), %rsi
cmpq %rsi, %rdx
jge 0x8d52
movq 0x118(%rbp), %rsi
movb (%rsi,%rdx), %sil
movb %sil, (%rcx,%rdx)
incq %rdx
jmp 0x8d32
movq 0x110(%rbp), %rbp
addq %rdx, %rcx
jmp 0x8d2b
movw $0x22, (%rcx)
addl $0x2, %r12d
movq %rax, %rdi
xorl %esi, %esi
movq %rax, %rdx
movl %r12d, %ecx
pushq $0x18
popq %r8
callq 0x86ce
movq 0x110(%r15), %rcx
movq 0x110(%rcx), %rdx
movq (%r13), %rcx
movq %rcx, 0x110(%rax)
movq %rax, %r15
movq %rax, %rcx
movl $0x110, %eax            # imm = 0x110
addq %rax, %rcx
movq %r15, (%r13)
movq %rcx, %r13
movq %rdx, %r15
jmp 0x8c39
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3956(%rip), %rdi      # 0xc71d
leaq 0x38cf(%rip), %rsi      # 0xc69d
movl $0xb7, %edx
callq 0x3cc4
leaq 0x3604(%rip), %rdi      # 0xc3e3
leaq 0x38b7(%rip), %rsi      # 0xc69d
movl $0xbd, %edx
callq 0x3cc4