// File: /workspace/github_c_makefile_star2_O2/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 0x1b3e0
movq %rcx, %r12
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %rbx
leal -0x1(%r15), %eax
cmpl $0x14, %eax
ja 0x1b467
leaq 0x4866(%rip), %rcx      # 0x1f9f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
je 0x1b3ff
movq (%r12), %rax
cmpq 0x178(%rbx), %rax
jbe 0x1b2de
movq %rax, 0x178(%rbx)
imulq $0x28, %rax, %rsi
movq 0x168(%rbx), %rdi
callq 0x33c0
movq %rax, 0x168(%rbx)
jmp 0x1b2de
movq 0x1a0(%rbx), %rax
movq %rax, 0x10(%rsp)
andq $0x0, 0x1a0(%rbx)
jmp 0x1b203
movl (%r12), %eax
movq 0x8(%r12), %r15
shlq $0x20, %r15
orq %rax, %r15
pushq $0xa
jmp 0x1b25e
movq $0x0, 0x10(%rsp)
decl %r14d
movslq %r14d, %rbp
leaq (,%rbp,8), %rdi
callq 0x3380
movq %rax, %r15
movq (%r12), %rax
xorl %ecx, %ecx
testl %ebp, %ebp
cmovlel %ecx, %ebp
cmpq %rcx, %rbp
je 0x1b237
movl 0x8(%r12,%rcx,8), %edx
movl %edx, (%r15,%rcx,8)
incq %rcx
jmp 0x1b224
movq %r14, 0x8(%rsp)
testq %rax, %rax
setne %bpl
xorl %r14d, %r14d
jmp 0x1b274
pushq $0xe
jmp 0x1b26d
pushq $0x1
jmp 0x1b26d
pushq $0xf
jmp 0x1b26d
pushq $0x8
jmp 0x1b26d
movl (%r12), %r15d
pushq $0xb
popq %r14
movq %rax, 0x8(%rsp)
jmp 0x1b274
pushq $0x9
jmp 0x1b26d
pushq $0xd
popq %r14
movq %rax, 0x8(%rsp)
movq 0x168(%rbx), %rax
movq 0x170(%rbx), %r13
leaq 0x1(%r13), %r12
cmpq 0x178(%rbx), %r12
jbe 0x1b2ad
leaq (%r12,%r12), %rcx
movq %rcx, 0x178(%rbx)
imulq $0x50, %r12, %rsi
movq %rax, %rdi
callq 0x33c0
movq %rax, 0x168(%rbx)
movq 0x10(%rsp), %rdx
movq %r12, 0x170(%rbx)
imulq $0x28, %r13, %rcx
movl %r14d, (%rax,%rcx)
movq %r15, 0x8(%rax,%rcx)
movq %rdx, 0x10(%rax,%rcx)
movq 0x8(%rsp), %rdx
movl %edx, 0x18(%rax,%rcx)
movb %bpl, 0x24(%rax,%rcx)
movb $0x0, 0x25(%rax,%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %r9
cmpq $0x1, %r9
je 0x1b3d9
cmpq $0x40, %r9
je 0x1b3b0
cmpq $0x10, %r9
je 0x1b3be
cmpq $0x20, %r9
je 0x1b3b7
cmpq $0x8, %r9
jne 0x1b3c5
pushq $0x3
jmp 0x1b26d
movq 0x1a0(%rbx), %rdi
callq 0x3030
movl %r14d, %edi
movq %r12, %rsi
callq 0x1b56c
movq %rax, 0x1a0(%rbx)
jmp 0x1b2de
cmpl $0x1, %r14d
jbe 0x1b423
movq (%r12), %r13
movl 0x8(%r12), %eax
addl $-0x2, %r14d
movq %r14, %rcx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movslq %r14d, %r14
leaq (,%r14,4), %rdi
callq 0x3380
movq %rax, %r15
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
cmpq %rax, %r14
je 0x1b39f
movl 0x10(%r12,%rax,8), %ecx
movl %ecx, (%r15,%rax,4)
incq %rax
jmp 0x1b38c
pushq $0xc
popq %r14
movl %r13d, %eax
movq %rax, 0x8(%rsp)
jmp 0x1b274
pushq $0x6
jmp 0x1b26d
pushq $0x5
jmp 0x1b26d
pushq $0x4
jmp 0x1b26d
cmpq $0x3f, %r9
jg 0x1b499
movl %r9d, %r15d
pushq $0x7
jmp 0x1b25e
pushq $0x2
jmp 0x1b26d
leaq 0x7a69(%rip), %rdi      # 0x22e50
leaq 0x7352(%rip), %rsi      # 0x22740
leaq 0x7a75(%rip), %rcx      # 0x22e6a
movl $0x2f7, %edx            # imm = 0x2F7
callq 0x31e0
leaq 0x733a(%rip), %rsi      # 0x22740
leaq 0x7aae(%rip), %rcx      # 0x22ebb
leaq 0x7a36(%rip), %r8       # 0x22e4a
movq %rbx, %rdi
movl $0x2fc, %edx            # imm = 0x2FC
xorl %eax, %eax
callq 0xbed2
leaq 0x7316(%rip), %rsi      # 0x22740
leaq 0x7acb(%rip), %rcx      # 0x22efc
leaq 0x7a12(%rip), %r8       # 0x22e4a
movq %rbx, %rdi
movl $0x344, %edx            # imm = 0x344
movl %r14d, %r9d
jmp 0x1b492
movl 0x8(%r12), %esi
movq %rbx, %rdi
callq 0x105cd
movl (%r12), %edx
leaq 0x7acc(%rip), %rdi      # 0x22f29
movq %rax, %rsi
xorl %eax, %eax
callq 0x3190
movq %r12, %rdi
movl %r14d, %esi
callq 0x1b5a2
leaq 0x72c7(%rip), %rsi      # 0x22740
leaq 0x7abc(%rip), %rcx      # 0x22f3c
leaq 0x79c3(%rip), %r8       # 0x22e4a
movq %rbx, %rdi
movl $0x365, %edx            # imm = 0x365
movl %r15d, %r9d
xorl %eax, %eax
callq 0xbed2
leaq 0x72a0(%rip), %rsi      # 0x22740
leaq 0x7a2e(%rip), %rcx      # 0x22ed5
leaq 0x799c(%rip), %r8       # 0x22e4a
movq %rbx, %rdi
movl $0x31a, %edx            # imm = 0x31A
jmp 0x1b492