// File: /workspace/github_c_makefile_star2_O3/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, 0x34(%rsp)
movq %r8, 0x38(%rsp)
movl %esi, %r14d
movq %rdi, %r12
testl %ecx, %ecx
movl %ecx, 0x44(%rsp)
je 0x2e481
leal (%r14,%r14), %esi
movq %rdx, %rdi
movl %ecx, %edx
callq 0x2af92
movq %rax, 0x28(%rsp)
jmp 0x2e486
movq %rdx, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movups %xmm0, 0x30(%r12)
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movl %r14d, 0x8(%r12)
movslq %r14d, %rdi
movl $0x8, %esi
callq 0x3250
movq %rax, 0x70(%rsp)
movq %rax, 0x10(%r12)
movl 0x20f0(%rsp), %eax
movl %eax, %r15d
imull 0x34(%rsp), %r15d
leal (%r15,%r15), %eax
leal (%rax,%rax,2), %ebp
movl %ebp, 0xc(%r12)
movq 0x38(%rsp), %rax
leal (%rax,%rax), %esi
movl %r14d, %edi
callq 0x311ee
movq %rax, 0x18(%r12)
movq %r12, 0x48(%rsp)
movq %rdx, 0x20(%r12)
testl %r14d, %r14d
jle 0x2e7cf
movq %rdx, %rbx
movslq %ebp, %rax
movq %rax, 0x68(%rsp)
leal (%r15,%r15,2), %eax
cltq
movq %rax, 0x60(%rsp)
leaq (,%rax,4), %rax
movq %rax, 0x58(%rsp)
movl %r14d, %eax
movq %rax, 0x50(%rsp)
movl 0x38(%rsp), %r13d
xorl %r14d, %r14d
leaq (%r14,%r14), %rax
movq %rax, 0x78(%rsp)
movq %r14, %rbp
shlq $0x4, %rbp
movq 0x28(%rsp), %r12
movq (%r12,%rbp), %rsi
leaq 0x98(%rsp), %rdi
movl 0x34(%rsp), %r15d
movl %r15d, %edx
movl 0x20f0(%rsp), %ecx
callq 0x16ac9
movq 0x78(%rsp), %rax
movq 0x8(%r12,%rax,8), %rsi
leaq 0x80(%rsp), %rdi
movl %r15d, %edx
movl 0x20f0(%rsp), %ecx
callq 0x16ac9
movl $0x4, %esi
movq 0x68(%rsp), %rdi
callq 0x3250
movq %rax, %r15
movq 0x70(%rsp), %rax
movq %r15, (%rax,%r14,8)
movq 0xa8(%rsp), %rsi
movq %r15, %rdi
movq 0x58(%rsp), %r12
movq %r12, %rdx
callq 0x32b0
movq 0x60(%rsp), %rax
leaq (%r15,%rax,4), %rdi
movq 0x90(%rsp), %rsi
movq %r12, %rdx
leaq 0x2a47f(%rip), %r12     # 0x58a56
leaq 0x2a4f6(%rip), %r15     # 0x58ad4
callq 0x32b0
movq 0x28(%rsp), %rax
movq (%rax,%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
leaq 0x10b0(%rsp), %rbp
movq %rbp, %rcx
callq 0xf02d
movq %rbp, %rdi
leaq 0x29221(%rip), %rsi     # 0x5782d
leaq 0x2c2ff(%rip), %rdx     # 0x5a912
movq %rbp, %rcx
callq 0xf02d
movq %rbp, %rdi
leaq 0x2c804(%rip), %rsi     # 0x5ae29
callq 0x3390
movq %rax, %rbp
movq %rax, %rdi
leaq 0x2a4a2(%rip), %rsi     # 0x58ad9
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x30a0
cmpl $0x2, %eax
jne 0x2e66f
movq (%rbx,%r14,8), %rax
movslq 0x24(%rsp), %rcx
movss 0x20(%rsp), %xmm0
ucomiss (%rax,%rcx,8), %xmm0
jbe 0x2e66a
addq %rcx, %rcx
movss %xmm0, (%rax,%rcx,4)
movq %rbp, %rdi
jmp 0x2e630
leaq 0x1(,%r14,2), %rax
movq 0x28(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
movq %r15, %rsi
movq %r12, %rdx
leaq 0xb0(%rsp), %r15
movq %r15, %rcx
callq 0xf02d
movq %r15, %rdi
leaq 0x2918d(%rip), %rsi     # 0x5782d
leaq 0x2c26b(%rip), %rdx     # 0x5a912
movq %r15, %rcx
callq 0xf02d
movq %r15, %rdi
leaq 0x2c770(%rip), %rsi     # 0x5ae29
callq 0x3390
movq %rax, %r15
movq %rax, %rdi
leaq 0x2a40e(%rip), %rsi     # 0x58ad9
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x30a0
cmpl $0x2, %eax
jne 0x2e70d
movq (%rbx,%r14,8), %rax
movslq 0x24(%rsp), %rcx
leaq (%rcx,%rcx), %rdx
movss 0x20(%rsp), %xmm0
ucomiss 0x4(%rax,%rdx,4), %xmm0
jbe 0x2e708
leaq 0x1(,%rcx,2), %rcx
movss %xmm0, (%rax,%rcx,4)
movq %r15, %rdi
jmp 0x2e6c4
cmpl $0x0, 0x38(%rsp)
movss 0x26b4a(%rip), %xmm1    # 0x55264
movss 0x268e6(%rip), %xmm2    # 0x55008
movsd 0x2a2b6(%rip), %xmm3    # 0x589e0
movsd 0x2a29e(%rip), %xmm4    # 0x589d0
jle 0x2e775
movq (%rbx,%r14,8), %rax
xorl %ecx, %ecx
movss (%rax,%rcx,8), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2e751
ucomiss 0x4(%rax,%rcx,8), %xmm1
jbe 0x2e751
movlps %xmm2, (%rax,%rcx,8)
jmp 0x2e76d
ucomiss %xmm0, %xmm1
jbe 0x2e768
movss 0x4(%rax,%rcx,8), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2e768
movsd %xmm3, (%rax,%rcx,8)
jmp 0x2e76d
movsd %xmm4, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r13
jne 0x2e73a
movq %rbp, %rdi
callq 0x3130
movq %r15, %rdi
callq 0x3130
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x98(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
incq %r14
cmpq 0x50(%rsp), %r14
jne 0x2e533
cmpl $0x0, 0x44(%rsp)
je 0x2e7e0
movq 0x28(%rsp), %rdi
callq 0x3040
movq 0x48(%rsp), %rax
addq $0x20b8, %rsp           # imm = 0x20B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq