// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/image.c
// Function: letterbox_image
image letterbox_image(image im, int w, int h)
{
    int new_w = im.w;
    int new_h = im.h;
    if (((float)w/im.w) < ((float)h/im.h)) {
        new_w = w;
        new_h = (im.h * w)/im.w;
    } else {
        new_h = h;
        new_w = (im.w * h)/im.h;
    }
    image resized = resize_image(im, new_w, new_h);
    image boxed = make_image(w, h, im.c);
    fill_image(boxed, .5);
    //int i;
    //for(i = 0; i < boxed.w*boxed.h*boxed.c; ++i) boxed.data[i] = 0;
    embed_image(resized, boxed, (w-new_w)/2, (h-new_h)/2); 
    free_image(resized);
    return boxed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x90(%rsp), %r15
movd %edx, %xmm0
movd %esi, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm1
movsd (%r15), %xmm0
cvtdq2ps %xmm0, %xmm2
divps %xmm2, %xmm1
movaps %xmm1, %xmm2
shufps $0x55, %xmm1, %xmm2     # xmm2 = xmm2[1,1],xmm1[1,1]
ucomiss %xmm1, %xmm2
jbe 0x19973
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movd %xmm1, %eax
imull %r14d, %eax
movd %xmm0, %ecx
cltd
idivl %ecx
movl %r14d, %r12d
jmp 0x1998b
movd %xmm0, %eax
imull %ebp, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
cltd
idivl %ecx
movl %eax, %r12d
movl %ebp, %eax
movq 0x10(%r15), %rcx
movq %rcx, 0x10(%rsp)
movdqu (%r15), %xmm0
movdqu %xmm0, (%rsp)
leaq 0x40(%rsp), %rdi
movl %r12d, %esi
movl %eax, 0x3c(%rsp)
movl %eax, %edx
callq 0x170fa
movl 0x8(%r15), %eax
movl %ebp, 0x4(%rbx)
movl %r14d, (%rbx)
movl %eax, 0x8(%rbx)
movl %ebp, %r15d
imull %r14d, %r15d
imull %eax, %r15d
movslq %r15d, %r13
movl $0x4, %esi
movq %r13, %rdi
callq 0x3250
movq %rax, 0x10(%rbx)
testl %r13d, %r13d
jle 0x19adf
movl %r15d, %ecx
addl $0x3, %r15d
andl $-0x4, %r15d
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x3b76a(%rip), %xmm1    # 0x55170
movdqa 0x3b672(%rip), %xmm2    # 0x55080
xorl %ecx, %ecx
movdqa 0x3b678(%rip), %xmm3    # 0x55090
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x3b758(%rip), %xmm5    # 0x55180
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x19a63
movl $0x3f000000, (%rax,%rcx,4) # imm = 0x3F000000
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x19a79
movl $0x3f000000, 0x4(%rax,%rcx,4) # imm = 0x3F000000
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x19ab8
movl $0x3f000000, 0x8(%rax,%rcx,4) # imm = 0x3F000000
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x19aca
movl $0x3f000000, 0xc(%rax,%rcx,4) # imm = 0x3F000000
addq $0x4, %rcx
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
cmpq %rcx, %r15
jne 0x19a28
subl %r12d, %r14d
movl %r14d, %edi
shrl $0x1f, %edi
addl %r14d, %edi
sarl %edi
subl 0x3c(%rsp), %ebp
movl %ebp, %esi
shrl $0x1f, %esi
addl %ebp, %esi
sarl %esi
movq 0x10(%rbx), %rax
movq %rax, 0x28(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x40(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x162c2
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x19b32
callq 0x3040
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq