// File: /workspace/github_c_makefile_star2_O0/rchiossi[P]dexterity/lib/dex_parser.c
// Function: dx_codeitem
DexCodeItem* dx_codeitem(ByteStream* bs, uint32_t offset) {
  DexCodeItem* res;
  unsigned int i;

  DX_ALLOC(DexCodeItem,res);

  bsseek(bs,offset);

  bsread(bs,(uint8_t*) &(res->registers_size),sizeof(uint16_t));
  bsread(bs,(uint8_t*) &(res->ins_size),sizeof(uint16_t));
  bsread(bs,(uint8_t*) &(res->outs_size),sizeof(uint16_t));
  bsread(bs,(uint8_t*) &(res->tries_size),sizeof(uint16_t));
  bsread(bs,(uint8_t*) &(res->debug_info_off),sizeof(uint32_t));
  bsread(bs,(uint8_t*) &(res->insns_size),sizeof(uint32_t));

  res->meta.corrupted = bs->exhausted;
  if (res->meta.corrupted) return res;

  DX_ALLOC_LIST(uint16_t,res->insns,res->insns_size);

  for (i=0; i<res->insns_size; i++)
    bsread(bs,(uint8_t*) &(res->insns[i]),sizeof(uint16_t));

  if (res->tries_size > 0) {
    if (res->insns_size % 2 != 0)
      bsread(bs,(uint8_t*) &(res->padding),sizeof(uint16_t));

    DX_ALLOC_LIST(DexTryItem*,res->tries,res->tries_size); 
   
    for (i=0; i<res->tries_size; i++)
      res->tries[i] = dx_tryitem(bs,bs->offset);

    res->handlers = dx_encodedcatchhandlerlist(bs,bs->offset);    
  }

  return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x38, %edi
callq 0x4750
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x44f0
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x8, %rsi
movl $0x2, %edx
callq 0x4500
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0xa, %rsi
movl $0x2, %edx
callq 0x4500
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0xc, %rsi
movl $0x2, %edx
callq 0x4500
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0xe, %rsi
movl $0x2, %edx
callq 0x4500
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x10, %rsi
movl $0x4, %edx
callq 0x4500
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x14, %rsi
movl $0x4, %edx
callq 0x4500
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
setne %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
movq -0x20(%rbp), %rax
testb $0x1, (%rax)
je 0x7f48
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8096
jmp 0x7f4a
movq -0x20(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x7f72
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, %edi
shlq %rdi
callq 0x4750
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x7f7e
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
jmp 0x7f80
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jae 0x7fbd
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movl -0x24(%rbp), %eax
shlq %rax
addq %rax, %rsi
movl $0x2, %edx
callq 0x4500
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x7f87
movq -0x20(%rbp), %rax
movzwl 0xe(%rax), %eax
cmpl $0x0, %eax
jle 0x808e
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x7ff3
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x20, %rsi
movl $0x2, %edx
callq 0x4500
jmp 0x7ff5
movq -0x20(%rbp), %rax
movzwl 0xe(%rax), %eax
cmpl $0x0, %eax
je 0x8022
movq -0x20(%rbp), %rax
movzwl 0xe(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x4750
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0x802e
movq -0x20(%rbp), %rax
movq $0x0, 0x28(%rax)
jmp 0x8030
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
movzwl 0xe(%rcx), %ecx
cmpl %ecx, %eax
jae 0x8073
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x4920
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8037
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x4270
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq