// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %rsi
leaq 0x48(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x1a9d5
leaq 0x90(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1a9d5
movslq 0x4(%r14), %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(%r15), %rax
movq %rax, 0x28(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x18a99
movl %eax, %r12d
movl (%r15), %ecx
movl 0x4(%r15), %r8d
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
leaq 0x78(%rsp), %r13
movq %r13, %rdi
movl $0xa, %esi
movl %r12d, %edx
callq 0x181f7
movq 0x10(%r13), %rdi
movq 0x10(%r14), %rsi
movl 0x4(%r14), %edx
imull (%r14), %edx
imull 0x8(%r14), %edx
movl $0x64, %ecx
callq 0xf01b
movl (%r15), %ecx
movl 0x4(%r15), %r8d
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
leaq 0x60(%rsp), %r13
movq %r13, %rdi
movl $0xfffffff6, %esi       # imm = 0xFFFFFFF6
movl %r12d, %edx
callq 0x181f7
movq 0x10(%r13), %rdi
movq 0x10(%r14), %rsi
movl 0x4(%r14), %edx
imull (%r14), %edx
imull 0x8(%r14), %edx
movl $0x64, %ecx
callq 0xf01b
leaq 0x3f5f2(%rip), %rdi     # 0x58441
movl %r12d, %esi
xorl %eax, %eax
callq 0x3170
movl (%r14), %ecx
movl 0x4(%r14), %r8d
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x181f7
movl 0x4(%r14), %edx
imull (%r14), %edx
testl %edx, %edx
jle 0x18eaf
movq 0x58(%rsp), %rax
movq 0x40(%rsp), %rcx
movl %edx, %edx
xorl %esi, %esi
movss (%rax,%rsi,4), %xmm0
movss %xmm0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0x18e9d
testq %rbx, %rbx
leaq 0x40305(%rip), %rdi     # 0x591be
cmovneq %rbx, %rdi
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x3, %esi
movl $0x50, %edx
callq 0x17a81
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq