// File: /workspace/github_c_makefile_star2_O0/sisshiki1969[P]monocc/src/pp.c
// Function: pp
void pp() {
  Macro *m;
  for (Token *t = token; t; t = t->next) {
    // print_token(stderr, t);
    if (t->kind != TK_IDENT) continue;
    if (!(m = find_macro(t))) continue;
    Macro args_head;
    args_head.next = NULL;
    Macro *args = &args_head;
    if (m->params) {
      check_params(m, t, &args);
    }
    // for(Macro *args = args_head.next; args; args = args->next)
    // print_tokens(stderr, args->params);
    if (!m->subst) {
      Token *next_token = t->next;
      *t = *next_token;
      t = next_token;
      continue;
    }

    Token *next_token = t->next;
    *t = *(m->subst);
    while (t->next) {
      if (t->kind == TK_IDENT) {
        for (Token *param = m->params; param; param = param->next) {
          if (cmp_token(t, param)) {
            int i = param->num_val;
            // fprintf(stderr, "find: %d", i);
            // print_token(stderr, t);
            for (Macro *args = args_head.next; args; args = args->next) {
              if (i-- == 0) {
                Token *next = t->next;
                // copy_token(args->params, t);
                *t = *args->params;
                while (t->next) t - t->next;
                t->next = next;
                break;
              }
            }
            // fprintf(stderr, "\n");
            break;
          }
        }
      }
      t = t->next;
    }
    t->next = next_token;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
leaq 0xa2a9(%rip), %rax      # 0x15218
movq (%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xb12c
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0xaf8f
jmp 0xb11b
movq -0x10(%rbp), %rdi
callq 0xb4d0
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
jne 0xafa7
jmp 0xb11b
movq $0x0, -0x30(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xafd3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0xacc0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0xb009
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0x30, %edx
callq 0x1110
movq -0x40(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0xb11b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movl $0x30, %edx
callq 0x1110
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xb10f
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xb0fe
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0xb0fc
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x79f0
testb $0x1, %al
jne 0xb071
jmp 0xb0e9
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0xb0e7
movl -0x54(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x54(%rbp)
cmpl $0x0, %eax
jne 0xb0d8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x30, %edx
callq 0x1110
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xb0ca
jmp 0xb0bd
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xb0e7
jmp 0xb0da
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0xb084
jmp 0xb0fc
jmp 0xb0eb
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0xb053
jmp 0xb0fe
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0xb02b
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0xaf76
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)