// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/data.c
// Function: load_data_swag
data load_data_swag(char **paths, int n, int classes, float jitter)
{
    int index = rand()%n;
    char *random_path = paths[index];

    image orig = load_image_color(random_path, 0, 0);
    int h = orig.h;
    int w = orig.w;

    data d = {0};
    d.shallow = 0;
    d.w = w;
    d.h = h;

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

    int k = (4+classes)*90;
    d.y = make_matrix(1, k);

    int dw = w*jitter;
    int dh = h*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 =  w - pleft - pright;
    int sheight = h - ptop - pbot;

    float sx = (float)swidth  / w;
    float sy = (float)sheight / h;

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

    float dx = ((float)pleft/w)/sx;
    float dy = ((float)ptop /h)/sy;

    image sized = resize_image(cropped, w, h);
    if(flip) flip_image(sized);
    d.X.vals[0] = sized.data;

    fill_truth_swag(random_path, d.y.vals[0], classes, flip, dx, dy, 1./sx, 1./sy);

    free_image(orig);
    free_image(cropped);

    return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movaps %xmm0, 0x20(%rsp)
movl %ecx, %r12d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x34e0
cltd
idivl %ebp
movslq %edx, %rax
movq (%r14,%rax,8), %rsi
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movq %rsi, 0x58(%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbf36
movl (%r14), %r13d
movl 0x4(%r14), %ecx
xorps %xmm0, %xmm0
andq $0x0, 0x38(%rbx)
movups %xmm0, 0x28(%rbx)
movl %r13d, (%rbx)
movl %ecx, 0x4(%rbx)
movl %ecx, %r15d
movl $0x1, 0x8(%rbx)
pushq $0x1
popq %rdi
pushq $0x8
popq %rsi
callq 0x3250
movq %rax, 0x50(%rsp)
movq %rax, 0x10(%rbx)
movl %r15d, %eax
imull %r13d, %eax
leal (%rax,%rax,2), %eax
movl %eax, 0xc(%rbx)
movl %r12d, 0x3c(%rsp)
imull $0x5a, %r12d, %esi
addl $0x168, %esi            # imm = 0x168
pushq $0x1
popq %rdi
callq 0x221e3
movq %rax, 0x18(%rbx)
movq %rdx, 0x48(%rsp)
movq %rbx, 0x40(%rsp)
movq %rdx, 0x20(%rbx)
cvtsi2ss %r13d, %xmm0
movl %r13d, 0x38(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, %xmm3
movaps 0x20(%rsp), %xmm2
mulss %xmm2, %xmm3
cvttss2si %xmm3, %eax
cvtsi2ss %r15d, %xmm1
movl %r15d, %ebx
movaps %xmm1, 0xa0(%rsp)
mulss %xmm1, %xmm2
movaps %xmm2, 0x20(%rsp)
negl %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x1c(%rsp)
cvttss2si %xmm2, %ebp
cvttps2dq %xmm3, %xmm1
cvtdq2ps %xmm1, %xmm1
movaps %xmm1, 0x90(%rsp)
callq 0x4c09
cvttss2si %xmm0, %r15d
movss 0x1c(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
callq 0x4c09
negl %ebp
cvtsi2ss %ebp, %xmm2
movss %xmm2, 0x1c(%rsp)
cvttss2si %xmm0, %ebp
cvttps2dq 0x20(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm1
movaps %xmm1, 0x20(%rsp)
movaps %xmm2, %xmm0
callq 0x4c09
cvttss2si %xmm0, %r12d
movss 0x1c(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x4c09
cvttss2si %xmm0, %eax
addl %r15d, %ebp
subl %ebp, %r13d
addl %r12d, %eax
movl %ebx, %ebp
subl %eax, %ebp
callq 0x34e0
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %edx, 0x1c(%rsp)
leaq 0x78(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
movl %r15d, 0x20(%rsp)
movl %r15d, %esi
movl %r12d, %edx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0xdba7
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x60(%rsp), %rdi
movl 0x38(%rsp), %esi
movl %ebx, %edx
movl 0x1c(%rsp), %ebx
callq 0xc3ee
testl %ebx, %ebx
je 0x1fc4b
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xcb93
movd %ebp, %xmm0
movd %r12d, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm1
movaps 0xa0(%rsp), %xmm0
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
divps %xmm0, %xmm1
movaps %xmm1, %xmm4
shufps $0x55, %xmm1, %xmm4     # xmm4 = xmm4[1,1],xmm1[1,1]
divss %xmm4, %xmm1
movd %r13d, %xmm0
movd 0x20(%rsp), %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
cvtdq2ps %xmm2, %xmm0
movaps 0xb0(%rsp), %xmm2
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
divps %xmm2, %xmm0
movaps %xmm0, %xmm5
shufps $0x55, %xmm0, %xmm5     # xmm5 = xmm5[1,1],xmm0[1,1]
divss %xmm5, %xmm0
movq 0x70(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rax, (%rcx)
movq 0x48(%rsp), %rax
movq (%rax), %rsi
movss 0x2c34a(%rip), %xmm3    # 0x4c008
movaps %xmm3, %xmm2
divss %xmm5, %xmm2
divss %xmm4, %xmm3
movq 0x58(%rsp), %rdi
movl 0x3c(%rsp), %edx
movl %ebx, %ecx
callq 0x1d0ef
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x78(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xc0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0x40(%rsp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq