// File: /workspace/github_c_makefile_star2_O0/cogbee[P]vmir-latest/src/vmir_type.c
// Function: type_print
static int
type_print(char **dst, const ir_unit_t *iu, const ir_type_t *it)
{
  char tmpbuf[128];
  const char *append = "type-???";
  int len = 0;

  switch(it->it_code) {
  case IR_TYPE_VOID:       append = "void"; break;
  case IR_TYPE_INT1:       append = "i1"; break;
  case IR_TYPE_INT8:       append = "i8"; break;
  case IR_TYPE_INT16:      append = "i16"; break;
  case IR_TYPE_INT32:      append = "i32"; break;
  case IR_TYPE_INT64:      append = "i64"; break;
  case IR_TYPE_FLOAT:      append = "float"; break;
  case IR_TYPE_DOUBLE:     append = "double"; break;
  case IR_TYPE_METADATA:   append = "metadata"; break;
  case IR_TYPE_LABEL:      append = "label"; break;
  case IR_TYPE_OPAQUE:     append = "opaque"; break;

  case IR_TYPE_INTx:
    snprintf(tmpbuf, sizeof(tmpbuf), "i%d", it->it_bits);
    return addstr(dst, tmpbuf);

  case IR_TYPE_STRUCT:
    if(it->it_struct.name != NULL) {
      len += addstr(dst, it->it_struct.name);
      return len;
    }

    snprintf(tmpbuf, sizeof(tmpbuf), "struct {");

    len += addstr(dst, tmpbuf);

    for(int i = 0; i < it->it_struct.num_elements; i++) {
      if(i > 0)
        len += addstr(dst, " ");

      len += type_print_id(dst, iu, it->it_struct.elements[i].type);

      snprintf(tmpbuf, sizeof(tmpbuf), " @ %x",
               it->it_struct.elements[i].offset);
      len += addstr(dst, tmpbuf);
    }
    len += addstr(dst, "}");
    return len;

  case IR_TYPE_ARRAY:
    len += addstr(dst, "[ ");

    len += type_print_id(dst, iu, it->it_array.element_type);

    snprintf(tmpbuf, sizeof(tmpbuf), " x %d ]", it->it_array.num_elements);
    len += addstr(dst, tmpbuf);
    return len;

  case IR_TYPE_POINTER:
    if(it->it_pointer.pointee == -1) {
      len += addstr(dst, "void*");
    } else {
      len += type_print_id(dst, iu, it->it_pointer.pointee);
      len += addstr(dst, "*");
    }
    return len;

  case IR_TYPE_FUNCTION:
    len += type_print_id(dst, iu, it->it_function.return_type);
    len += addstr(dst, " (*)(");

    for(int i = 0; i < it->it_function.num_parameters; i++) {
      if(i > 0)
        len += addstr(dst, ", ");

      len += type_print_id(dst, iu, it->it_function.parameters[i]);
    }
    len += addstr(dst, ")");
    return len;
  }

  len += addstr(dst, append);
  return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq 0x25901(%rip), %rax     # 0x3e24f
movq %rax, -0xa8(%rbp)
movl $0x0, -0xac(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xc0(%rbp)
subq $0xf, %rax
ja 0x18dcd
movq -0xc0(%rbp), %rax
leaq 0x2426c(%rip), %rcx     # 0x3cbf0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x258c4(%rip), %rax     # 0x3e258
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x258b6(%rip), %rax     # 0x3e25d
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x258a6(%rip), %rax     # 0x3e260
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x25896(%rip), %rax     # 0x3e263
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x25ed5(%rip), %rax     # 0x3e8b5
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x25eec(%rip), %rax     # 0x3e8df
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x27780(%rip), %rax     # 0x40186
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x27753(%rip), %rax     # 0x4016c
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x2583b(%rip), %rax     # 0x3e267
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x25831(%rip), %rax     # 0x3e270
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq 0x25824(%rip), %rax     # 0x3e276
movq %rax, -0xa8(%rbp)
jmp 0x18dcd
leaq -0xa0(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x80, %esi
leaq 0x25805(%rip), %rdx     # 0x3e27d
movb $0x0, %al
callq 0x3180
movq -0x10(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x18e90
movl %eax, -0x4(%rbp)
jmp 0x18df2
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x18acd
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x18df2
leaq -0xa0(%rbp), %rdi
movl $0x80, %esi
leaq 0x257a1(%rip), %rdx     # 0x3e281
movb $0x0, %al
callq 0x3180
movq -0x10(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl $0x0, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x18bcd
cmpl $0x0, -0xb0(%rbp)
jle 0x18b45
movq -0x10(%rbp), %rdi
leaq 0x262ff(%rip), %rsi     # 0x3ee33
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xb0(%rbp), %rcx
movl (%rax,%rcx,8), %edx
callq 0x18ef0
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
leaq -0xa0(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xb0(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %ecx
movl $0x80, %esi
leaq 0x256f4(%rip), %rdx     # 0x3e28a
movb $0x0, %al
callq 0x3180
movq -0x10(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x18b0d
movq -0x10(%rbp), %rdi
leaq 0x262b7(%rip), %rsi     # 0x3ee8f
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x18df2
movq -0x10(%rbp), %rdi
leaq 0x2568e(%rip), %rsi     # 0x3e290
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x18ef0
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
leaq -0xa0(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %ecx
movl $0x80, %esi
leaq 0x25646(%rip), %rdx     # 0x3e293
movb $0x0, %al
callq 0x3180
movq -0x10(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x18df2
movq -0x20(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x18ca6
movq -0x10(%rbp), %rdi
leaq 0x25608(%rip), %rsi     # 0x3e29b
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
jmp 0x18ce2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x18ef0
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x255ce(%rip), %rsi     # 0x3e29f
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x18df2
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x18ef0
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x25586(%rip), %rsi     # 0x3e2a1
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x18da6
cmpl $0x0, -0xb4(%rbp)
jle 0x18d6a
movq -0x10(%rbp), %rdi
leaq 0x2554e(%rip), %rsi     # 0x3e2a7
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xb4(%rbp), %rcx
movl (%rax,%rcx,4), %edx
callq 0x18ef0
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x18d36
movq -0x10(%rbp), %rdi
leaq 0x25334(%rip), %rsi     # 0x3e0e5
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x18df2
movq -0x10(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x18e90
addl -0xac(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nop