// File: /workspace/github_c_makefile_star2_O1/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 0x985d
movq %rdi, %r15
cmpl $0x1, (%rdi)
jne 0x985d
movq %rsi, %rbx
movq 0x7d13(%rip), %rbp      # 0x11388
leaq 0x2c8f(%rip), %r13      # 0xc30b
movq %rsi, 0x10(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x9278
testl %eax, %eax
je 0x97b2
movq 0x110(%r15), %rsi
testq %rsi, %rsi
je 0x97b2
movq %rbx, %rdi
callq 0x49a2
testq %rax, %rax
je 0x97b2
movq %r13, %rbx
movq 0xa0(%rax), %r13
testq %r13, %r13
je 0x986c
cmpl $0x1, (%r13)
jne 0x986c
xorl %r14d, %r14d
movq %r13, %rax
movslq 0x120(%rax), %rcx
movslq %r14d, %r14
addq %rcx, %r14
movq 0x110(%rax), %rax
testq %rax, %rax
jne 0x96d9
movq %r14, %rdi
addq $0x3, %rdi
callq 0x2140
testq %rax, %rax
je 0x9884
movq %rax, %r12
movb $0x22, (%rax)
incq %rax
cmpl $0x0, 0x120(%r13)
jle 0x973b
xorl %ecx, %ecx
movq 0x118(%r13), %rdx
movb (%rdx,%rcx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
movslq 0x120(%r13), %rdx
cmpq %rdx, %rcx
jl 0x971c
addq %rcx, %rax
movq 0x110(%r13), %r13
testq %r13, %r13
jne 0x9710
movw $0x22, (%rax)
addl $0x2, %r14d
movl $0x1, %edi
callq 0x3f05
movq %r12, 0x118(%rax)
movl %r14d, 0x120(%rax)
movl $0x18, 0x108(%rax)
movq %r12, 0x128(%rax)
movl $0x0, 0x130(%rax)
movq 0x110(%r15), %rcx
movq 0x110(%rcx), %rcx
movq (%rbp), %rdx
movq %rdx, 0x110(%rax)
movq %rax, %r15
addq $0x110, %rax            # imm = 0x110
movq %rbx, %r13
movq 0x10(%rsp), %rbx
jmp 0x984a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x49a2
testq %rax, %rax
je 0x9831
movq 0xa0(%rax), %r12
movq $0x0, 0x8(%rsp)
testq %r12, %r12
je 0x97fd
leaq 0x8(%rsp), %r14
movq %r12, %rdi
callq 0x91a0
movq %rax, (%r14)
addq $0x110, %rax            # imm = 0x110
movq 0x110(%r12), %r12
movq %rax, %r14
testq %r12, %r12
jne 0x97dc
movq 0x8(%rsp), %rdx
movq %rdx, %rcx
movq %rcx, %rax
movq 0x110(%rcx), %rcx
testq %rcx, %rcx
jne 0x9805
movq 0x110(%r15), %rcx
movq (%rbp), %rsi
movq %rsi, 0x110(%rax)
addq $0x110, %rax            # imm = 0x110
movq %rdx, %r15
jmp 0x984a
leaq 0x110(%r15), %rax
movq 0x110(%r15), %rcx
movq (%rbp), %rdx
movq %rdx, 0x110(%r15)
movq %r15, (%rbp)
movq %rcx, %r15
movq %rax, %rbp
testq %rcx, %rcx
jne 0x9681
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2eae(%rip), %rdi      # 0xc721
leaq 0x2e27(%rip), %rsi      # 0xc6a1
movl $0xb7, %edx
callq 0x4704
leaq 0x2b5c(%rip), %rdi      # 0xc3e7
leaq 0x2e0f(%rip), %rsi      # 0xc6a1
movl $0xbd, %edx
callq 0x4704