// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/data.c
// Function: load_data_seg
data load_data_seg(int n, char **paths, int m, int w, int h, int classes, int min, int max, float angle, float aspect, float hue, float saturation, float exposure, int div)
{
    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;


    d.y.rows = n;
    d.y.cols = h*w*classes/div/div;
    d.y.vals = calloc(d.X.rows, sizeof(float*));

    for(i = 0; i < n; ++i){
        image orig = load_image_color(random_paths[i], 0, 0);
        augment_args a = random_augment_args(orig, angle, aspect, min, max, w, h);
        image sized = rotate_crop_image(orig, a.rad, a.scale, a.w, a.h, a.dx, a.dy, a.aspect);

        int flip = rand()%2;
        if(flip) flip_image(sized);
        random_distort_image(sized, hue, saturation, exposure);
        d.X.vals[i] = sized.data;

        image mask = get_segmentation_image(random_paths[i], orig.w, orig.h, classes);
        //image mask = make_image(orig.w, orig.h, classes+1);
        image sized_m = rotate_crop_image(mask, a.rad, a.scale/div, a.w/div, a.h/div, a.dx/div, a.dy/div, a.aspect);

        if(flip) flip_image(sized_m);
        d.y.vals[i] = sized_m.data;

        free_image(orig);
        free_image(mask);

        /*
           image rgb = mask_to_rgb(sized_m, classes);
           show_image(rgb, "part");
           show_image(sized, "orig");
           cvWaitKey(0);
           free_image(rgb);
         */
    }
    free(random_paths);
    return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movss %xmm4, 0x54(%rsp)
movss %xmm3, 0x50(%rsp)
movss %xmm2, 0x4c(%rsp)
movss %xmm1, 0x48(%rsp)
movss %xmm0, 0x44(%rsp)
movl %r9d, %r15d
movl %r8d, %r12d
movl %esi, %ebx
movq %rdi, %r14
movq %rdx, %rdi
movl %ecx, %edx
callq 0x2af92
movq %rax, 0x58(%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, %rbp
movl $0x8, %esi
movq %rbp, %rdi
callq 0x3250
movq %rax, %r13
movq %rax, 0x10(%r14)
movl %r15d, 0x40(%rsp)
movl %r15d, %eax
movl %r12d, 0x3c(%rsp)
imull %r12d, %eax
leal (%rax,%rax,2), %ecx
movl %ecx, 0xc(%r14)
movl %ebp, 0x18(%r14)
imull 0x100(%rsp), %eax
cltd
movl 0x118(%rsp), %ecx
idivl %ecx
cltd
idivl %ecx
movl %eax, 0x1c(%r14)
movl $0x8, %esi
movq %rbp, %rdi
callq 0x3250
movq %r14, 0x78(%rsp)
movq %rax, 0x20(%r14)
testl %ebp, %ebp
jle 0x2db0e
movq %rax, %r15
xorps %xmm0, %xmm0
cvtsi2ssl 0x118(%rsp), %xmm0
movss %xmm0, 0x38(%rsp)
movl %ebx, %r14d
xorl %r12d, %r12d
movq 0x58(%rsp), %rax
movq (%rax,%r12,8), %rbx
leaq 0x60(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16ac9
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x1c(%rsp), %rdi
movss 0x44(%rsp), %xmm0
movss 0x48(%rsp), %xmm1
movl 0x108(%rsp), %esi
movl 0x110(%rsp), %edx
movl 0x3c(%rsp), %ecx
movl 0x40(%rsp), %r8d
callq 0x19c90
movss 0x28(%rsp), %xmm0
movss 0x24(%rsp), %xmm1
movl 0x1c(%rsp), %esi
movl 0x20(%rsp), %edx
movss 0x2c(%rsp), %xmm2
movss 0x30(%rsp), %xmm3
movss 0x34(%rsp), %xmm4
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm5
movups %xmm5, (%rsp)
leaq 0x80(%rsp), %rdi
callq 0x18c21
callq 0x34e0
movl %eax, %ebp
testb $0x1, %bpl
je 0x2d9ce
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1786a
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
movss 0x4c(%rsp), %xmm0
movss 0x50(%rsp), %xmm1
movss 0x54(%rsp), %xmm2
callq 0x1b0ee
movq 0x90(%rsp), %rax
movq %rax, (%r13,%r12,8)
movl 0x60(%rsp), %edx
movl 0x64(%rsp), %ecx
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
movl 0x100(%rsp), %r8d
callq 0x2d2d0
movss 0x28(%rsp), %xmm0
movss 0x24(%rsp), %xmm1
movss 0x38(%rsp), %xmm4
divss %xmm4, %xmm1
movl 0x1c(%rsp), %eax
movl 0x20(%rsp), %ecx
cltd
movl 0x118(%rsp), %edi
idivl %edi
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %edi
movss 0x2c(%rsp), %xmm2
divss %xmm4, %xmm2
movss 0x30(%rsp), %xmm3
divss %xmm4, %xmm3
movss 0x34(%rsp), %xmm4
movq 0xa8(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movups 0x98(%rsp), %xmm5
movups %xmm5, (%rsp)
leaq 0xb0(%rsp), %rdi
movl %eax, %edx
callq 0x18c21
testb $0x1, %bpl
je 0x2dac0
movq 0xc0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xb0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1786a
movq 0xc0(%rsp), %rax
movq %rax, (%r15,%r12,8)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x98(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
incq %r12
cmpq %r12, %r14
jne 0x2d903
movq 0x58(%rsp), %rdi
callq 0x3040
movq 0x78(%rsp), %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq