// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/image.c
// Function: composite_3d
void composite_3d(char *f1, char *f2, char *out, int delta)
{
    if(!out) out = "out";
    image a = load_image(f1, 0,0,0);
    image b = load_image(f2, 0,0,0);
    int shift = best_3d_shift_r(a, b, -a.h/100, a.h/100);

    image c1 = crop_image(b, 10, shift, b.w, b.h);
    float d1 = dist_array(c1.data, a.data, a.w*a.h*a.c, 100);
    image c2 = crop_image(b, -10, shift, b.w, b.h);
    float d2 = dist_array(c2.data, a.data, a.w*a.h*a.c, 100);

    if(d2 < d1 && 0){
        image swap = a;
        a = b;
        b = swap;
        shift = -shift;
        printf("swapped, %d\n", shift);
    }
    else{
        printf("%d\n", shift);
    }

    image c = crop_image(b, delta, shift, a.w, a.h);
    int i;
    for(i = 0; i < c.w*c.h; ++i){
        c.data[i] = a.data[i];
    }
    save_image(c, out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %ecx, 0x3c(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %rsi
leaq 0x58(%rsp), %r15
movq %r15, %rdi
xorl %edx, %edx
callq 0x1b21a
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1b21a
movslq 0x4(%r15), %rax
imulq $-0x51eb851f, %rax, %rdi # imm = 0xAE147AE1
movq %rdi, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rdi
addl %ecx, %edi
imulq $0x51eb851f, %rax, %rsi # imm = 0x51EB851F
movq %rsi, %rax
shrq $0x3f, %rax
sarq $0x25, %rsi
addl %eax, %esi
movq 0x10(%r14), %rax
movq %rax, 0x28(%rsp)
movups (%r14), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x19312
movl %eax, %r12d
movl (%r14), %ecx
movl 0x4(%r14), %r8d
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x88(%rsp), %r13
movq %r13, %rdi
movl $0xa, %esi
movl %r12d, %edx
callq 0x18a89
movq 0x10(%r13), %rdi
movq 0x10(%r15), %rsi
movl 0x4(%r15), %edx
imull (%r15), %edx
imull 0x8(%r15), %edx
movl $0x64, %ecx
callq 0xf827
movl (%r14), %ecx
movl 0x4(%r14), %r8d
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x70(%rsp), %r13
movq %r13, %rdi
movl $0xfffffff6, %esi       # imm = 0xFFFFFFF6
movl %r12d, %edx
callq 0x18a89
movq 0x10(%r13), %rdi
movq 0x10(%r15), %rsi
movl (%r15), %r13d
movl 0x4(%r15), %ebp
movl %ebp, %edx
imull %r13d, %edx
imull 0x8(%r15), %edx
movl $0x64, %ecx
callq 0xf827
leaq 0x40ea7(%rip), %rdi     # 0x5a599
movl %r12d, %esi
xorl %eax, %eax
callq 0x3160
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl 0x3c(%rsp), %esi
movl %r12d, %edx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0x18a89
movl 0x4(%r14), %edx
imull (%r14), %edx
testl %edx, %edx
jle 0x19753
movq 0x68(%rsp), %rax
movq 0x50(%rsp), %rcx
movl %edx, %edx
xorl %esi, %esi
movss (%rax,%rsi,4), %xmm0
movss %xmm0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0x19741
testq %rbx, %rbx
leaq 0x41bb9(%rip), %rdi     # 0x5b316
cmovneq %rbx, %rdi
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x40(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x3, %esi
movl $0x50, %edx
callq 0x18310
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq