// File: /workspace/github_c_makefile_star2_O3/cogbee[P]vmir-latest/src/vmir_bitcode_parser.c
// Function: types_new_rec_handler
static void
types_new_rec_handler(struct ir_unit *iu, int op,
                      unsigned int argc, const int64_t *argv)
{
  ir_type_t it;
  const char *ctx = "types";

  assert(iu->iu_types_created == 0);

  switch(op) {
  case TYPE_CODE_NUMENTRY:
    if(argc < 1)
      parser_error(iu, "%s: Short NUMENTRY record", ctx);

    VECTOR_SET_CAPACITY(&iu->iu_types, argv[0]);
    return;

  case TYPE_CODE_VOID:
    it.it_code = IR_TYPE_VOID;
    break;
  case TYPE_CODE_FLOAT:
    it.it_code = IR_TYPE_FLOAT;
    break;
  case TYPE_CODE_DOUBLE:
    it.it_code = IR_TYPE_DOUBLE;
    break;
  case TYPE_CODE_INTEGER:
    if(argv[0] == 1) {
      it.it_code = IR_TYPE_INT1;
    } else if(argv[0] == 8) {
      it.it_code = IR_TYPE_INT8;
    } else if(argv[0] == 16) {
      it.it_code = IR_TYPE_INT16;
    } else if(argv[0] == 32) {
      it.it_code = IR_TYPE_INT32;
    } else if(argv[0] == 64) {
      it.it_code = IR_TYPE_INT64;
    } else if(argv[0] < 64) {
      it.it_code = IR_TYPE_INTx;
      it.it_bits = argv[0];
    } else {
      parser_error(iu, "%s: Integer width %d bit not supported",
                   ctx, (int)argv[0]);
    }
    break;
  case TYPE_CODE_ARRAY:
    it.it_code = IR_TYPE_ARRAY;
    it.it_array.num_elements = argv[0];
    it.it_array.element_type = argv[1];
    break;

  case TYPE_CODE_STRUCT_NAME:
    free(iu->iu_current_struct_name);
    iu->iu_current_struct_name = read_str_from_argv(argc, argv);
    return;

  case TYPE_CODE_STRUCT_NAMED:

    it.it_struct.name = iu->iu_current_struct_name;
    iu->iu_current_struct_name = NULL;

    if(0)
  case TYPE_CODE_STRUCT_ANON:
      it.it_struct.name = NULL;

    it.it_code = IR_TYPE_STRUCT;
    it.it_struct.computed = 0;
    it.it_struct.num_elements = argc - 1;
    it.it_struct.elements = malloc(it.it_struct.num_elements *
                                   sizeof(it.it_struct.elements[0]));
    it.it_struct.packed = !!argv[0];
    for(int i = 0; i < it.it_struct.num_elements; i++) {
      it.it_struct.elements[i].type = argv[i + 1];
    }
    break;

  case TYPE_CODE_POINTER:
    it.it_code = IR_TYPE_POINTER;
    it.it_pointer.pointee = argv[0];
    break;

  case TYPE_CODE_FUNCTION:
    if(argc < 2)
      parser_error(iu, "%s: Invalid # of args (%d) for function type",
                   ctx, argc);

    it.it_code = IR_TYPE_FUNCTION;
    it.it_function.varargs = argv[0];
    it.it_function.return_type = argv[1];
    it.it_function.num_parameters = argc - 2;
    it.it_function.parameters =
      malloc(it.it_function.num_parameters * sizeof(int));
    for(int i = 0; i < it.it_function.num_parameters; i++)
      it.it_function.parameters[i] = argv[2 + i];
    break;

  case TYPE_CODE_METADATA:
    it.it_code = IR_TYPE_METADATA;
    break;

  case TYPE_CODE_LABEL:
    it.it_code = IR_TYPE_LABEL;
    break;

  case TYPE_CODE_OPAQUE:
    it.it_code = IR_TYPE_OPAQUE;
    break;

  case TYPE_CODE_VECTOR:
    printf("Vector of %s x %d\n",
           type_str_index(iu, argv[1]),
           (int)argv[0]);

           //    break;

  default:
    printargs(argv, argc);
    parser_error(iu, "%s: Unknown op %d", ctx, op);
  }

  VECTOR_PUSH_BACK(&iu->iu_types, it);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl $0x0, 0x368(%rdi)
jne 0x1fee5
movq %rcx, %r15
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %rbx
leal -0x1(%r12), %eax
cmpl $0x14, %eax
ja 0x1ff6a
leaq 0x4c57(%rip), %rcx      # 0x2487c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
je 0x1ff04
movq (%r15), %rax
cmpq 0x178(%rbx), %rax
jbe 0x1fd9c
movq %rax, 0x178(%rbx)
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
movq 0x168(%rbx), %rdi
callq 0x33c0
movq %rax, 0x168(%rbx)
jmp 0x1fd9c
movq 0x1a0(%rbx), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x1a0(%rbx)
jmp 0x1fca6
movl (%r15), %eax
movq 0x8(%r15), %r12
shlq $0x20, %r12
orq %rax, %r12
movl $0xa, %r13d
jmp 0x1fd18
movq $0x0, 0x10(%rsp)
decl %r14d
movslq %r14d, %r13
leaq (,%r13,8), %rdi
callq 0x3380
movq %rax, %r12
cmpq $0x0, (%r15)
setne %al
testl %r13d, %r13d
movb %al, 0xc(%rsp)
jle 0x1fe81
movl %r14d, %eax
xorl %r13d, %r13d
xorl %ecx, %ecx
movl 0x8(%r15,%rcx,8), %edx
movl %edx, (%r12,%rcx,8)
leaq 0x1(%rcx), %rdx
movq %rdx, %rcx
cmpq %rdx, %rax
jne 0x1fcd8
jmp 0x1fd28
movl $0xe, %r13d
jmp 0x1fd28
movl $0x1, %r13d
jmp 0x1fd28
movl $0xf, %r13d
jmp 0x1fd28
movl $0x8, %r13d
jmp 0x1fd28
movl (%r15), %r12d
movl $0xb, %r13d
jmp 0x1fd28
movl $0x9, %r13d
jmp 0x1fd28
movl $0xd, %r13d
movq 0x168(%rbx), %rax
movq 0x170(%rbx), %r15
leaq 0x1(%r15), %rbp
cmpq 0x178(%rbx), %rbp
jbe 0x1fd6c
leaq (,%rbp,2), %rcx
movq %rcx, 0x178(%rbx)
movq %rbp, %rcx
shlq $0x4, %rcx
leaq (%rcx,%rcx,4), %rsi
movq %rax, %rdi
callq 0x33c0
movq %rax, 0x168(%rbx)
movq 0x10(%rsp), %rdx
movq %rbp, 0x170(%rbx)
leaq (%r15,%r15,4), %rcx
movl %r13d, (%rax,%rcx,8)
movq %r12, 0x8(%rax,%rcx,8)
movq %rdx, 0x10(%rax,%rcx,8)
movl %r14d, 0x18(%rax,%rcx,8)
movb 0xc(%rsp), %dl
movb %dl, 0x24(%rax,%rcx,8)
movb $0x0, 0x25(%rax,%rcx,8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %r9
cmpq $0xf, %r9
jle 0x1fe89
cmpq $0x10, %r9
je 0x1feac
cmpq $0x20, %r9
je 0x1feb7
cmpq $0x40, %r9
jne 0x1fecd
movl $0x6, %r13d
jmp 0x1fd28
movq 0x1a0(%rbx), %rdi
callq 0x3030
leal 0x1(%r14), %edi
callq 0x3380
movl %r14d, %ecx
movb $0x0, (%rax,%rcx)
testl %r14d, %r14d
je 0x1fe14
xorl %edx, %edx
movb (%r15,%rdx,8), %sil
movb %sil, (%rax,%rdx)
incq %rdx
cmpq %rdx, %rcx
jne 0x1fe04
movq %rax, 0x1a0(%rbx)
jmp 0x1fd9c
cmpl $0x1, %r14d
jbe 0x1ff28
movl (%r15), %eax
movl %eax, 0xc(%rsp)
movl 0x8(%r15), %eax
addl $-0x2, %r14d
movq %r14, %rcx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movslq %r14d, %rbp
leaq (,%rbp,4), %rdi
callq 0x3380
movq %rax, %r12
movl $0xc, %r13d
testl %ebp, %ebp
jle 0x1fea0
movl 0xc(%rsp), %edx
xorl %eax, %eax
movl 0x10(%r15,%rax,8), %ecx
movl %ecx, (%r12,%rax,4)
incq %rax
cmpq %rax, %r14
jne 0x1fe6b
movl %edx, %r14d
jmp 0x1fea7
xorl %r13d, %r13d
jmp 0x1fd28
cmpq $0x1, %r9
je 0x1fec2
cmpq $0x8, %r9
jne 0x1fecd
movl $0x3, %r13d
jmp 0x1fd28
movl 0xc(%rsp), %eax
movl %eax, %r14d
jmp 0x1fd28
movl $0x4, %r13d
jmp 0x1fd28
movl $0x5, %r13d
jmp 0x1fd28
movl $0x2, %r13d
jmp 0x1fd28
cmpq $0x3f, %r9
jg 0x1ff9c
movl %r9d, %r12d
movl $0x7, %r13d
jmp 0x1fd18
leaq 0x7df9(%rip), %rdi      # 0x27ce5
leaq 0x76e2(%rip), %rsi      # 0x275d5
leaq 0x7e05(%rip), %rcx      # 0x27cff
movl $0x2f7, %edx            # imm = 0x2F7
callq 0x31e0
leaq 0x76ca(%rip), %rsi      # 0x275d5
leaq 0x7e3e(%rip), %rcx      # 0x27d50
leaq 0x7dc6(%rip), %r8       # 0x27cdf
movq %rbx, %rdi
movl $0x2fc, %edx            # imm = 0x2FC
xorl %eax, %eax
callq 0xca98
leaq 0x76a6(%rip), %rsi      # 0x275d5
leaq 0x7e5b(%rip), %rcx      # 0x27d91
leaq 0x7da2(%rip), %r8       # 0x27cdf
movq %rbx, %rdi
movl $0x344, %edx            # imm = 0x344
movl %r14d, %r9d
jmp 0x1ff95
movl 0x8(%r15), %esi
movq %rbx, %rdi
callq 0x120fa
movl (%r15), %edx
leaq 0x7e5e(%rip), %rdi      # 0x27dbe
movq %rax, %rsi
xorl %eax, %eax
callq 0x3190
movq %r15, %rdi
movl %r14d, %esi
callq 0x200c8
leaq 0x7659(%rip), %rsi      # 0x275d5
leaq 0x7e4e(%rip), %rcx      # 0x27dd1
leaq 0x7d55(%rip), %r8       # 0x27cdf
movq %rbx, %rdi
movl $0x365, %edx            # imm = 0x365
movl %r12d, %r9d
xorl %eax, %eax
callq 0xca98
leaq 0x7632(%rip), %rsi      # 0x275d5
leaq 0x7dc0(%rip), %rcx      # 0x27d6a
leaq 0x7d2e(%rip), %r8       # 0x27cdf
movq %rbx, %rdi
movl $0x31a, %edx            # imm = 0x31A
jmp 0x1ff95