// File: /workspace/github_c_makefile_star2_O2/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, %r14d
movl %r8d, %r12d
movl %esi, %ebp
movq %rdi, %rbx
movq %rdx, %rdi
movl %ecx, %edx
callq 0x1c922
movq %rax, 0x58(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x30(%rbx)
movl %ebp, 0x8(%rbx)
movslq %ebp, %r13
pushq $0x8
popq %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3250
movq %rax, %r15
movq %rax, 0x10(%rbx)
movl %r14d, 0x40(%rsp)
movl %r14d, %eax
movl %r12d, 0x3c(%rsp)
imull %r12d, %eax
leal (%rax,%rax,2), %ecx
movl %ecx, 0xc(%rbx)
movl %r13d, 0x18(%rbx)
imull 0x100(%rsp), %eax
cltd
movl 0x118(%rsp), %ecx
idivl %ecx
cltd
idivl %ecx
movl %ecx, %r14d
movl %eax, 0x1c(%rbx)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3250
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x38(%rsp)
movq %rax, %r12
movq %rbx, 0x78(%rsp)
movq %rax, 0x20(%rbx)
xorl %r14d, %r14d
testl %r13d, %r13d
movl $0x0, %ebx
cmovgl %r13d, %ebx
cmpq %r14, %rbx
je 0x1ed7f
movq 0x58(%rsp), %rax
movq (%rax,%r14,8), %r13
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbf36
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 0xea45
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 0xdccf
callq 0x34e0
movl %eax, %ebp
testb $0x1, %bpl
je 0x1ec44
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xcb93
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 0xfd21
movq 0x90(%rsp), %rax
movq %rax, (%r15,%r14,8)
movl 0x60(%rsp), %edx
movl 0x64(%rsp), %ecx
leaq 0x98(%rsp), %rdi
movq %r13, %rsi
movl 0x100(%rsp), %r8d
callq 0x1e6d7
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 0xdccf
testb $0x1, %bpl
je 0x1ed35
movq 0xc0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xb0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xcb93
movq 0xc0(%rsp), %rax
movq %rax, (%r12,%r14,8)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x98(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
incq %r14
jmp 0x1eb70
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