// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/image.c
// Function: resize_image
image resize_image(image im, int w, int h)
{
    image resized = make_image(w, h, im.c);   
    image part = make_image(w, im.h, im.c);
    int r, c, k;
    float w_scale = (float)(im.w - 1) / (w - 1);
    float h_scale = (float)(im.h - 1) / (h - 1);
    for(k = 0; k < im.c; ++k){
        for(r = 0; r < im.h; ++r){
            for(c = 0; c < w; ++c){
                float val = 0;
                if(c == w-1 || im.w == 1){
                    val = get_pixel(im, im.w-1, r, k);
                } else {
                    float sx = c*w_scale;
                    int ix = (int) sx;
                    float dx = sx - ix;
                    val = (1 - dx) * get_pixel(im, ix, r, k) + dx * get_pixel(im, ix+1, r, k);
                }
                set_pixel(part, c, r, k, val);
            }
        }
    }
    for(k = 0; k < im.c; ++k){
        for(r = 0; r < h; ++r){
            float sy = r*h_scale;
            int iy = (int) sy;
            float dy = sy - iy;
            for(c = 0; c < w; ++c){
                float val = (1-dy) * get_pixel(part, c, iy, k);
                set_pixel(resized, c, r, k, val);
            }
            if(r == h-1 || im.h == 1) continue;
            for(c = 0; c < w; ++c){
                float val = dy * get_pixel(part, c, iy+1, k);
                add_pixel(resized, c, r, k, val);
            }
        }
    }

    free_image(part);
    return resized;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %esi, %r12d
movq %rdi, %r15
movslq 0xf8(%rsp), %r14
movl %edx, 0x4(%rdi)
movl %esi, (%rdi)
movl %r14d, 0x8(%rdi)
movl %r14d, %ebx
imull %esi, %ebx
movl %ebx, %eax
movq %rdx, 0x30(%rsp)
imull %edx, %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x3250
movq %rax, 0x90(%rsp)
movq %r15, 0x88(%rsp)
movq %rax, 0x10(%r15)
movl 0xf4(%rsp), %eax
movq %rax, 0x20(%rsp)
imull %eax, %ebx
movslq %ebx, %rdi
movl $0x4, %esi
callq 0x3250
movq %r14, 0x38(%rsp)
testq %r14, %r14
jle 0x174be
movq %rax, 0x48(%rsp)
leaq 0xf0(%rsp), %r15
movl (%r15), %eax
movq %rax, 0x58(%rsp)
leal -0x1(%rax), %ecx
leal -0x1(%r12), %eax
movl %ecx, 0x7c(%rsp)
cvtsi2ss %ecx, %xmm2
movq 0x20(%rsp), %rsi
leal -0x1(%rsi), %ecx
cvtsi2ss %eax, %xmm0
movq 0x30(%rsp), %rdx
leal -0x1(%rdx), %edx
cvtsi2ss %ecx, %xmm1
divss %xmm0, %xmm2
movss %xmm2, 0x78(%rsp)
movl %edx, 0x6c(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
divss %xmm0, %xmm1
movss %xmm1, 0x74(%rsp)
movl %eax, %eax
movq %rax, 0x98(%rsp)
movl %r12d, %eax
movq %rax, 0x60(%rsp)
movl %esi, %eax
imull %r12d, %eax
movl %eax, 0x70(%rsp)
movq $0x0, 0x40(%rsp)
xorl %ebx, %ebx
movq %r12, 0x50(%rsp)
cmpl $0x0, 0x20(%rsp)
jle 0x17345
movq 0x40(%rsp), %rax
movl %eax, 0x2c(%rsp)
xorl %r14d, %r14d
testl %r12d, %r12d
jle 0x1732d
movl 0x2c(%rsp), %eax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,4), %rbp
xorl %r13d, %r13d
cmpl $0x1, 0x58(%rsp)
sete %al
cmpq %r13, 0x98(%rsp)
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x17273
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movl 0x7c(%rsp), %edi
movl %r14d, %esi
movl %ebx, %edx
callq 0x15f12
jmp 0x17318
xorps %xmm1, %xmm1
cvtsi2ss %r13d, %xmm1
mulss 0x78(%rsp), %xmm1
cvttss2si %xmm1, %r12d
cvttps2dq %xmm1, %xmm0
cvtdq2ps %xmm0, %xmm0
subss %xmm0, %xmm1
movaps %xmm1, 0xa0(%rsp)
movss 0x3dd67(%rip), %xmm0    # 0x55008
subss %xmm1, %xmm0
movss %xmm0, 0x84(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movl %r12d, %edi
movl %r14d, %esi
movl %ebx, %edx
callq 0x15f12
movss %xmm0, 0x80(%rsp)
incl %r12d
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movl %r12d, %edi
movl %r14d, %esi
movl %ebx, %edx
callq 0x15f12
mulss 0xa0(%rsp), %xmm0
movss 0x80(%rsp), %xmm1
mulss 0x84(%rsp), %xmm1
addss %xmm0, %xmm1
movaps %xmm1, %xmm0
movss %xmm0, (%rbp,%r13,4)
incq %r13
cmpq %r13, 0x60(%rsp)
jne 0x17235
incq %r14
movq 0x50(%rsp), %r12
addl %r12d, 0x2c(%rsp)
cmpq 0x20(%rsp), %r14
jne 0x1721c
incq %rbx
movq 0x40(%rsp), %rax
addl 0x70(%rsp), %eax
movq %rax, 0x40(%rsp)
cmpq 0x38(%rsp), %rbx
jne 0x17205
cmpl $0x0, 0x38(%rsp)
movq 0x48(%rsp), %rax
movq 0x60(%rsp), %r13
jle 0x174be
movl 0x6c(%rsp), %edx
movq 0x30(%rsp), %rsi
movl %esi, %ecx
imull %r12d, %esi
movl %esi, 0x58(%rsp)
xorl %esi, %esi
movl $0x1, %edi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpl $0x0, 0x30(%rsp)
jle 0x174a0
movl %r8d, %r10d
xorl %r11d, %r11d
testl %r12d, %r12d
jle 0x17491
xorps %xmm0, %xmm0
cvtsi2ss %r11d, %xmm0
mulss 0x74(%rsp), %xmm0
cvttss2si %xmm0, %r14d
cmpl %r14d, 0x20(%rsp)
jle 0x174e5
movslq %r10d, %rbx
movq 0x90(%rsp), %r15
leaq (%r15,%rbx,4), %rbx
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm1
subss %xmm1, %xmm0
movss 0x3dc18(%rip), %xmm1    # 0x55008
subss %xmm0, %xmm1
leal (%rsi,%r14), %ebp
imull %r12d, %ebp
movslq %ebp, %r15
leaq (%rax,%r15,4), %r15
xorl %r12d, %r12d
movss (%r15,%r12,4), %xmm2
mulss %xmm1, %xmm2
movss %xmm2, (%rbx,%r12,4)
incq %r12
cmpq %r12, %r13
jne 0x17406
movq 0x50(%rsp), %r13
testl %r13d, %r13d
setle %bpl
cmpl $0x1, 0x20(%rsp)
sete %r15b
cmpq %rdx, %r11
sete %r12b
orb %r15b, %r12b
orb %bpl, %r12b
movq %r13, %r12
movq 0x60(%rsp), %r13
movq 0x48(%rsp), %rax
jne 0x17491
leal 0x1(%r14), %ebp
cmpl %ebp, 0x20(%rsp)
jle 0x174e5
addl %edi, %r14d
movq 0x50(%rsp), %r12
imull %r12d, %r14d
movslq %r14d, %r14
leaq (%rax,%r14,4), %r14
xorl %r15d, %r15d
movss (%r14,%r15,4), %xmm1
mulss %xmm0, %xmm1
addss (%rbx,%r15,4), %xmm1
movss %xmm1, (%rbx,%r15,4)
incq %r15
cmpq %r15, %r13
jne 0x17473
incq %r11
addl %r12d, %r10d
cmpq %rcx, %r11
jne 0x173a7
incq %r9
addl 0x58(%rsp), %r8d
movq 0x20(%rsp), %r10
addl %r10d, %esi
addl %r10d, %edi
cmpq 0x38(%rsp), %r9
jne 0x17396
testq %rax, %rax
je 0x174cb
movq %rax, %rdi
callq 0x3040
movq 0x88(%rsp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x410a5(%rip), %rdi     # 0x58591
leaq 0x402a9(%rip), %rsi     # 0x5779c
leaq 0x410b5(%rip), %rcx     # 0x585af
movl $0x31, %edx
callq 0x31b0