// File: /workspace/github_c_makefile_star2_O3/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, 0x30(%rsp)
movl %ecx, %r15d
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 0x16ac9
movl (%r14), %r13d
movl 0x4(%r14), %ebp
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rbx)
movq $0x0, 0x38(%rbx)
movl %r13d, (%rbx)
movl %ebp, 0x4(%rbx)
movl $0x1, 0x8(%rbx)
movl $0x1, %edi
movl $0x8, %esi
callq 0x3250
movq %rax, 0x50(%rsp)
movq %rax, 0x10(%rbx)
movl %ebp, %eax
imull %r13d, %eax
leal (%rax,%rax,2), %eax
movl %eax, 0xc(%rbx)
movl %r15d, 0x2c(%rsp)
imull $0x5a, %r15d, %esi
addl $0x168, %esi            # imm = 0x168
movl $0x1, %edi
callq 0x311ee
movq %rax, 0x18(%rbx)
movq %rdx, 0x48(%rsp)
movq %rbx, 0x40(%rsp)
movq %rdx, 0x20(%rbx)
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
movl %r13d, 0x28(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, %xmm3
movaps 0x30(%rsp), %xmm2
mulss %xmm2, %xmm3
cvttss2si %xmm3, %eax
cvtsi2ss %ebp, %xmm1
movl %ebp, %r14d
movl %ebp, 0x24(%rsp)
movaps %xmm1, 0xa0(%rsp)
mulss %xmm1, %xmm2
movaps %xmm2, 0x30(%rsp)
negl %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x1c(%rsp)
cvttss2si %xmm2, %ebp
cvttps2dq %xmm3, %xmm1
cvtdq2ps %xmm1, %xmm1
movaps %xmm1, 0x90(%rsp)
callq 0xfa10
cvttss2si %xmm0, %r15d
movl %r15d, 0x20(%rsp)
movss 0x1c(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
callq 0xfa10
negl %ebp
xorps %xmm2, %xmm2
cvtsi2ss %ebp, %xmm2
movss %xmm2, 0x1c(%rsp)
cvttss2si %xmm0, %ebp
cvttps2dq 0x30(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm1
movaps %xmm1, 0x30(%rsp)
movaps %xmm2, %xmm0
callq 0xfa10
cvttss2si %xmm0, %ebx
movss 0x1c(%rsp), %xmm0
movaps 0x30(%rsp), %xmm1
callq 0xfa10
cvttss2si %xmm0, %eax
addl %r15d, %ebp
subl %ebp, %r13d
addl %ebx, %eax
movl %r14d, %ebp
subl %eax, %ebp
callq 0x34e0
movl %eax, %r15d
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
andl $-0x2, %r12d
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 0x20(%rsp), %esi
movl %ebx, %edx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0x18a89
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x60(%rsp), %rdi
movl 0x28(%rsp), %esi
movl 0x24(%rsp), %edx
callq 0x170fa
subl %r12d, %r15d
je 0x2ea09
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1786a
movd %ebp, %xmm0
movd %ebx, %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 0x2658d(%rip), %xmm3    # 0x55008
movaps %xmm3, %xmm2
divss %xmm5, %xmm2
divss %xmm4, %xmm3
movq 0x58(%rsp), %rdi
movl 0x2c(%rsp), %edx
movl %r15d, %ecx
callq 0x2b7b7
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x78(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xc0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0x40(%rsp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq