// File: /workspace/github_c_makefile_star2_O1/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 0x414c
movq %rdi, %rbx
movl (%rdi), %edi
callq 0x193c
movl (%rbx), %ecx
testb %al, %al
je 0x4175
cmpl $0x13, %ecx
ja 0x41b5
movl $0xfbff0, %eax          # imm = 0xFBFF0
btl %ecx, %eax
jae 0x41b5
leaq 0xf12c(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8c18(%rip), %rsi      # 0xcd21
xorl %eax, %eax
callq 0x10f0
movq 0x8(%rbx), %rdi
callq 0x40b0
leaq 0xf100(%rip), %r14      # 0x13220
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
movq 0x10(%rbx), %rdi
callq 0x40b0
movq (%r14), %rsi
movl $0x29, %edi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10c0
leaq 0xf0cd(%rip), %rax      # 0x13220
movq (%rax), %rcx
leaq 0x8bbe(%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 0x4768
leaq 0x8a75(%rip), %rax      # 0xcbfc
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0xf089(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
leaq 0x8beb(%rip), %rsi      # 0xcd90
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0x8b6c(%rip), %rdi      # 0xcd28
xorl %eax, %eax
callq 0x50b0
jmp 0x4110
leaq 0xf051(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8bf2(%rip), %rdi      # 0xcdcb
movl $0xe, %esi
jmp 0x4665
leaq 0xf036(%rip), %rax      # 0x13220
movq (%rax), %rcx
leaq 0x8b81(%rip), %rdi      # 0xcd75
movl $0x9, %esi
jmp 0x4162
leaq 0xf01b(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8b94(%rip), %rdi      # 0xcda3
movl $0x4, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
movq 0x10(%rbx), %rdi
callq 0x40b0
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
movq 0x18(%rbx), %rdi
jmp 0x4131
leaq 0xefc6(%rip), %r15      # 0x13220
movq (%r15), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8bb9(%rip), %rsi      # 0xce28
xorl %eax, %eax
callq 0x10f0
movq (%r15), %rdi
movq 0x58(%rbx), %rsi
callq 0x477f
movq (%r15), %rdi
movl 0x38(%rbx), %edx
leaq 0x8ba5(%rip), %rsi      # 0xce34
xorl %eax, %eax
callq 0x10f0
movq 0x48(%rbx), %r14
testq %r14, %r14
je 0x42d2
movq %r14, %rdi
callq 0x3f62
testl %eax, %eax
jle 0x42d2
movl %eax, %r12d
xorl %r13d, %r13d
movq (%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x40b0
movq (%r15), %rsi
movl $0x20, %edi
callq 0x10c0
incq %r13
cmpq %r13, %r12
jne 0x42b1
movq (%r15), %rcx
leaq 0x8b66(%rip), %rdi      # 0xce42
movl $0x7, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
movq (%r15), %rsi
jmp 0x4139
movq 0x8(%rbx), %rax
movq 0x50(%rax), %rax
leaq 0xef15(%rip), %r14      # 0x13220
movq (%r14), %rdi
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8a63(%rip), %rsi      # 0xcd7f
xorl %eax, %eax
callq 0x10f0
movq 0x48(%rbx), %rbx
movq %rbx, %rdi
callq 0x3f62
testl %eax, %eax
jle 0x435a
movl %eax, %r15d
xorl %r12d, %r12d
movq (%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x40b0
movq (%r14), %rsi
movl $0x3a, %edi
callq 0x10c0
incq %r12
cmpq %r12, %r15
jne 0x4339
movq (%r14), %rcx
leaq 0x8a28(%rip), %rdi      # 0xcd8c
movl $0x3, %esi
jmp 0x4162
leaq 0xeeab(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8a83(%rip), %rdi      # 0xce02
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq 0x48(%rbx), %rbx
testq %rbx, %rbx
je 0x4136
movq %rbx, %rdi
callq 0x3f62
testl %eax, %eax
jle 0x4136
movl %eax, %r15d
xorl %r12d, %r12d
movq (%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x40b0
movq (%r14), %rsi
movl $0x3a, %edi
callq 0x10c0
incq %r12
cmpq %r12, %r15
jne 0x43b1
jmp 0x4136
leaq 0xee42(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x896c(%rip), %rdi      # 0xcd54
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq (%r14), %rdi
movq 0x58(%rbx), %rsi
callq 0x477f
movq (%r14), %rsi
movl $0x20, %edi
callq 0x10c0
jmp 0x466f
leaq 0xee04(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x89f9(%rip), %rdi      # 0xce1f
movl $0x8, %esi
jmp 0x4665
movq 0x48(%rbx), %rbx
leaq 0xede5(%rip), %r14      # 0x13220
movq (%r14), %rsi
movl $0x7b, %edi
callq 0x10c0
movq %rbx, %rdi
callq 0x3f62
testl %eax, %eax
jle 0x448b
movb $0x1, %al
xorl %r15d, %r15d
testb $0x1, %al
jne 0x446a
movq (%r14), %rsi
movl $0x2c, %edi
callq 0x10c0
movq (%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x40b0
incq %r15
movq %rbx, %rdi
callq 0x3f62
movslq %eax, %rcx
xorl %eax, %eax
cmpq %rcx, %r15
jl 0x4459
movq (%r14), %rsi
movl $0x7d, %edi
jmp 0x413e
leaq 0xed81(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x88f6(%rip), %rdi      # 0xcd9f
movl $0x3, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
jmp 0x4120
leaq 0xed53(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8884(%rip), %rdi      # 0xcd5b
movl $0x8, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
movq (%r14), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
movl 0x38(%rbx), %r8d
leaq 0x885c(%rip), %rsi      # 0xcd64
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0xed01(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x8862(%rip), %rsi      # 0xcd96
jmp 0x4694
leaq 0xece0(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x87fb(%rip), %rdi      # 0xcd45
movl $0x6, %esi
jmp 0x4665
leaq 0xecc5(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x87e7(%rip), %rdi      # 0xcd4c
movl $0x7, %esi
jmp 0x4665
leaq 0xecaa(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x885a(%rip), %rdi      # 0xcdda
movl $0xc, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
movq (%r14), %rcx
leaq 0x8816(%rip), %rdi      # 0xcdb8
jmp 0x46ff
leaq 0xec72(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x882f(%rip), %rdi      # 0xcde7
movl $0xb, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
movq (%r14), %rcx
leaq 0x87d6(%rip), %rdi      # 0xcdb0
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq 0x10(%rbx), %rdi
callq 0x40b0
movq (%r14), %rcx
leaq 0x87f7(%rip), %rdi      # 0xcdf3
movl $0x7, %esi
movl $0x1, %edx
callq 0x1190
movq 0x18(%rbx), %rdi
callq 0x40b0
movq (%r14), %rcx
leaq 0x87dd(%rip), %rdi      # 0xcdfb
movl $0x6, %esi
movl $0x1, %edx
callq 0x1190
movq 0x48(%rbx), %rax
movq (%rax), %rax
movq (%rax), %rdi
jmp 0x4131
leaq 0xebdd(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x86f0(%rip), %rdi      # 0xcd3d
jmp 0x4660
leaq 0xebca(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x86e1(%rip), %rdi      # 0xcd41
movl $0x3, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
jmp 0x4131
leaq 0xeba1(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x50(%rbx), %rax
movl 0x28(%rax), %edx
movq 0x20(%rax), %rcx
leaq 0x877f(%rip), %rsi      # 0xce13
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0xeb75(%rip), %rax      # 0x13220
movq (%rax), %rdi
movq 0x30(%rbx), %rax
movl 0x18(%rax), %edx
leaq 0x874d(%rip), %rsi      # 0xce09
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x10f0
leaq 0xeb4d(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x86e2(%rip), %rdi      # 0xcdbf
movl $0xb, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
movq (%r14), %rcx
leaq 0x86d4(%rip), %rdi      # 0xcdd3
movl $0x6, %esi
jmp 0x473e
leaq 0xeb13(%rip), %r14      # 0x13220
movq (%r14), %rcx
leaq 0x8691(%rip), %rdi      # 0xcda8
movl $0xe, %esi
movl $0x1, %edx
callq 0x1190
movq 0x8(%rbx), %rdi
callq 0x40b0
movq (%r14), %rcx
leaq 0x867e(%rip), %rdi      # 0xcdb7
movl $0x7, %esi
movl $0x1, %edx
callq 0x1190
jmp 0x412d
leaq 0xeacc(%rip), %rax      # 0x13220
movq (%rax), %rcx
leaq 0x8610(%rip), %rdi      # 0xcd6e
movl $0x6, %esi
jmp 0x4162
leaq 0x86db(%rip), %rdi      # 0xce4a
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x50b0