// File: /workspace/github_cpp_makefile_star2_O3/mhe[P]raytracerframework_cpp/lodepng.cpp
// Function: HuffmanTree_fillInCoins(vector*, unsigned int const*, unsigned int, unsigned long)
static unsigned HuffmanTree_fillInCoins(vector* coins, const unsigned* frequencies, unsigned numcodes, size_t sum)
{
  unsigned i;
  for(i = 0; i < numcodes; i++)
  {
    Coin* coin;
    if(frequencies[i] == 0) continue; /*it's important to exclude symbols that aren't present*/
    if(!vector_resize(coins, coins->size + 1)) { vector_cleanup(coins); return 9904; }
    coin = (Coin*)(vector_get(coins, coins->size - 1));
    Coin_init(coin);
    coin->weight = frequencies[i] / (float)sum;
    uivector_push_back(&coin->symbols, i);
  }
  if(coins->size) Coin_sort((Coin*)coins->data, coins->size);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
testl %edx, %edx
je 0x23298
movq %rsi, %r14
testq %rcx, %rcx
js 0x231f1
cvtsi2ss %rcx, %xmm0
jmp 0x23206
movq %rcx, %rax
shrq %rax
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq 0x8(%rbx), %rax
movq %rax, -0x38(%rbp)
movl %edx, %r13d
xorl %r12d, %r12d
cmpl $0x0, (%r14,%r12,4)
je 0x23290
movq 0x8(%rbx), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x22cfa
testl %eax, %eax
je 0x23387
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
decq %rcx
movl 0x18(%rbx), %edx
imulq %rcx, %rdx
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rdx)
movq $0x0, 0x10(%rax,%rdx)
movl (%r14,%r12,4), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
leaq (%rax,%rdx), %r15
divss -0x2c(%rbp), %xmm0
movss %xmm0, 0x18(%rax,%rdx)
movl $0x1, %esi
movq %r15, %rdi
callq 0x22340
testl %eax, %eax
je 0x23290
movq (%r15), %rax
movq 0x8(%r15), %rcx
movl %r12d, -0x4(%rax,%rcx,4)
incq %r12
cmpq %r12, %r13
jne 0x23219
movq 0x8(%rbx), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x233a5
cmpq $0x1, %rcx
je 0x233a5
movq (%rbx), %rsi
addq $0x18, %rsi
movabsq $0x4ec4ec4ec4ec4ec5, %rdi # imm = 0x4EC4EC4EC4EC4EC5
movl $0xb, %r8d
movq %rcx, %r9
addq %r9, %r9
leaq (%r9,%r9,4), %rax
mulq %rdi
leaq (%r9,%r9,4), %rax
addq $-0x75, %rax
shrq $0x2, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
cmpq $0x1a, %rax
movq %rdx, %r9
cmovbq %r8, %r9
xorl %eax, %eax
movq %rcx, %rdx
movl $0x0, %r10d
subq %r9, %rdx
je 0x23372
movq %r9, %r10
shlq $0x5, %r10
xorl %ebx, %ebx
movq %rsi, %r11
movss (%r11,%r10), %xmm0
movss (%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x23363
movss %xmm1, (%r11,%r10)
movss %xmm0, (%r11)
movq -0x10(%r11), %rbx
movq -0x10(%r11,%r10), %r14
movq %r14, -0x10(%r11)
movq %rbx, -0x10(%r11,%r10)
movq -0x8(%r11), %rbx
movq -0x8(%r11,%r10), %r14
movq %r14, -0x8(%r11)
movq %rbx, -0x8(%r11,%r10)
movq -0x18(%r11), %rbx
movq -0x18(%r11,%r10), %r14
movq %r14, -0x18(%r11)
movq %rbx, -0x18(%r11,%r10)
movb $0x1, %bl
addq $0x20, %r11
decq %rdx
jne 0x23310
testb %bl, %bl
setne %r10b
cmpq $0x2, %r9
setae %dl
orb %r10b, %dl
testb $0x1, %dl
jne 0x232cb
jmp 0x233a5
xorps %xmm0, %xmm0
movq -0x38(%rbp), %rax
movups %xmm0, (%rax)
movq (%rbx), %rdi
callq 0x4380
movq $0x0, (%rbx)
movl $0x26b0, %eax           # imm = 0x26B0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq