// File: /workspace/github_c_makefile_star2_O3/sisshiki1969[P]monocc/src/debug.c
// Function: print_node
void print_node(Node *node) {
  if (node == NULL) {
    fprintf(output, "NULL ");
    return;
  }
  if (is_binary_op(node->kind)) {
    switch (node->kind) {
      case ND_ADD:
      case ND_SUB:
      case ND_MUL:
      case ND_DIV:
      case ND_EQ:
      case ND_NEQ:
      case ND_GE:
      case ND_GT:
      case ND_LAND:
      case ND_LOR:
      case ND_AND:
      case ND_OR:
      case ND_XOR:
      case ND_SHR:
      case ND_SHL:
        fprintf(output, "(%.*s ", node->token->len, node->token->str);
        break;
      default:
        error("Unknown binary node.");
    }
    print_node(node->lhs);
    fprintf(output, " ");
    print_node(node->rhs);
    fprintf(output, ")");
    return;
  }
  switch (node->kind) {
    case ND_NOT:
      fprintf(output, "(! ");
      print_node(node->lhs);
      fprintf(output, ")");
      return;
    case ND_CMP:
      fprintf(output, "(~ ");
      print_node(node->lhs);
      fprintf(output, ")");
      return;
    case ND_ADDR:
      fprintf(output, "(ADDR ");
      print_node(node->lhs);
      fprintf(output, ")");
      return;
    case ND_DEREF:
      fprintf(output, "(DEREF ");
      print_node(node->lhs);
      fprintf(output, ")");
      return;
    case ND_CAST:
      fprintf(output, "(CAST ");
      print_type(output, node->type);
      fprintf(output, " ");
      print_node(node->lhs);
      fprintf(output, ")");
      return;
    case ND_MEMBER:
      fprintf(output, "(MEMBER ");
      print_node(node->lhs);
      fprintf(output, " %.*s %d)", node->token->len, node->token->str,
              node->offset);
      return;
    case ND_BREAK:
      fprintf(output, "BREAK ");
      return;
    case ND_CONTINUE:
      fprintf(output, "CONTINUE ");
      return;
  }
  if (node->kind == ND_CALL) {
    Token *name = node->lhs->token;
    fprintf(output, "(CALL %.*s (", name->len, name->str);
    Vector *vec = node->nodes;
    int len = vec_len(vec);
    for (int i = 0; i < len; i++) {
      print_node(vec->data[i]);
      fprintf(output, ":");
    }
    fprintf(output, ") )");
    return;
  }
  if (node->kind == ND_NUM) {
    fprintf(output, " %ld ", node->num_val);
    return;
  }
  if (node->kind == ND_STR) {
    fprintf(output, " \"%.*s\" ", node->token->len, node->token->str);
    return;
  }
  if (node->kind == ND_INIT) {
    Vector *vec = node->nodes;
    bool first = true;
    fprintf(output, "{");
    for (int i = 0; i < vec_len(vec); i++) {
      if (!first) fprintf(output, ",");
      first = false;
      print_node(vec->data[i]);
      // fprintf(output, " ");
    }
    fprintf(output, "}");
    return;
  }
  if (node->kind == ND_ASSIGN) {
    fprintf(output, "(= ");
    print_node(node->lhs);
    fprintf(output, " ");
    print_node(node->rhs);
    fprintf(output, ")");
    return;
  }
  if (node->kind == ND_IF) {
    fprintf(output, "(IF ");
    print_node(node->lhs);
    fprintf(output, " ");
    print_node(node->rhs);
    fprintf(output, " ");
    print_node(node->xhs);
    fprintf(output, ")");
    return;
  }
  if (node->kind == ND_SWITCH) {
    fprintf(output, "(SWITCH cond: ");
    print_node(node->lhs);
    fprintf(output, " body: ");
    print_node(node->rhs);
    fprintf(output, ")");
    return;
  }

  if (node->kind == ND_CASE) {
    fprintf(output, "(CASE cond:");
    print_node(node->lhs);
    fprintf(output, " body:");
    print_node(node->rhs);
    fprintf(output, ")");
    return;
  }

  if (node->kind == ND_DEFAULT) {
    fprintf(output, "(DEFAULT body:");
    print_node(node->lhs);
    fprintf(output, ")");
    return;
  }

  if (node->kind == ND_WHILE) {
    fprintf(output, "(WHILE cond:");
    print_node(node->lhs);
    fprintf(output, "body: ");
    print_node(node->rhs);
    fprintf(output, ")");
    return;
  }
  if (node->kind == ND_FOR) {
    fprintf(output, "(FOR init: ");
    print_node(node->lhs);
    fprintf(output, "cond: ");
    print_node(node->rhs);
    fprintf(output, " post: ");
    print_node(node->xhs);
    fprintf(output, " body ");
    print_node(node->nodes->data[0]);
    fprintf(output, ")");
    return;
  }
  if (node->kind == ND_BLOCK) {
    fprintf(output, "(BLOCK");
    if (node->nodes) {
      Vector *vec = node->nodes;
      int len = vec_len(vec);
      for (int i = 0; i < len; i++) {
        print_node(vec->data[i]);
        fprintf(output, ":");
      }
    }
    fprintf(output, ")");
    return;
  }
  if (node->kind == ND_LVAR) {
    fprintf(output, "(LVAR %d)", node->lvar->offset);
    return;
  }
  if (node->kind == ND_GVAR) {
    fprintf(output, "(GVAR %.*s)", node->token->len, node->token->str);
    return;
  }
  if (node->kind == ND_RETURN) {
    fprintf(output, "(RETURN ");
    print_node(node->lhs);
    fprintf(output, ")");
    return;
  }
  if (node->kind == ND_FDECL) {
    fprintf(output, "FDECL %.*s ", node->token->len, node->token->str);
    print_type(output, node->type);
    fprintf(output, " max_offset:%d\n//    ", node->offset);
    if (node->nodes) {
      Vector *params = node->nodes;
      int len = vec_len(params);
      for (int i = 0; i < len; i++) {
        print_node(params->data[i]);
        fprintf(output, " ");
      }
    }
    fprintf(output, "\n//    ");
    print_node(node->lhs);
    fprintf(output, ")");
    return;
  }
  error("print_node(): Unknown node.");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x4128
movq %rdi, %rbx
movl (%rdi), %edi
callq 0x193c
movl (%rbx), %ecx
testb %al, %al
je 0x4151
cmpl $0x13, %ecx
ja 0x4191
movl $0xfbff0, %eax          # imm = 0xFBFF0
btl %ecx, %eax
jae 0x4191
leaq 0xf150(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8c3c(%rip), %rsi      # 0xcd21
xorl %eax, %eax
callq 0x10f0
movq 0x8(%rbx), %rdi
callq 0x408c
leaq 0xf124(%rip), %r14      # 0x13220
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
movq 0x10(%rbx), %rdi
callq 0x408c
movq (%r14), %rsi
movl $0x29, %edi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10c0
leaq 0xf0f1(%rip), %rax      # 0x13220
movq (%rax), %rcx
leaq 0x8be2(%rip), %rdi      # 0xcd1b
movl $0x5, %esi
movl $0x1, %edx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1190
decl %ecx
cmpl $0x26, %ecx
ja 0x4744
leaq 0x8a99(%rip), %rax      # 0xcbfc
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0xf0ad(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
leaq 0x8c0f(%rip), %rsi      # 0xcd90
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0x8b90(%rip), %rdi      # 0xcd28
xorl %eax, %eax
callq 0x508c
jmp 0x40ec
leaq 0xf075(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8c16(%rip), %rdi      # 0xcdcb
movl $0xe, %esi
jmp 0x4641
leaq 0xf05a(%rip), %rax      # 0x13220
movq (%rax), %rcx
leaq 0x8ba5(%rip), %rdi      # 0xcd75
movl $0x9, %esi
jmp 0x413e
leaq 0xf03f(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8bb8(%rip), %rdi      # 0xcda3
movl $0x4, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
movq 0x10(%rbx), %rdi
callq 0x408c
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
movq 0x18(%rbx), %rdi
jmp 0x410d
leaq 0xefea(%rip), %r15      # 0x13220
movq (%r15), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8bdd(%rip), %rsi      # 0xce28
xorl %eax, %eax
callq 0x10f0
movq (%r15), %rdi
movq 0x58(%rbx), %rsi
callq 0x475b
movq (%r15), %rdi
movl 0x38(%rbx), %edx
leaq 0x8bc9(%rip), %rsi      # 0xce34
xorl %eax, %eax
callq 0x10f0
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x42ae
movq %r14, %rdi
callq 0x3f3a
testl %eax, %eax
jle 0x42ae
movl %eax, %r12d
xorl %r13d, %r13d
movq (%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x408c
movq (%r15), %rsi
movl $0x20, %edi
callq 0x10c0
incq %r13
cmpq %r13, %r12
jne 0x428d
movq (%r15), %rcx
leaq 0x8b8a(%rip), %rdi      # 0xce42
movl $0x7, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
movq (%r15), %rsi
jmp 0x4115
movq 0x8(%rbx), %rax
movq 0x50(%rax), %rax
leaq 0xef39(%rip), %r14      # 0x13220
movq (%r14), %rdi
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8a87(%rip), %rsi      # 0xcd7f
xorl %eax, %eax
callq 0x10f0
movq 0x48(%rbx), %rbx
movq %rbx, %rdi
callq 0x3f3a
testl %eax, %eax
jle 0x4336
movl %eax, %r15d
xorl %r12d, %r12d
movq (%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x408c
movq (%r14), %rsi
movl $0x3a, %edi
callq 0x10c0
incq %r12
cmpq %r12, %r15
jne 0x4315
movq (%r14), %rcx
leaq 0x8a4c(%rip), %rdi      # 0xcd8c
movl $0x3, %esi
jmp 0x413e
leaq 0xeecf(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8aa7(%rip), %rdi      # 0xce02
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq 0x48(%rbx), %rbx
testq %rbx, %rbx
je 0x4112
movq %rbx, %rdi
callq 0x3f3a
testl %eax, %eax
jle 0x4112
movl %eax, %r15d
xorl %r12d, %r12d
movq (%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x408c
movq (%r14), %rsi
movl $0x3a, %edi
callq 0x10c0
incq %r12
cmpq %r12, %r15
jne 0x438d
jmp 0x4112
leaq 0xee66(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8990(%rip), %rdi      # 0xcd54
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq (%r14), %rdi
movq 0x58(%rbx), %rsi
callq 0x475b
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
jmp 0x464b
leaq 0xee28(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8a1d(%rip), %rdi      # 0xce1f
movl $0x8, %esi
jmp 0x4641
movq 0x48(%rbx), %rbx
leaq 0xee09(%rip), %r14      # 0x13220
movq (%r14), %rsi
movl $0x7b, %edi
callq 0x10c0
movq %rbx, %rdi
callq 0x3f3a
testl %eax, %eax
jle 0x4467
movb $0x1, %al
xorl %r15d, %r15d
testb $0x1, %al
jne 0x4446
movq (%r14), %rsi
movl $0x2c, %edi
callq 0x10c0
movq (%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x408c
incq %r15
movq %rbx, %rdi
callq 0x3f3a
movslq %eax, %rcx
xorl %eax, %eax
cmpq %rcx, %r15
jl 0x4435
movq (%r14), %rsi
movl $0x7d, %edi
jmp 0x411a
leaq 0xeda5(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x891a(%rip), %rdi      # 0xcd9f
movl $0x3, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
jmp 0x40fc
leaq 0xed77(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x88a8(%rip), %rdi      # 0xcd5b
movl $0x8, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
movq (%r14), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
movl 0x38(%rbx), %r8d
leaq 0x8880(%rip), %rsi      # 0xcd64
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0xed25(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8886(%rip), %rsi      # 0xcd96
jmp 0x4670
leaq 0xed04(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x881f(%rip), %rdi      # 0xcd45
movl $0x6, %esi
jmp 0x4641
leaq 0xece9(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x880b(%rip), %rdi      # 0xcd4c
movl $0x7, %esi
jmp 0x4641
leaq 0xecce(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x887e(%rip), %rdi      # 0xcdda
movl $0xc, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
movq (%r14), %rcx
leaq 0x883a(%rip), %rdi      # 0xcdb8
jmp 0x46db
leaq 0xec96(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8853(%rip), %rdi      # 0xcde7
movl $0xb, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
movq (%r14), %rcx
leaq 0x87fa(%rip), %rdi      # 0xcdb0
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq 0x10(%rbx), %rdi
callq 0x408c
movq (%r14), %rcx
leaq 0x881b(%rip), %rdi      # 0xcdf3
movl $0x7, %esi
movl $0x1, %edx
callq 0x1190
movq 0x18(%rbx), %rdi
callq 0x408c
movq (%r14), %rcx
leaq 0x8801(%rip), %rdi      # 0xcdfb
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq 0x48(%rbx), %rax
movq (%rax), %rax
movq (%rax), %rdi
jmp 0x410d
leaq 0xec01(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8714(%rip), %rdi      # 0xcd3d
jmp 0x463c
leaq 0xebee(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8705(%rip), %rdi      # 0xcd41
movl $0x3, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
jmp 0x410d
leaq 0xebc5(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x87a3(%rip), %rsi      # 0xce13
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0xeb99(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x30(%rbx), %rax
movl 0x18(%rax), %edx
leaq 0x8771(%rip), %rsi      # 0xce09
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0xeb71(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8706(%rip), %rdi      # 0xcdbf
movl $0xb, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
movq (%r14), %rcx
leaq 0x86f8(%rip), %rdi      # 0xcdd3
movl $0x6, %esi
jmp 0x471a
leaq 0xeb37(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x86b5(%rip), %rdi      # 0xcda8
movl $0xe, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x408c
movq (%r14), %rcx
leaq 0x86a2(%rip), %rdi      # 0xcdb7
movl $0x7, %esi
movl $0x1, %edx
callq 0x1190
jmp 0x4109
leaq 0xeaf0(%rip), %rax      # 0x13220
movq (%rax), %rcx
leaq 0x8634(%rip), %rdi      # 0xcd6e
movl $0x6, %esi
jmp 0x413e
leaq 0x86ff(%rip), %rdi      # 0xce4a
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x508c