// File: /workspace/github_c_makefile_star2_O2/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, %ebp
movl %r8d, %r15d
movl %esi, %ebx
movq %rdi, %r14
movl 0x158(%rsp), %r12d
movl 0x150(%rsp), %r13d
movq %rdx, %rdi
movl %ecx, %edx
callq 0x1c922
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movl %ebx, 0x8(%r14)
movslq %ebx, %rbx
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x3250
movq %rax, 0xb8(%rsp)
movq %rax, 0x10(%r14)
movl %r15d, 0x28(%rsp)
movl %r15d, %eax
movl %ebp, 0x2c(%rsp)
imull %ebp, %eax
leal (%rax,%rax,2), %eax
movl %eax, 0xc(%r14)
movl %r13d, %eax
imull %r13d, %eax
leal 0x5(%r12), %esi
imull %eax, %esi
movl %ebx, %edi
callq 0x221e3
movq %rax, 0x18(%r14)
movq %r14, 0xa8(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rdx, 0x20(%r14)
xorl %ebp, %ebp
testl %ebx, %ebx
cmovlel %ebp, %ebx
movq %rbx, 0xc0(%rsp)
cmpq %rbp, 0xc0(%rsp)
je 0x1f66f
movq 0x50(%rsp), %rax
movq (%rax,%rbp,8), %rsi
leaq 0x58(%rsp), %rdi
movq %rsi, 0xc8(%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbf36
movl 0x58(%rsp), %r13d
movl 0x5c(%rsp), %r14d
cvtsi2ss %r13d, %xmm0
movss %xmm0, 0x80(%rsp)
movaps %xmm0, %xmm3
movss 0x30(%rsp), %xmm1
mulss %xmm1, %xmm3
cvtsi2ss %r14d, %xmm2
cvttss2si %xmm3, %eax
movss %xmm2, 0x90(%rsp)
mulss %xmm1, %xmm2
movaps %xmm2, 0x70(%rsp)
negl %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x24(%rsp)
cvttss2si %xmm2, %ebx
cvttps2dq %xmm3, %xmm1
cvtdq2ps %xmm1, %xmm1
movaps %xmm1, 0x40(%rsp)
callq 0x4c09
movaps %xmm0, 0x100(%rsp)
cvttss2si %xmm0, %r12d
movss 0x24(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
callq 0x4c09
negl %ebx
cvtsi2ss %ebx, %xmm2
movss %xmm2, 0x24(%rsp)
cvttss2si %xmm0, %r15d
cvttps2dq 0x70(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm1
movaps %xmm1, 0x40(%rsp)
movaps %xmm2, %xmm0
callq 0x4c09
movaps %xmm0, 0x70(%rsp)
cvttss2si %xmm0, %ebx
movss 0x24(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
callq 0x4c09
cvttss2si %xmm0, %eax
addl %r12d, %r15d
subl %r15d, %r13d
addl %ebx, %eax
subl %eax, %r14d
callq 0x34e0
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %edx, %r15d
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xe8(%rsp), %rdi
movl %r12d, %esi
movl %ebx, %edx
movl %r13d, %ecx
movl %r14d, %r8d
callq 0xdba7
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 0xc3ee
testl %r15d, %r15d
je 0x1f534
movq 0xe0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xd0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xcb93
cvtsi2ss %r13d, %xmm3
movss 0x80(%rsp), %xmm2
divss %xmm2, %xmm3
movss %xmm3, 0x24(%rsp)
cvtsi2ss %r14d, %xmm0
movss 0x90(%rsp), %xmm1
divss %xmm1, %xmm0
movaps %xmm0, %xmm4
movss %xmm0, 0x40(%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 0xfd21
movq 0xe0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0xb0(%rsp), %rax
movq (%rax,%rbp,8), %rsi
movss 0x2ca14(%rip), %xmm3    # 0x4c008
movaps %xmm3, %xmm2
divss 0x24(%rsp), %xmm2
divss 0x40(%rsp), %xmm3
movq 0xc8(%rsp), %rdi
movl 0x158(%rsp), %edx
movl 0x150(%rsp), %ecx
movl %r15d, %r8d
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
callq 0x1d25c
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0xf8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xe8(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
incq %rbp
jmp 0x1f3b0
movq 0x50(%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