// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
leaq 0xbe88(%rip), %rax      # 0x40f85
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x368(%rax)
jne 0x35110
jmp 0x3512f
leaq 0xbe74(%rip), %rdi      # 0x40f8b
leaq 0xb746(%rip), %rsi      # 0x40864
movl $0x2f7, %edx            # imm = 0x2F7
leaq 0xbe7b(%rip), %rcx      # 0x40fa5
callq 0x31c0
movl -0xc(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x14, %eax
ja 0x354b4
movq -0x70(%rbp), %rax
leaq 0x8d56(%rip), %rcx      # 0x3dea4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x1, -0x10(%rbp)
jae 0x3517f
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %r8
leaq 0xb6f8(%rip), %rsi      # 0x40864
movl $0x2fc, %edx            # imm = 0x2FC
leaq 0xbe7e(%rip), %rcx      # 0x40ff6
movb $0x0, %al
callq 0x18220
jmp 0x35181
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x178(%rcx), %rax
jbe 0x351d9
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x178(%rax)
movq -0x8(%rbp), %rax
imulq $0x28, 0x178(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x168(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x3390
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x168(%rax)
jmp 0x351db
jmp 0x35588
movl $0x1, -0x40(%rbp)
jmp 0x354e6
movl $0x8, -0x40(%rbp)
jmp 0x354e6
movl $0x9, -0x40(%rbp)
jmp 0x354e6
movq -0x18(%rbp), %rax
cmpq $0x1, (%rax)
jne 0x3521a
movl $0x2, -0x40(%rbp)
jmp 0x352bc
movq -0x18(%rbp), %rax
cmpq $0x8, (%rax)
jne 0x35230
movl $0x3, -0x40(%rbp)
jmp 0x352ba
movq -0x18(%rbp), %rax
cmpq $0x10, (%rax)
jne 0x35243
movl $0x4, -0x40(%rbp)
jmp 0x352b8
movq -0x18(%rbp), %rax
cmpq $0x20, (%rax)
jne 0x35256
movl $0x5, -0x40(%rbp)
jmp 0x352b6
movq -0x18(%rbp), %rax
cmpq $0x40, (%rax)
jne 0x35269
movl $0x6, -0x40(%rbp)
jmp 0x352b4
movq -0x18(%rbp), %rax
cmpq $0x40, (%rax)
jge 0x35286
movl $0x7, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x38(%rbp)
jmp 0x352b2
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %r8
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %r9d
leaq 0xb5c5(%rip), %rsi      # 0x40864
movl $0x31a, %edx            # imm = 0x31A
leaq 0xbd65(%rip), %rcx      # 0x41010
movb $0x0, %al
callq 0x18220
jmp 0x352b4
jmp 0x352b6
jmp 0x352b8
jmp 0x352ba
jmp 0x352bc
jmp 0x354e6
movl $0xa, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x34(%rbp)
jmp 0x354e6
movq -0x8(%rbp), %rax
movq 0x1a0(%rax), %rdi
callq 0x3030
movl -0x10(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x35860
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1a0(%rax)
jmp 0x35588
movq -0x8(%rbp), %rax
movq 0x1a0(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x1a0(%rax)
xorl %eax, %eax
testb $0x1, %al
jne 0x35337
jmp 0x35341
jmp 0x35339
movq $0x0, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movb $0x0, -0x1b(%rbp)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
movslq -0x28(%rbp), %rdi
shlq $0x3, %rdi
callq 0x3360
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x1c(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x353b5
movq -0x18(%rbp), %rax
movl -0x54(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x35384
jmp 0x354e6
movl $0xb, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x38(%rbp)
jmp 0x354e6
cmpl $0x2, -0x10(%rbp)
jae 0x353fc
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %r8
movl -0x10(%rbp), %r9d
leaq 0xb47b(%rip), %rsi      # 0x40864
movl $0x344, %edx            # imm = 0x344
leaq 0xbc42(%rip), %rcx      # 0x41037
movb $0x0, %al
callq 0x18220
movl $0xc, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x30(%rbp)
movl -0x10(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3360
movq %rax, -0x38(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x3546a
movq -0x18(%rbp), %rax
movl -0x58(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x35439
jmp 0x354e6
movl $0xd, -0x40(%rbp)
jmp 0x354e6
movl $0xe, -0x40(%rbp)
jmp 0x354e6
movl $0xf, -0x40(%rbp)
jmp 0x354e6
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %esi
callq 0x22560
movq %rax, %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %edx
leaq 0xbbb7(%rip), %rdi      # 0x41064
movb $0x0, %al
callq 0x3170
movq -0x18(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x35d90
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %r8
movl -0xc(%rbp), %r9d
leaq 0xb391(%rip), %rsi      # 0x40864
movl $0x365, %edx            # imm = 0x365
leaq 0xbb98(%rip), %rcx      # 0x41077
movb $0x0, %al
callq 0x18220
jmp 0x354e8
movq -0x8(%rbp), %rax
movq 0x170(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq -0x8(%rbp), %rcx
cmpq 0x178(%rcx), %rax
jbe 0x35554
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x178(%rax)
movq -0x8(%rbp), %rax
imulq $0x28, 0x178(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x168(%rax), %rdi
movq -0x68(%rbp), %rsi
callq 0x3390
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x168(%rax)
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x170(%rax)
movq -0x8(%rbp), %rax
movq 0x168(%rax), %rdi
imulq $0x28, -0x60(%rbp), %rax
addq %rax, %rdi
leaq -0x40(%rbp), %rsi
movl $0x28, %edx
callq 0x3330
addq $0x70, %rsp
popq %rbp
retq
nop