// File: /workspace/github_c_makefile_star2_O2/rchiossi[P]dexterity/lib/dex_builder.c
// Function: dx_build
void dx_build(Dex* dx, char* filename) {
  ByteStream* bs;
  unsigned int i;

  if (dx == NULL) return;

  bs = bsalloc(dx->header->file_size);

  if (bs == NULL) return;

  
  dxb_header(bs,dx->header);
  dxb_maplist(bs,dx->map_list);

  for (i=0; i<dx->header->string_ids_size; i++)
    dxb_stringid(bs,dx->string_ids[i]);

  for (i=0; i<dx->header->type_ids_size; i++)
    dxb_typeid(bs,dx->type_ids[i]);

  for (i=0; i<dx->header->proto_ids_size; i++)
    dxb_protoid(bs,dx->proto_ids[i]);

  for (i=0; i<dx->header->field_ids_size; i++)
    dxb_fieldid(bs,dx->field_ids[i]);

  for (i=0; i<dx->header->method_ids_size; i++)
    dxb_methodid(bs,dx->method_ids[i]);

  for (i=0; i<dx->header->class_defs_size; i++)
    dxb_classdef(bs,dx->class_defs[i]);

  //Data
  for (i=0; i<dx->meta.string_data_list_size; i++)
    dxb_stringdata(bs,dx->string_data_list[i]);
  
  for (i=0; i<dx->meta.type_lists_size; i++)
    dxb_typelist(bs,dx->type_lists[i]);

  for (i=0; i<dx->meta.an_directories_size; i++)
    dxb_annotationdirectoryitem(bs,dx->an_directories[i]);

  for (i=0; i<dx->meta.class_data_size; i++)
    dxb_classdata(bs,dx->class_data[i]);

  for (i=0; i<dx->meta.encoded_arrays_size; i++)
    dxb_encodedarray(bs,dx->encoded_arrays[i]);

  for (i=0; i<dx->meta.code_list_size; i++)
    dxb_codeitem(bs,dx->code_list[i]);

  for (i=0; i<dx->meta.debug_info_list_size; i++)
    dxb_debuginfo(bs,dx->debug_info_list[i]);

  for (i=0; i<dx->meta.an_set_size; i++)
    dxb_annotationsetitem(bs,dx->an_set[i]);

  for (i=0; i<dx->meta.an_set_ref_lists_size; i++)
    dxb_annotationsetreflist(bs,dx->an_set_ref_lists[i]);

  for (i=0; i<dx->meta.annotations_size; i++)
    dxb_annotationitem(bs,dx->annotations[i]);

  bssave(bs,filename);

  bsfree(bs);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x5bb3
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rax
movl 0x28(%rax), %edi
callq 0x43e0
testq %rax, %rax
je 0x5bb3
movq %rax, %r15
movq (%r14), %rsi
movq %rax, %rdi
callq 0x4050
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x48b0
xorl %r12d, %r12d
movq (%r14), %rax
movl 0x40(%rax), %ecx
cmpq %rcx, %r12
jae 0x5bbf
movq 0x10(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4780
incq %r12
jmp 0x5b93
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r12d, %r12d
movl 0x48(%rax), %ecx
cmpq %rcx, %r12
jae 0x5be2
movq 0x18(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x48a0
incq %r12
movq (%r14), %rax
jmp 0x5bc2
xorl %r12d, %r12d
movl 0x50(%rax), %ecx
cmpq %rcx, %r12
jae 0x5c05
movq 0x20(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x40f0
incq %r12
movq (%r14), %rax
jmp 0x5be5
xorl %r12d, %r12d
movl 0x58(%rax), %ecx
cmpq %rcx, %r12
jae 0x5c28
movq 0x28(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4390
incq %r12
movq (%r14), %rax
jmp 0x5c08
xorl %r12d, %r12d
movl 0x60(%rax), %ecx
cmpq %rcx, %r12
jae 0x5c4b
movq 0x30(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x42f0
incq %r12
movq (%r14), %rax
jmp 0x5c2b
xorl %r12d, %r12d
movl 0x68(%rax), %eax
cmpq %rax, %r12
jae 0x5c6e
movq 0x38(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4130
incq %r12
movq (%r14), %rax
jmp 0x5c4e
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0xc8(%r14)
jbe 0x5c93
movq 0x40(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4040
leal 0x1(%r12), %eax
jmp 0x5c70
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0xd8(%r14)
jbe 0x5cb8
movq 0x48(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4410
leal 0x1(%r12), %eax
jmp 0x5c95
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0xe8(%r14)
jbe 0x5cdd
movq 0x50(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4380
leal 0x1(%r12), %eax
jmp 0x5cba
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0xf8(%r14)
jbe 0x5d02
movq 0x58(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4240
leal 0x1(%r12), %eax
jmp 0x5cdf
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0x108(%r14)
jbe 0x5d27
movq 0x60(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4850
leal 0x1(%r12), %eax
jmp 0x5d04
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0x118(%r14)
jbe 0x5d4c
movq 0x68(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4260
leal 0x1(%r12), %eax
jmp 0x5d29
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0x128(%r14)
jbe 0x5d71
movq 0x70(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4650
leal 0x1(%r12), %eax
jmp 0x5d4e
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0x138(%r14)
jbe 0x5d96
movq 0x78(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4320
leal 0x1(%r12), %eax
jmp 0x5d73
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0x148(%r14)
jbe 0x5dbe
movq 0x80(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4140
leal 0x1(%r12), %eax
jmp 0x5d98
xorl %eax, %eax
movl %eax, %r12d
cmpq %r12, 0x158(%r14)
jbe 0x5de6
movq 0x88(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4370
leal 0x1(%r12), %eax
jmp 0x5dc0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x42a0
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x4330