// File: /workspace/github_c_makefile_star2_O2/rchiossi[P]dexterity/lib/dex_stringid.c
// Function: dx_shift_stringid
void dx_shift_stringid(Dex* dx, uint32_t base, int32_t delta) {
  unsigned int i;

  dx_shift *shift, *prev;

  if (dx == NULL) return;

  shift = (dx_shift*) malloc_s(sizeof(dx_shift));

  shift->base = base;
  shift->delta = delta;
  shift->next = NULL;

  for (i=0; i<dx->header->type_ids_size; i++)
    dxsi_typeid(dx->type_ids[i],shift);
  
  for (i=0; i<dx->header->proto_ids_size; i++)
    dxsi_protoid(dx->proto_ids[i],shift);
  
  for (i=0; i<dx->header->field_ids_size; i++)
    dxsi_fieldid(dx->field_ids[i],shift);
  
  for (i=0; i<dx->header->method_ids_size; i++)
    dxsi_methodid(dx->method_ids[i],shift);
  
  for (i=0; i<dx->header->class_defs_size; i++)
    dxsi_classdef(dx->class_defs[i],shift);
  
  for (i=0; i<dx->meta.encoded_arrays_size; i++)
    dxsi_encodedarray(dx->encoded_arrays[i],shift);
  
  for (i=0; i<dx->meta.debug_info_list_size; i++)
    dxsi_debuginfo(dx->debug_info_list[i],shift);
  
  for (i=0; i<dx->meta.annotations_size; i++)
    dxsi_annotationitem(dx->annotations[i],shift);

  prev = shift;
  shift = shift->next;
  free(prev);

  //ULEB expansion  
  while (shift != NULL) {
    printf("delta2 = %d\n",shift->delta);
    dx->header->file_size += shift->delta;

    if (shift->base > dx->header->data_off)
      dx->header->data_size += shift->delta;

    dx_shift_offset(dx,shift->base,shift->delta);

    prev = shift;
    shift = shift->next;
    free(prev);
  }
  
}

// Assembly:
testq %rdi, %rdi
je 0x915c
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
pushq $0x10
popq %rdi
callq 0x46a0
movq %rax, %r14
movl %r15d, (%rax)
movl %ebp, 0x4(%rax)
andq $0x0, 0x8(%rax)
movq (%rbx), %rax
movl 0x48(%rax), %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x9001
movq 0x18(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movl 0x8(%rsi), %edi
cmpl %r15d, %edi
jb 0x8ffc
addl %ebp, %edi
movl %edi, 0x8(%rsi)
incq %rdx
jmp 0x8fe2
movl 0x50(%rax), %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x9025
movq 0x20(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movl 0x8(%rsi), %edi
cmpl %r15d, %edi
jb 0x9020
addl %ebp, %edi
movl %edi, 0x8(%rsi)
incq %rdx
jmp 0x9006
movl 0x58(%rax), %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x9049
movq 0x28(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movl 0xc(%rsi), %edi
cmpl %r15d, %edi
jb 0x9044
addl %ebp, %edi
movl %edi, 0xc(%rsi)
incq %rdx
jmp 0x902a
movl 0x60(%rax), %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x906d
movq 0x30(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movl 0xc(%rsi), %edi
cmpl %r15d, %edi
jb 0x9068
addl %ebp, %edi
movl %edi, 0xc(%rsi)
incq %rdx
jmp 0x904e
movl 0x68(%rax), %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x9091
movq 0x38(%rbx), %rdx
movq (%rdx,%rcx,8), %rdx
movl 0x18(%rdx), %esi
cmpl %r15d, %esi
jb 0x908c
addl %ebp, %esi
movl %esi, 0x18(%rdx)
incq %rcx
jmp 0x9072
xorl %eax, %eax
movl %eax, %r15d
cmpq %r15, 0x108(%rbx)
jbe 0x90b5
movq 0x60(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq %r14, %rsi
callq 0x4350
leal 0x1(%r15), %eax
jmp 0x9093
xorl %eax, %eax
movl %eax, %r15d
cmpq %r15, 0x128(%rbx)
jbe 0x90d9
movq 0x70(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq %r14, %rsi
callq 0x44c0
leal 0x1(%r15), %eax
jmp 0x90b7
xorl %eax, %eax
movl %eax, %r15d
cmpq %r15, 0x158(%rbx)
jbe 0x9100
movq 0x88(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq %r14, %rsi
callq 0x4690
leal 0x1(%r15), %eax
jmp 0x90db
movq 0x8(%r14), %r15
movq %r14, %rdi
callq 0x4060
leaq 0x10e3(%rip), %r14      # 0xa1f6
testq %r15, %r15
je 0x9154
movl 0x4(%r15), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4250
movl 0x4(%r15), %edx
movq (%rbx), %rax
addl %edx, 0x28(%rax)
movl (%r15), %esi
cmpl 0x74(%rax), %esi
jbe 0x913b
addl %edx, 0x70(%rax)
movq %rbx, %rdi
callq 0x4610
movq 0x8(%r15), %r12
movq %r15, %rdi
callq 0x4060
movq %r12, %r15
jmp 0x9113
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)