// File: /workspace/github_cpp_makefile_star2_O1/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 0x24753
movq %rsi, %r14
testq %rcx, %rcx
js 0x24677
cvtsi2ss %rcx, %xmm0
jmp 0x2468c
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 0x24719
movq 0x8(%rbx), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x24143
testl %eax, %eax
je 0x24720
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
decq %rcx
movl 0x18(%rbx), %edx
imulq %rcx, %rdx
leaq (%rax,%rdx), %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rdx)
movq $0x0, 0x10(%rax,%rdx)
movl (%r14,%r12,4), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
divss -0x2c(%rbp), %xmm0
movss %xmm0, 0x18(%rax,%rdx)
movq 0x8(%rax,%rdx), %rsi
incq %rsi
movq %r15, %rdi
callq 0x236c7
xorl %ecx, %ecx
testl %eax, %eax
je 0x2473e
movq (%r15), %rax
movq 0x8(%r15), %rdx
movl %r12d, -0x4(%rax,%rdx,4)
jmp 0x2473e
movl $0x4, %ecx
jmp 0x2473e
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq (%rbx), %rdi
callq 0x5390
movq $0x0, (%rbx)
movl $0x1, %ecx
testb $0x3, %cl
jne 0x24842
incq %r12
cmpq %r12, %r13
jne 0x2469f
movq 0x8(%rbx), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x24847
cmpq $0x1, %rcx
je 0x24847
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 0x2482d
movq %r9, %r10
shlq $0x5, %r10
xorl %ebx, %ebx
movq %rsi, %r11
movss (%r11,%r10), %xmm0
movss (%r11), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x2481e
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 0x247cb
testb %bl, %bl
setne %r10b
cmpq $0x2, %r9
setae %dl
orb %r10b, %dl
testb $0x1, %dl
jne 0x24786
jmp 0x24847
movl $0x26b0, %eax           # imm = 0x26B0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq