// File: /workspace/github_c_makefile_star2_O1/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 0x1fd16
movq %rcx, %r15
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %rbx
leal -0x1(%r12), %eax
cmpl $0x14, %eax
ja 0x1fd9b
leaq 0x4da4(%rip), %rcx      # 0x24810
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
je 0x1fd35
movq (%r15), %rax
cmpq 0x178(%rbx), %rax
jbe 0x1fbe6
movq %rax, 0x178(%rbx)
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
movq 0x168(%rbx), %rdi
callq 0x33c0
movq %rax, 0x168(%rbx)
jmp 0x1fbe6
movq 0x1a0(%rbx), %rbp
movq $0x0, 0x1a0(%rbx)
jmp 0x1fae0
movl (%r15), %eax
movq 0x8(%r15), %r12
shlq $0x20, %r12
orq %rax, %r12
movl $0xa, %edi
jmp 0x1fb4e
xorl %ebp, %ebp
decl %r14d
movslq %r14d, %r13
leaq (,%r13,8), %rdi
callq 0x3380
movq %rax, %r12
cmpq $0x0, (%r15)
setne %sil
testl %r13d, %r13d
movq %rbp, 0x10(%rsp)
jle 0x1fcc4
movl %r14d, %eax
xorl %edi, %edi
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 0x1fb13
jmp 0x1fb5c
movl $0xe, %edi
jmp 0x1fb5c
movl $0x1, %edi
jmp 0x1fb5c
movl $0xf, %edi
jmp 0x1fb5c
movl $0x8, %edi
jmp 0x1fb5c
movl (%r15), %r12d
movl $0xb, %edi
jmp 0x1fb5c
movl $0x9, %edi
jmp 0x1fb5c
movl $0xd, %edi
movq 0x170(%rbx), %r15
leaq 0x1(%r15), %rbp
cmpq 0x178(%rbx), %rbp
jbe 0x1fbb3
leaq (,%rbp,2), %rax
movq %rax, 0x178(%rbx)
movq %rbp, %rax
shlq $0x4, %rax
movb %sil, 0xf(%rsp)
leaq (%rax,%rax,4), %rsi
movq %r14, %r13
movq %rdi, %r14
movq 0x168(%rbx), %rdi
callq 0x33c0
movq %r14, %rdi
movq %r13, %r14
movb 0xf(%rsp), %sil
movq %rax, 0x168(%rbx)
movq %rbp, 0x170(%rbx)
movq 0x168(%rbx), %rax
leaq (%r15,%r15,4), %rcx
movl %edi, (%rax,%rcx,8)
movq %r12, 0x8(%rax,%rcx,8)
movq 0x10(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movl %r14d, 0x18(%rax,%rcx,8)
movb %sil, 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 0x1fccb
cmpq $0x10, %r9
je 0x1fce1
cmpq $0x20, %r9
je 0x1fceb
cmpq $0x40, %r9
jne 0x1fcff
movl $0x6, %edi
jmp 0x1fb5c
movq 0x1a0(%rbx), %rdi
callq 0x3030
leal 0x1(%r14), %edi
callq 0x3380
movl %r14d, %ecx
movb $0x0, (%rax,%rcx)
testl %r14d, %r14d
je 0x1fc5d
xorl %edx, %edx
movb (%r15,%rdx,8), %sil
movb %sil, (%rax,%rdx)
incq %rdx
cmpq %rdx, %rcx
jne 0x1fc4d
movq %rax, 0x1a0(%rbx)
jmp 0x1fbe6
cmpl $0x1, %r14d
jbe 0x1fd59
movl (%r15), %r13d
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, %edi
testl %ebp, %ebp
jle 0x1fcbc
movl %r14d, %eax
xorl %ecx, %ecx
movl 0x10(%r15,%rcx,8), %edx
movl %edx, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1fcab
movl %r13d, %r14d
jmp 0x1fb5c
xorl %edi, %edi
jmp 0x1fb5c
cmpq $0x1, %r9
je 0x1fcf5
cmpq $0x8, %r9
jne 0x1fcff
movl $0x3, %edi
jmp 0x1fb5c
movl $0x4, %edi
jmp 0x1fb5c
movl $0x5, %edi
jmp 0x1fb5c
movl $0x2, %edi
jmp 0x1fb5c
cmpq $0x3f, %r9
jg 0x1fdcd
movl %r9d, %r12d
movl $0x7, %edi
jmp 0x1fb4e
leaq 0x7f7e(%rip), %rdi      # 0x27c9b
leaq 0x7867(%rip), %rsi      # 0x2758b
leaq 0x7f8a(%rip), %rcx      # 0x27cb5
movl $0x2f7, %edx            # imm = 0x2F7
callq 0x31e0
leaq 0x784f(%rip), %rsi      # 0x2758b
leaq 0x7fc3(%rip), %rcx      # 0x27d06
leaq 0x7f4b(%rip), %r8       # 0x27c95
movq %rbx, %rdi
movl $0x2fc, %edx            # imm = 0x2FC
xorl %eax, %eax
callq 0xca73
leaq 0x782b(%rip), %rsi      # 0x2758b
leaq 0x7fe0(%rip), %rcx      # 0x27d47
leaq 0x7f27(%rip), %r8       # 0x27c95
movq %rbx, %rdi
movl $0x344, %edx            # imm = 0x344
movl %r14d, %r9d
jmp 0x1fdc6
movl 0x8(%r15), %esi
movq %rbx, %rdi
callq 0x12335
movl (%r15), %edx
leaq 0x7fe3(%rip), %rdi      # 0x27d74
movq %rax, %rsi
xorl %eax, %eax
callq 0x3190
movq %r15, %rdi
movl %r14d, %esi
callq 0x1fef9
leaq 0x77de(%rip), %rsi      # 0x2758b
leaq 0x7fd3(%rip), %rcx      # 0x27d87
leaq 0x7eda(%rip), %r8       # 0x27c95
movq %rbx, %rdi
movl $0x365, %edx            # imm = 0x365
movl %r12d, %r9d
xorl %eax, %eax
callq 0xca73
leaq 0x77b7(%rip), %rsi      # 0x2758b
leaq 0x7f45(%rip), %rcx      # 0x27d20
leaq 0x7eb3(%rip), %r8       # 0x27c95
movq %rbx, %rdi
movl $0x31a, %edx            # imm = 0x31A
jmp 0x1fdc6