// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xbbb0
testb $0x1, %al
jne 0xc542
jmp 0xc6d2
movq 0x8e2f(%rip), %rax      # 0x15378
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xc6d2
movq -0x8(%rbp), %rdi
leaq 0x4d15(%rip), %rsi      # 0x11278
callq 0xbdf0
cmpl $0x0, %eax
je 0xc5f7
movq -0x8(%rbp), %rax
cmpq $0x0, 0x110(%rax)
je 0xc5f7
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rsi
callq 0x50b0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xc5f7
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0xc6e0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rax
movq 0x110(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x110(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq $0x110, %rax            # imm = 0x110
movq %rax, -0x18(%rbp)
jmp 0xc54d
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x50b0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0xc658
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x110(%rax)
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
addq $0x110, %rax            # imm = 0x110
movq %rax, -0x18(%rbp)
jmp 0xc54d
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0xbd20
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x110(%rax)
je 0xc693
movq -0x40(%rbp), %rax
movq 0x110(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xc674
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x110(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
addq $0x110, %rax            # imm = 0x110
movq %rax, -0x18(%rbp)
jmp 0xc54d
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)