// File: /workspace/github_c_makefile_star2_O0/pocari[P]compilerbook-9cc/debug.c
// Function: type_info_helper
int type_info_helper(char *buf, int offset, Type *type) {
  int n = 0;

  #pragma clang diagnostic ignored "-Wswitch"
  switch (type->kind) {
    case TY_VOID:
      n += sprintf(buf + offset, "void");
      break;
    case TY_INT:
      n += sprintf(buf + offset, "int");
      break;
    case TY_CHAR:
      n += sprintf(buf + offset, "char");
      break;
    case TY_SHORT:
      n += sprintf(buf + offset, "short");
      break;
    case TY_LONG:
      n += sprintf(buf + offset, "long");
      break;
    case TY_PTR:
      n += sprintf(buf + offset, "*");
      n += type_info_helper(buf, offset + n, type->ptr_to);
      break;
    case TY_ARRAY:
      // int x[2][3]と宣言された配列の場合
      //
      // TY_ARRAY
      // array_size: 2
      // ptr_to ---------> TY_ARRAY
      //                   array_size: 3
      //                   ptr_to   --------> TY_INT
      //
      // と、「「intのサイズ3の配列」のサイズ2の配列」という構造になるので、
      n += sprintf(buf + offset, "[%ld]", type->array_size);
      n += type_info_helper(buf, offset + n, type->ptr_to);
      break;
    case TY_STRUCT:
      n += sprintf(buf + offset, "struct (size %d) {", type->size);
      for (Member *m = type->members; m; m = m->next) {
        n += type_info_helper(buf, offset + n, m->ty);
        n += sprintf(buf + offset + n, " %s (offset %d)", m->name, m->offset);
        if (m->next) {
          n += sprintf(buf + offset + n, " ");
        }
      }
      n += sprintf(buf + offset + n, "}");
      break;
  }
  return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x8, %eax
ja 0x479a
movq -0x30(%rbp), %rax
leaq 0xba7c(%rip), %rcx      # 0xffd8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
leaq 0xbce9(%rip), %rsi      # 0x10260
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x479a
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
leaq 0xbcca(%rip), %rsi      # 0x10265
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x479a
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
leaq 0xbcaa(%rip), %rsi      # 0x10269
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x479a
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
leaq 0xbc8b(%rip), %rsi      # 0x1026e
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x479a
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
leaq 0xbc6d(%rip), %rsi      # 0x10274
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x479a
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
leaq 0xc7e9(%rip), %rsi      # 0x10e14
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x4520
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x479a
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdx
leaq 0xbc05(%rip), %rsi      # 0x10279
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x4520
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x479a
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
leaq 0xbbc3(%rip), %rsi      # 0x1027f
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4774
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
addl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4520
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x28(%rbp), %rax
movl 0x18(%rax), %ecx
leaq 0xbb6d(%rip), %rsi      # 0x10292
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x4762
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
leaq 0xb334(%rip), %rsi      # 0xfa89
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x4764
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x46d5
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
leaq 0xbb15(%rip), %rsi      # 0x102a2
movb $0x0, %al
callq 0x2190
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)