// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/data.c
// Function: load_data_detection
data load_data_detection(int n, char **paths, int m, int w, int h, int boxes, int classes, float jitter, float hue, float saturation, float exposure)
{
    char **random_paths = get_random_paths(paths, n, m);
    int i;
    data d = {0};
    d.shallow = 0;

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

    d.y = make_matrix(n, 5*boxes);
    for(i = 0; i < n; ++i){
        image orig = load_image_color(random_paths[i], 0, 0);
        image sized = make_image(w, h, orig.c);
        fill_image(sized, .5);

        float dw = jitter * orig.w;
        float dh = jitter * orig.h;

        float new_ar = (orig.w + rand_uniform(-dw, dw)) / (orig.h + rand_uniform(-dh, dh));
        //float scale = rand_uniform(.25, 2);
        float scale = 1;

        float nw, nh;

        if(new_ar < 1){
            nh = scale * h;
            nw = nh * new_ar;
        } else {
            nw = scale * w;
            nh = nw / new_ar;
        }

        float dx = rand_uniform(0, w - nw);
        float dy = rand_uniform(0, h - nh);

        place_image(orig, nw, nh, dx, dy, sized);

        random_distort_image(sized, hue, saturation, exposure);

        int flip = rand()%2;
        if(flip) flip_image(sized);
        d.X.vals[i] = sized.data;


        fill_truth_detection(random_paths[i], boxes, d.y.vals[i], classes, flip, -dx/w, -dy/h, nw/w, nh/h);

        free_image(orig);
    }
    free(random_paths);
    return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movss %xmm3, 0x64(%rsp)
movss %xmm2, 0x60(%rsp)
movss %xmm1, 0x5c(%rsp)
movss %xmm0, 0x58(%rsp)
movl %r9d, %ebx
movl %r8d, %r12d
movl %esi, %r15d
movq %rdi, %r14
movq %rdx, %rdi
movl %ecx, %edx
callq 0x2af92
movq %rax, 0x80(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movl %r15d, 0x8(%r14)
movslq %r15d, %rbp
movl $0x8, %esi
movq %rbp, %rdi
callq 0x3250
movq %rax, %r13
movq %rax, 0x10(%r14)
movl %r12d, 0x38(%rsp)
movl %r12d, %eax
movl %ebx, 0x3c(%rsp)
imull %ebx, %eax
leal (%rax,%rax,2), %eax
movl %eax, 0xc(%r14)
movl 0x130(%rsp), %eax
leal (%rax,%rax,4), %esi
movl %ebp, %edi
callq 0x311ee
movq %rax, 0x18(%r14)
movq %r14, 0xd8(%rsp)
movq %rdx, 0x20(%r14)
testl %ebp, %ebp
jle 0x2ee7c
movq %rdx, %rbx
xorps %xmm0, %xmm0
cvtsi2ssl 0x3c(%rsp), %xmm0
movaps %xmm0, 0xc0(%rsp)
xorps %xmm0, %xmm0
cvtsi2ssl 0x38(%rsp), %xmm0
movss %xmm0, 0x34(%rsp)
movl %r15d, %r14d
xorl %r12d, %r12d
movq 0x80(%rsp), %rax
movq (%rax,%r12,8), %r15
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16ac9
movl 0x90(%rsp), %ecx
leaq 0x68(%rsp), %rdi
movl 0x38(%rsp), %esi
movl 0x3c(%rsp), %edx
callq 0x15d43
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, (%rsp)
movss 0x26649(%rip), %xmm0    # 0x55264
callq 0x1918e
xorps %xmm1, %xmm1
cvtsi2ssl 0x88(%rsp), %xmm1
movss %xmm1, 0x40(%rsp)
xorps %xmm2, %xmm2
cvtsi2ssl 0x8c(%rsp), %xmm2
movss 0x58(%rsp), %xmm0
mulss %xmm0, %xmm1
mulss %xmm0, %xmm2
movaps %xmm2, 0xb0(%rsp)
movaps %xmm1, %xmm0
movaps 0x26432(%rip), %xmm2    # 0x55090
xorps %xmm2, %xmm0
callq 0xfa10
xorps %xmm1, %xmm1
cvtsi2ssl 0x8c(%rsp), %xmm1
movss %xmm1, 0xa0(%rsp)
addss 0x40(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
movaps 0xb0(%rsp), %xmm1
movaps %xmm1, %xmm0
xorps 0x263f8(%rip), %xmm0    # 0x55090
callq 0xfa10
movaps 0x40(%rsp), %xmm1
addss 0xa0(%rsp), %xmm0
divss %xmm0, %xmm1
movss 0x26351(%rip), %xmm0    # 0x55008
ucomiss %xmm1, %xmm0
ja 0x2eccf
movss 0x34(%rsp), %xmm3
movaps %xmm3, %xmm4
movaps 0xc0(%rsp), %xmm2
jmp 0x2ece4
movaps %xmm1, %xmm4
movaps 0xc0(%rsp), %xmm2
mulss %xmm2, %xmm4
movss 0x34(%rsp), %xmm3
movss %xmm4, 0xb0(%rsp)
movaps %xmm3, %xmm0
divss %xmm1, %xmm0
cmpltss 0x2630b(%rip), %xmm1    # 0x55008
movaps %xmm1, %xmm5
andnps %xmm0, %xmm1
andps %xmm2, %xmm5
orps %xmm1, %xmm5
movaps %xmm5, 0x40(%rsp)
movaps %xmm3, %xmm1
subss %xmm4, %xmm1
xorps %xmm0, %xmm0
callq 0xfa10
movaps %xmm0, 0xa0(%rsp)
movaps 0xc0(%rsp), %xmm1
subss 0x40(%rsp), %xmm1
xorps %xmm0, %xmm0
callq 0xfa10
cvttss2si 0xb0(%rsp), %edi
cvttss2si 0x40(%rsp), %esi
cvttss2si 0xa0(%rsp), %edx
movaps %xmm0, 0xe0(%rsp)
cvttss2si %xmm0, %ecx
movq 0x78(%rsp), %rax
movq %rax, 0x28(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x88(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x18673
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, (%rsp)
movss 0x5c(%rsp), %xmm0
movss 0x60(%rsp), %xmm1
movss 0x64(%rsp), %xmm2
callq 0x1b0ee
callq 0x34e0
movl %eax, %ebp
shrl $0x1f, %eax
addl %ebp, %eax
andl $-0x2, %eax
subl %eax, %ebp
je 0x2ede6
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x68(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1786a
movq 0x78(%rsp), %rax
movq %rax, (%r13,%r12,8)
movq (%rbx,%r12,8), %rdx
movaps 0x26295(%rip), %xmm0    # 0x55090
movaps 0xa0(%rsp), %xmm4
xorps %xmm0, %xmm4
movss 0x34(%rsp), %xmm3
divss %xmm3, %xmm4
movaps 0xe0(%rsp), %xmm1
xorps %xmm0, %xmm1
movaps 0xc0(%rsp), %xmm0
divss %xmm0, %xmm1
movss 0xb0(%rsp), %xmm2
divss %xmm3, %xmm2
movaps 0x40(%rsp), %xmm3
divss %xmm0, %xmm3
movq %r15, %rdi
movl 0x130(%rsp), %esi
movl %ebp, %r8d
movaps %xmm4, %xmm0
callq 0x2c748
movq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x88(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
incq %r12
cmpq %r12, %r14
jne 0x2ebc7
movq 0x80(%rsp), %rdi
callq 0x3040
movq 0xd8(%rsp), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq