// File: /workspace/github_c_makefile_star2_O3/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 0x5f27
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rax
movl 0x28(%rax), %edi
callq 0x4380
testq %rax, %rax
je 0x5f27
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 0x5c77
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), %ecx
cmpq %rcx, %r12
jb 0x5c59
cmpl $0x0, 0x48(%rax)
je 0x5c9e
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), %ecx
cmpq %rcx, %r12
jb 0x5c80
cmpl $0x0, 0x50(%rax)
je 0x5cc5
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), %ecx
cmpq %rcx, %r12
jb 0x5ca7
cmpl $0x0, 0x58(%rax)
je 0x5cec
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), %ecx
cmpq %rcx, %r12
jb 0x5cce
cmpl $0x0, 0x60(%rax)
je 0x5d13
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), %ecx
cmpq %rcx, %r12
jb 0x5cf5
cmpl $0x0, 0x68(%rax)
je 0x5d3a
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 0x5d1c
cmpq $0x0, 0xc8(%r14)
je 0x5d68
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 0x5d4b
cmpq $0x0, 0xd8(%r14)
je 0x5d96
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 0x5d79
cmpq $0x0, 0xe8(%r14)
je 0x5dc4
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 0x5da7
cmpq $0x0, 0xf8(%r14)
je 0x5df2
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 0x5dd5
cmpq $0x0, 0x108(%r14)
je 0x5e20
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 0x5e03
cmpq $0x0, 0x118(%r14)
je 0x5e4e
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 0x5e31
cmpq $0x0, 0x128(%r14)
je 0x5e7c
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 0x5e5f
cmpq $0x0, 0x138(%r14)
je 0x5eaa
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 0x5e8d
cmpq $0x0, 0x148(%r14)
je 0x5edb
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 0x5ebb
cmpq $0x0, 0x158(%r14)
je 0x5f0c
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 0x5eec
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