// File: /workspace/github_c_makefile_star2_O1/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 0x2c7f8
leal (%r14,%r14), %esi
movq %rdx, %rdi
movl %ecx, %edx
callq 0x29752
movq %rax, 0x28(%rsp)
jmp 0x2c7fd
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 0x3260
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 0x2f52e
movq %rax, 0x18(%r12)
movq %r12, 0x48(%rsp)
movq %rdx, 0x20(%r12)
testl %r14d, %r14d
jle 0x2cb5f
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 0x160b6
movq 0x78(%rsp), %rax
movq 0x8(%r12,%rax,8), %rsi
leaq 0x80(%rsp), %rdi
movl %r15d, %edx
movl 0x20f0(%rsp), %ecx
callq 0x160b6
movl $0x4, %esi
movq 0x68(%rsp), %rdi
callq 0x3260
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 0x32c0
movq 0x60(%rsp), %rax
leaq (%r15,%rax,4), %rdi
movq 0x90(%rsp), %rsi
movq %r12, %rdx
leaq 0x2a008(%rip), %r12     # 0x56956
leaq 0x2a07f(%rip), %r15     # 0x569d4
callq 0x32c0
movq 0x28(%rsp), %rax
movq (%rax,%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
leaq 0x10b0(%rsp), %rbp
movq %rbp, %rcx
callq 0xe842
movq %rbp, %rdi
leaq 0x28dd2(%rip), %rsi     # 0x55755
leaq 0x2be30(%rip), %rdx     # 0x587ba
movq %rbp, %rcx
callq 0xe842
movq %rbp, %rdi
leaq 0x2c335(%rip), %rsi     # 0x58cd1
callq 0x33a0
movq %rax, %rbp
movq %rax, %rdi
leaq 0x2a02b(%rip), %rsi     # 0x569d9
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x30b0
cmpl $0x2, %eax
jne 0x2c9e6
movq (%rbx,%r14,8), %rax
movslq 0x24(%rsp), %rcx
movss 0x20(%rsp), %xmm0
ucomiss (%rax,%rcx,8), %xmm0
jbe 0x2c9e1
addq %rcx, %rcx
movss %xmm0, (%rax,%rcx,4)
movq %rbp, %rdi
jmp 0x2c9a7
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 0xe842
movq %r15, %rdi
leaq 0x28d3e(%rip), %rsi     # 0x55755
leaq 0x2bd9c(%rip), %rdx     # 0x587ba
movq %r15, %rcx
callq 0xe842
movq %r15, %rdi
leaq 0x2c2a1(%rip), %rsi     # 0x58cd1
callq 0x33a0
movq %rax, %r15
movq %rax, %rdi
leaq 0x29f97(%rip), %rsi     # 0x569d9
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x30b0
cmpl $0x2, %eax
movabsq $0x3f80000000000000, %r12 # imm = 0x3F80000000000000
jne 0x2caa9
movq (%rbx,%r14,8), %rax
movslq 0x24(%rsp), %rcx
leaq (%rcx,%rcx), %rdx
movss 0x20(%rsp), %xmm0
ucomiss 0x4(%rax,%rdx,4), %xmm0
jbe 0x2ca89
leaq 0x1(,%rcx,2), %rcx
movss %xmm0, (%rax,%rcx,4)
movq %r15, %rdi
leaq 0x29f46(%rip), %rsi     # 0x569d9
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0x30b0
cmpl $0x2, %eax
je 0x2ca62
cmpl $0x0, 0x38(%rsp)
movss 0x2677e(%rip), %xmm1    # 0x53234
movabsq $-0x3b65bfff3b65c000, %rdx # imm = 0xC49A4000C49A4000
jle 0x2cb05
movq (%rbx,%r14,8), %rax
xorl %ecx, %ecx
movss (%rax,%rcx,8), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2cae3
ucomiss 0x4(%rax,%rcx,8), %xmm1
jbe 0x2cae3
movq $0x3f800000, (%rax,%rcx,8) # imm = 0x3F800000
jmp 0x2cafd
ucomiss %xmm0, %xmm1
jbe 0x2caf9
movss 0x4(%rax,%rcx,8), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2caf9
movq %r12, (%rax,%rcx,8)
jmp 0x2cafd
movq %rdx, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r13
jne 0x2cac8
movq %rbp, %rdi
callq 0x3140
movq %r15, %rdi
callq 0x3140
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x98(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
incq %r14
cmpq 0x50(%rsp), %r14
jne 0x2c8aa
cmpl $0x0, 0x44(%rsp)
je 0x2cb70
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