// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/data.c
// Function: load_data_compare
data load_data_compare(int n, char **paths, int m, int classes, int w, int h)
{
    if(m) paths = get_random_paths(paths, 2*n, m);
    int i,j;
    data d = {0};
    d.shallow = 0;

    d.X.rows = n;
    d.X.vals = calloc(d.X.rows, sizeof(float*));
    d.X.cols = h*w*6;

    int k = 2*(classes);
    d.y = make_matrix(n, k);
    for(i = 0; i < n; ++i){
        image im1 = load_image_color(paths[i*2],   w, h);
        image im2 = load_image_color(paths[i*2+1], w, h);

        d.X.vals[i] = calloc(d.X.cols, sizeof(float));
        memcpy(d.X.vals[i],         im1.data, h*w*3*sizeof(float));
        memcpy(d.X.vals[i] + h*w*3, im2.data, h*w*3*sizeof(float));

        int id;
        float iou;

        char imlabel1[4096];
        char imlabel2[4096];
        find_replace(paths[i*2],   "imgs", "labels", imlabel1);
        find_replace(imlabel1, "jpg", "txt", imlabel1);
        FILE *fp1 = fopen(imlabel1, "r");

        while(fscanf(fp1, "%d %f", &id, &iou) == 2){
            if (d.y.vals[i][2*id] < iou) d.y.vals[i][2*id] = iou;
        }

        find_replace(paths[i*2+1], "imgs", "labels", imlabel2);
        find_replace(imlabel2, "jpg", "txt", imlabel2);
        FILE *fp2 = fopen(imlabel2, "r");

        while(fscanf(fp2, "%d %f", &id, &iou) == 2){
            if (d.y.vals[i][2*id + 1] < iou) d.y.vals[i][2*id + 1] = iou;
        }

        for (j = 0; j < classes; ++j){
            if (d.y.vals[i][2*j] > .5 &&  d.y.vals[i][2*j+1] < .5){
                d.y.vals[i][2*j] = 1;
                d.y.vals[i][2*j+1] = 0;
            } else if (d.y.vals[i][2*j] < .5 &&  d.y.vals[i][2*j+1] > .5){
                d.y.vals[i][2*j] = 0;
                d.y.vals[i][2*j+1] = 1;
            } else {
                d.y.vals[i][2*j]   = SECRET_NUM;
                d.y.vals[i][2*j+1] = SECRET_NUM;
            }
        }
        fclose(fp1);
        fclose(fp2);

        free_image(im1);
        free_image(im2);
    }
    if(m) free(paths);
    return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20b8, %rsp           # imm = 0x20B8
movl %r9d, 0x20(%rsp)
movl %r8d, %r14d
movl %esi, %r12d
movq %rdi, %r15
testl %ecx, %ecx
movl %ecx, 0x2c(%rsp)
je 0x1f6cf
leal (%r12,%r12), %esi
movq %rdx, %rdi
movl %ecx, %edx
callq 0x1c922
movq %rax, 0x18(%rsp)
jmp 0x1f6d4
movq %rdx, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movl %r12d, 0x8(%r15)
movslq %r12d, %rdi
pushq $0x8
popq %rsi
callq 0x3250
movq %rax, 0x50(%rsp)
movq %rax, 0x10(%r15)
movl 0x20f0(%rsp), %eax
movl %eax, %ebx
imull 0x20(%rsp), %ebx
imull $0x6, %ebx, %ebp
movl %ebp, 0xc(%r15)
leal (%r14,%r14), %esi
movl %r12d, %edi
callq 0x221e3
movq %r14, %rcx
movq %rdx, %r14
movq %rax, 0x18(%r15)
movq %r15, 0x30(%rsp)
movq %rdx, 0x20(%r15)
movslq %ebp, %rax
movq %rax, 0x48(%rsp)
leal (%rbx,%rbx,2), %eax
cltq
movq %rax, 0x40(%rsp)
leaq (,%rax,4), %rax
movq %rax, 0x38(%rsp)
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
testl %r12d, %r12d
cmovlel %eax, %r12d
leaq 0x28(%rsp), %rbx
leaq 0x24(%rsp), %r13
xorl %ebp, %ebp
movq %rcx, 0x60(%rsp)
movq %r12, 0x58(%rsp)
cmpq %r12, %rbp
je 0x1fa27
leaq (,%rbp,2), %rax
movq %rax, 0x68(%rsp)
movq %rbp, %rax
shlq $0x4, %rax
movq %rax, 0x70(%rsp)
movq 0x18(%rsp), %r12
movq (%r12,%rax), %rsi
leaq 0x98(%rsp), %rdi
movl 0x20(%rsp), %r15d
movl %r15d, %edx
movl 0x20f0(%rsp), %ecx
callq 0xbf36
leaq 0x1(,%rbp,2), %rax
movq %rax, 0x78(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%r12,%rax,8), %rsi
leaq 0x80(%rsp), %rdi
movl %r15d, %edx
movl 0x20f0(%rsp), %ecx
callq 0xbf36
movq 0x48(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x3250
movq %rax, %r15
movq 0x50(%rsp), %rax
movq %r15, (%rax,%rbp,8)
movq 0xa8(%rsp), %rsi
movq %r15, %rdi
movq 0x38(%rsp), %r12
movq %r12, %rdx
callq 0x32b0
movq 0x40(%rsp), %rax
leaq (%r15,%rax,4), %rdi
movq 0x90(%rsp), %rsi
movq %r12, %rdx
callq 0x32b0
movq 0x70(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax), %rdi
leaq 0x301d7(%rip), %rsi     # 0x4fa24
leaq 0x30152(%rip), %rdx     # 0x4f9a6
leaq 0x10b0(%rsp), %r15
movq %r15, %rcx
callq 0x42ea
movq %r15, %rdi
leaq 0x2eedf(%rip), %rsi     # 0x4e74d
leaq 0x31f55(%rip), %rdx     # 0x517ca
movq %r15, %rcx
callq 0x42ea
movq %r15, %rdi
leaq 0x32462(%rip), %rsi     # 0x51ce9
callq 0x3390
movq %rax, %r12
movq %r12, %rdi
leaq 0x30190(%rip), %rsi     # 0x4fa29
movq %rbx, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x30a0
cmpl $0x2, %eax
jne 0x1f8ca
movq (%r14,%rbp,8), %rax
movslq 0x28(%rsp), %rcx
movss 0x24(%rsp), %xmm0
ucomiss (%rax,%rcx,8), %xmm0
jbe 0x1f88f
addq %rcx, %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x1f88f
movq 0x18(%rsp), %rax
movq 0x78(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x30145(%rip), %rsi     # 0x4fa24
leaq 0x300c0(%rip), %rdx     # 0x4f9a6
leaq 0xb0(%rsp), %r15
movq %r15, %rcx
callq 0x42ea
movq %r15, %rdi
leaq 0x2ee4d(%rip), %rsi     # 0x4e74d
leaq 0x31ec3(%rip), %rdx     # 0x517ca
movq %r15, %rcx
callq 0x42ea
movq %r15, %rdi
leaq 0x323d0(%rip), %rsi     # 0x51ce9
callq 0x3390
movq %rax, %r15
movq %r15, %rdi
leaq 0x300fe(%rip), %rsi     # 0x4fa29
movq %rbx, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x30a0
cmpl $0x2, %eax
jne 0x1f966
movq (%r14,%rbp,8), %rax
movslq 0x28(%rsp), %rcx
leaq (%rcx,%rcx), %rdx
movss 0x24(%rsp), %xmm0
ucomiss 0x4(%rax,%rdx,4), %xmm0
jbe 0x1f921
leaq 0x1(,%rcx,2), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x1f921
xorl %eax, %eax
movq 0x60(%rsp), %rdx
movss 0x2c8bf(%rip), %xmm1    # 0x4c234
movss 0x2c68b(%rip), %xmm2    # 0x4c008
movsd 0x2ffab(%rip), %xmm3    # 0x4f930
movsd 0x2ff93(%rip), %xmm4    # 0x4f920
cmpq %rax, %rdx
je 0x1f9ce
movq (%r14,%rbp,8), %rcx
movss (%rcx,%rax,8), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1f9ad
ucomiss 0x4(%rcx,%rax,8), %xmm1
jbe 0x1f9ad
movlps %xmm2, (%rcx,%rax,8)
jmp 0x1f9c9
ucomiss %xmm0, %xmm1
jbe 0x1f9c4
movss 0x4(%rcx,%rax,8), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1f9c4
movsd %xmm3, (%rcx,%rax,8)
jmp 0x1f9c9
movsd %xmm4, (%rcx,%rax,8)
incq %rax
jmp 0x1f98d
movq %r12, %rdi
callq 0x3130
movq %r15, %rdi
callq 0x3130
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x98(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
incq %rbp
movq 0x58(%rsp), %r12
jmp 0x1f779
cmpl $0x0, 0x2c(%rsp)
je 0x1fa38
movq 0x18(%rsp), %rdi
callq 0x3040
movq 0x30(%rsp), %rax
addq $0x20b8, %rsp           # imm = 0x20B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq