// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x127bc
leaq 0x642a2(%rip), %rax     # 0x76a5a
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x38(%rbp), %rdi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x12a60
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x12a60
xorl %eax, %eax
subl -0x34(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %edi
movl -0x34(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %esi
leaq -0x38(%rbp), %rcx
leaq -0x50(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0x12480
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %edx
movl -0x50(%rbp), %ecx
movl -0x4c(%rbp), %r8d
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rax
movl $0xa, %esi
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x11ca0
movq -0x60(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x38(%rbp), %edx
imull -0x34(%rbp), %edx
imull -0x30(%rbp), %edx
movl $0x64, %ecx
callq 0x5800
movss %xmm0, -0x74(%rbp)
movl -0x54(%rbp), %edx
movl -0x50(%rbp), %ecx
movl -0x4c(%rbp), %r8d
leaq -0x90(%rbp), %rdi
leaq -0x50(%rbp), %rax
movl $0xfffffff6, %esi       # imm = 0xFFFFFFF6
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x11ca0
movq -0x80(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x38(%rbp), %edx
imull -0x34(%rbp), %edx
imull -0x30(%rbp), %edx
movl $0x64, %ecx
callq 0x5800
movss %xmm0, -0x94(%rbp)
movss -0x94(%rbp), %xmm1
movss -0x74(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1298a
xorl %eax, %eax
testb $0x1, %al
jne 0x12915
jmp 0x1298a
movq -0x38(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x40(%rbp)
xorl %eax, %eax
subl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %esi
leaq 0x607ec(%rip), %rdi     # 0x7316d
movb $0x0, %al
callq 0x3130
jmp 0x1299b
movl -0x54(%rbp), %esi
leaq 0x607e2(%rip), %rdi     # 0x73176
movb $0x0, %al
callq 0x3130
movl -0x1c(%rbp), %esi
movl -0x54(%rbp), %edx
movl -0x38(%rbp), %ecx
movl -0x34(%rbp), %r8d
leaq -0xc8(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x11ca0
movl $0x0, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movl -0xc8(%rbp), %ecx
imull -0xc4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x12a26
movq -0x28(%rbp), %rax
movslq -0xcc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0xb8(%rbp), %rax
movslq -0xcc(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x129db
movq -0x18(%rbp), %rdi
leaq -0xc8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x11330
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax,%rax)