// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x5f15
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rax
movl 0x28(%rax), %edi
callq 0x4380
testq %rax, %rax
je 0x5f15
movq %rax, %r15
movq (%r14), %rsi
movq %rax, %rdi
callq 0x4050
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0x47e0
movq (%r14), %rax
cmpl $0x0, 0x40(%rax)
je 0x5c56
xorl %r12d, %r12d
movq 0x10(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x46c0
incq %r12
movq (%r14), %rax
movl 0x40(%rax), %eax
cmpq %rax, %r12
jb 0x5c38
movq (%r14), %rax
cmpl $0x0, 0x48(%rax)
je 0x5c80
xorl %r12d, %r12d
movq 0x18(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x47d0
incq %r12
movq (%r14), %rax
movl 0x48(%rax), %eax
cmpq %rax, %r12
jb 0x5c62
movq (%r14), %rax
cmpl $0x0, 0x50(%rax)
je 0x5caa
xorl %r12d, %r12d
movq 0x20(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x40f0
incq %r12
movq (%r14), %rax
movl 0x50(%rax), %eax
cmpq %rax, %r12
jb 0x5c8c
movq (%r14), %rax
cmpl $0x0, 0x58(%rax)
je 0x5cd4
xorl %r12d, %r12d
movq 0x28(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4330
incq %r12
movq (%r14), %rax
movl 0x58(%rax), %eax
cmpq %rax, %r12
jb 0x5cb6
movq (%r14), %rax
cmpl $0x0, 0x60(%rax)
je 0x5cfe
xorl %r12d, %r12d
movq 0x30(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x42a0
incq %r12
movq (%r14), %rax
movl 0x60(%rax), %eax
cmpq %rax, %r12
jb 0x5ce0
movq (%r14), %rax
cmpl $0x0, 0x68(%rax)
je 0x5d28
xorl %r12d, %r12d
movq 0x38(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x4120
incq %r12
movq (%r14), %rax
movl 0x68(%rax), %eax
cmpq %rax, %r12
jb 0x5d0a
cmpq $0x0, 0xc8(%r14)
je 0x5d56
movl $0x1, %ebp
xorl %eax, %eax
movq 0x40(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x4040
movl %ebp, %eax
incl %ebp
cmpq %rax, 0xc8(%r14)
ja 0x5d39
cmpq $0x0, 0xd8(%r14)
je 0x5d84
movl $0x1, %ebp
xorl %eax, %eax
movq 0x48(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x43a0
movl %ebp, %eax
incl %ebp
cmpq %rax, 0xd8(%r14)
ja 0x5d67
cmpq $0x0, 0xe8(%r14)
je 0x5db2
movl $0x1, %ebp
xorl %eax, %eax
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x4320
movl %ebp, %eax
incl %ebp
cmpq %rax, 0xe8(%r14)
ja 0x5d95
cmpq $0x0, 0xf8(%r14)
je 0x5de0
movl $0x1, %ebp
xorl %eax, %eax
movq 0x58(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x4200
movl %ebp, %eax
incl %ebp
cmpq %rax, 0xf8(%r14)
ja 0x5dc3
cmpq $0x0, 0x108(%r14)
je 0x5e0e
movl $0x1, %ebp
xorl %eax, %eax
movq 0x60(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x4780
movl %ebp, %eax
incl %ebp
cmpq %rax, 0x108(%r14)
ja 0x5df1
cmpq $0x0, 0x118(%r14)
je 0x5e3c
movl $0x1, %ebp
xorl %eax, %eax
movq 0x68(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x4220
movl %ebp, %eax
incl %ebp
cmpq %rax, 0x118(%r14)
ja 0x5e1f
cmpq $0x0, 0x128(%r14)
je 0x5e6a
movl $0x1, %ebp
xorl %eax, %eax
movq 0x70(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x45c0
movl %ebp, %eax
incl %ebp
cmpq %rax, 0x128(%r14)
ja 0x5e4d
cmpq $0x0, 0x138(%r14)
je 0x5e98
movl $0x1, %ebp
xorl %eax, %eax
movq 0x78(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x42d0
movl %ebp, %eax
incl %ebp
cmpq %rax, 0x138(%r14)
ja 0x5e7b
cmpq $0x0, 0x148(%r14)
je 0x5ec9
movl $0x1, %ebp
xorl %eax, %eax
movq 0x80(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x4130
movl %ebp, %eax
incl %ebp
cmpq %rax, 0x148(%r14)
ja 0x5ea9
cmpq $0x0, 0x158(%r14)
je 0x5efa
movl $0x1, %ebp
xorl %eax, %eax
movq 0x88(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x4310
movl %ebp, %eax
incl %ebp
cmpq %rax, 0x158(%r14)
ja 0x5eda
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4250
movq %r15, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x42e0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop