// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/data.c
// Function: load_data_region
data load_data_region(int n, char **paths, int m, int w, int h, int size, 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;


    int k = size*size*(5+classes);
    d.y = make_matrix(n, k);
    for(i = 0; i < n; ++i){
        image orig = load_image_color(random_paths[i], 0, 0);

        int oh = orig.h;
        int ow = orig.w;

        int dw = (ow*jitter);
        int dh = (oh*jitter);

        int pleft  = rand_uniform(-dw, dw);
        int pright = rand_uniform(-dw, dw);
        int ptop   = rand_uniform(-dh, dh);
        int pbot   = rand_uniform(-dh, dh);

        int swidth =  ow - pleft - pright;
        int sheight = oh - ptop - pbot;

        float sx = (float)swidth  / ow;
        float sy = (float)sheight / oh;

        int flip = rand()%2;
        image cropped = crop_image(orig, pleft, ptop, swidth, sheight);

        float dx = ((float)pleft/ow)/sx;
        float dy = ((float)ptop /oh)/sy;

        image sized = resize_image(cropped, w, h);
        if(flip) flip_image(sized);
        random_distort_image(sized, hue, saturation, exposure);
        d.X.vals[i] = sized.data;

        fill_truth_region(random_paths[i], d.y.vals[i], classes, size, flip, dx, dy, 1./sx, 1./sy);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movss %xmm3, 0x3c(%rsp)
movss %xmm2, 0x38(%rsp)
movss %xmm1, 0x34(%rsp)
movss %xmm0, 0x30(%rsp)
movl %r9d, %r15d
movl %r8d, %r12d
movl %esi, %ebp
movq %rdi, %r14
movl 0x150(%rsp), %r13d
movq %rdx, %rdi
movl %ecx, %edx
callq 0x2af92
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movl %ebp, 0x8(%r14)
movslq %ebp, %rbx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x3250
movq %rax, 0xc0(%rsp)
movq %rax, 0x10(%r14)
movl %r12d, 0x28(%rsp)
movl %r12d, %eax
movl %r15d, 0x2c(%rsp)
imull %r15d, %eax
leal (%rax,%rax,2), %eax
movl %eax, 0xc(%r14)
imull %r13d, %r13d
movl 0x158(%rsp), %ecx
leal 0x5(%rcx), %esi
imull %r13d, %esi
movl %ebx, %edi
callq 0x311ee
movq %rax, 0x18(%r14)
movq %r14, 0xa8(%rsp)
movq %rdx, 0xb8(%rsp)
movq %rdx, 0x20(%r14)
testl %ebx, %ebx
jle 0x2e41f
movl %ebp, %eax
movq %rax, 0xb0(%rsp)
xorl %r12d, %r12d
movq 0x40(%rsp), %rax
movq (%rax,%r12,8), %rsi
leaq 0x48(%rsp), %rdi
movq %rsi, 0xc8(%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16ac9
movl 0x48(%rsp), %r14d
movl 0x4c(%rsp), %ebp
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x80(%rsp)
movaps %xmm0, %xmm3
movss 0x30(%rsp), %xmm1
mulss %xmm1, %xmm3
xorps %xmm2, %xmm2
cvtsi2ss %ebp, %xmm2
cvttss2si %xmm3, %eax
movss %xmm2, 0x90(%rsp)
mulss %xmm1, %xmm2
movaps %xmm2, 0x70(%rsp)
negl %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x20(%rsp)
cvttss2si %xmm2, %ebx
cvttps2dq %xmm3, %xmm1
cvtdq2ps %xmm1, %xmm1
movaps %xmm1, 0x60(%rsp)
callq 0xfa10
movaps %xmm0, 0x100(%rsp)
cvttss2si %xmm0, %r13d
movl %r13d, 0x24(%rsp)
movss 0x20(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
callq 0xfa10
negl %ebx
xorps %xmm2, %xmm2
cvtsi2ss %ebx, %xmm2
movss %xmm2, 0x20(%rsp)
cvttss2si %xmm0, %ebx
cvttps2dq 0x70(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm1
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, %xmm0
callq 0xfa10
movaps %xmm0, 0x70(%rsp)
cvttss2si %xmm0, %r15d
movss 0x20(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
callq 0xfa10
cvttss2si %xmm0, %eax
addl %r13d, %ebx
subl %ebx, %r14d
addl %r15d, %eax
subl %eax, %ebp
callq 0x34e0
movl %eax, %ebx
movl %eax, %r13d
shrl $0x1f, %r13d
addl %eax, %r13d
andl $-0x2, %r13d
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xe8(%rsp), %rdi
movl 0x24(%rsp), %esi
movl %r15d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x18a89
movq 0xf8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xe8(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xd0(%rsp), %rdi
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
callq 0x170fa
subl %r13d, %ebx
je 0x2e2d9
movq 0xe0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xd0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1786a
cvtsi2ss %r14d, %xmm3
movss 0x80(%rsp), %xmm2
divss %xmm2, %xmm3
movss %xmm3, 0x24(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movss 0x90(%rsp), %xmm1
divss %xmm1, %xmm0
movaps %xmm0, %xmm4
movss %xmm0, 0x20(%rsp)
cvttps2dq 0x100(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm0
divss %xmm2, %xmm0
divss %xmm3, %xmm0
movaps %xmm0, 0x80(%rsp)
cvttps2dq 0x70(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm0
divss %xmm1, %xmm0
divss %xmm4, %xmm0
movaps %xmm0, 0x90(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xd0(%rsp), %xmm0
movups %xmm0, (%rsp)
movss 0x34(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
movss 0x3c(%rsp), %xmm2
callq 0x1b0ee
movq 0xe0(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
movq 0xb8(%rsp), %rax
movq (%rax,%r12,8), %rsi
movss 0x26c6d(%rip), %xmm3    # 0x55008
movaps %xmm3, %xmm2
divss 0x24(%rsp), %xmm2
divss 0x20(%rsp), %xmm3
movq 0xc8(%rsp), %rdi
movl 0x158(%rsp), %edx
movl 0x150(%rsp), %ecx
movl %ebx, %r8d
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
callq 0x2b93b
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0xf8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xe8(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
incq %r12
cmpq %r12, 0xb0(%rsp)
jne 0x2e14b
movq 0x40(%rsp), %rdi
callq 0x3040
movq 0xa8(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq