// File: /workspace/github_c_makefile_star2_O1/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 $0xc8, %rsp
movaps %xmm0, 0x20(%rsp)
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x34f0
cltd
idivl %ebp
movslq %edx, %rax
movq (%r14,%rax,8), %rsi
leaq 0x88(%rsp), %r14
movq %r14, %rdi
movq %rsi, 0x68(%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x160b6
movl (%r14), %r13d
movl 0x4(%r14), %ebp
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movl %r13d, (%rbx)
movl %ebp, 0x4(%rbx)
movl $0x1, 0x8(%rbx)
movl $0x1, %edi
movl $0x8, %esi
callq 0x3260
movq %rax, 0x60(%rsp)
movq %rax, 0x10(%rbx)
movl %ebp, %eax
imull %r13d, %eax
leal (%rax,%rax,2), %eax
movl %eax, 0xc(%rbx)
movl %r15d, 0x4c(%rsp)
imull $0x5a, %r15d, %esi
addl $0x168, %esi            # imm = 0x168
movl $0x1, %edi
callq 0x2f52e
movq %rax, 0x18(%rbx)
movq %rdx, 0x58(%rsp)
movq %rbx, 0x50(%rsp)
movq %rdx, 0x20(%rbx)
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
movl %r13d, 0x40(%rsp)
movss %xmm0, 0x48(%rsp)
movaps %xmm0, %xmm3
movaps 0x20(%rsp), %xmm2
mulss %xmm2, %xmm3
cvttss2si %xmm3, %eax
cvtsi2ss %ebp, %xmm1
movl %ebp, %r14d
movl %ebp, 0x3c(%rsp)
movss %xmm1, 0x44(%rsp)
mulss %xmm1, %xmm2
movaps %xmm2, 0x20(%rsp)
negl %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x18(%rsp)
cvttss2si %xmm2, %ebp
cvttps2dq %xmm3, %xmm1
cvtdq2ps %xmm1, %xmm1
movaps %xmm1, 0xa0(%rsp)
callq 0xf201
cvttss2si %xmm0, %r15d
movl %r15d, 0x1c(%rsp)
movss 0x18(%rsp), %xmm0
movaps 0xa0(%rsp), %xmm1
callq 0xf201
negl %ebp
xorps %xmm2, %xmm2
cvtsi2ss %ebp, %xmm2
movss %xmm2, 0x18(%rsp)
cvttss2si %xmm0, %ebp
cvttps2dq 0x20(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm1
movaps %xmm1, 0x20(%rsp)
movaps %xmm2, %xmm0
callq 0xf201
cvttss2si %xmm0, %ebx
movss 0x18(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0xf201
cvttss2si %xmm0, %eax
addl %r15d, %ebp
subl %ebp, %r13d
addl %ebx, %eax
movl %r14d, %ebp
subl %eax, %ebp
callq 0x34f0
movl %eax, %r15d
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
andl $-0x2, %r12d
leaq 0x88(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
movl 0x1c(%rsp), %esi
movl %ebx, 0x20(%rsp)
movl %ebx, %edx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0x181f7
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x70(%rsp), %rdi
movl 0x40(%rsp), %esi
movl 0x3c(%rsp), %edx
callq 0x1676b
subl %r12d, %r15d
je 0x2cda5
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x16f91
xorps %xmm1, %xmm1
cvtsi2ssl 0x20(%rsp), %xmm1
cvtsi2ss %ebp, %xmm4
movss 0x44(%rsp), %xmm0
divss %xmm0, %xmm1
divss %xmm0, %xmm4
divss %xmm4, %xmm1
xorps %xmm0, %xmm0
cvtsi2ssl 0x1c(%rsp), %xmm0
movss 0x48(%rsp), %xmm2
divss %xmm2, %xmm0
cvtsi2ss %r13d, %xmm5
divss %xmm2, %xmm5
divss %xmm5, %xmm0
movq 0x80(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %rax, (%rcx)
movq 0x58(%rsp), %rax
movq (%rax), %rsi
movss 0x26204(%rip), %xmm3    # 0x53008
movaps %xmm3, %xmm2
divss %xmm5, %xmm2
divss %xmm4, %xmm3
movq 0x68(%rsp), %rdi
movl 0x4c(%rsp), %edx
movl %r15d, %ecx
callq 0x29fcd
movq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x88(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
movq 0xc0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xb0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
movq 0x50(%rsp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq