// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/data.c
// Function: fill_truth_mask
void fill_truth_mask(char *path, int num_boxes, float *truth, int classes, int w, int h, augment_args aug, int flip, int mw, int mh)
{
    char labelpath[4096];
    find_replace(path, "images", "mask", labelpath);
    find_replace(labelpath, "JPEGImages", "mask", labelpath);
    find_replace(labelpath, ".jpg", ".txt", labelpath);
    find_replace(labelpath, ".JPG", ".txt", labelpath);
    find_replace(labelpath, ".JPEG", ".txt", labelpath);
    FILE *file = fopen(labelpath, "r");
    if(!file) file_error(labelpath);
    char buff[32788];
    int id;
    int i = 0;
    image part = make_image(w, h, 1);
    while((fscanf(file, "%d %s", &id, buff) == 2) && i < num_boxes){
        int n = 0;
        int *rle = read_intlist(buff, &n, 0);
        load_rle(part, rle, n);
        image sized = rotate_crop_image(part, aug.rad, aug.scale, aug.w, aug.h, aug.dx, aug.dy, aug.aspect);
        if(flip) flip_image(sized);
        box b = bound_image(sized);
        if(b.w > 0){
            image crop = crop_image(sized, b.x, b.y, b.w, b.h);
            image mask = resize_image(crop, mw, mh);
            truth[i*(4 + mw*mh + 1) + 0] = (b.x + b.w/2.)/sized.w;
            truth[i*(4 + mw*mh + 1) + 1] = (b.y + b.h/2.)/sized.h;
            truth[i*(4 + mw*mh + 1) + 2] = b.w/sized.w;
            truth[i*(4 + mw*mh + 1) + 3] = b.h/sized.h;
            int j;
            for(j = 0; j < mw*mh; ++j){
                truth[i*(4 + mw*mh + 1) + 4 + j] = mask.data[j];
            }
            truth[i*(4 + mw*mh + 1) + 4 + mw*mh] = id;
            free_image(crop);
            free_image(mask);
            ++i;
        }
        free_image(sized);
        free(rle);
    }
    fclose(file);
    free_image(part);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x90f8, %rsp           # imm = 0x90F8
movl %r9d, %ebp
movl %r8d, %r14d
movq %rdx, 0x60(%rsp)
movl %esi, 0x40(%rsp)
movl 0x9158(%rsp), %ebx
leaq 0x9130(%rsp), %r13
leaq 0x31fcc(%rip), %rsi     # 0x4f99f
leaq 0x31fe9(%rip), %r12     # 0x4f9c3
leaq 0xe0(%rsp), %r15
movq %r12, %rdx
movq %r15, %rcx
callq 0x42ea
leaq 0x31fb9(%rip), %rsi     # 0x4f9ad
movq %r15, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x42ea
leaq 0x30d43(%rip), %rsi     # 0x4e74c
leaq 0x33db9(%rip), %r12     # 0x517c9
movq %r15, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x42ea
leaq 0x31f93(%rip), %rsi     # 0x4f9b8
movq %r15, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x42ea
leaq 0x31f83(%rip), %rsi     # 0x4f9bd
movq %r15, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x42ea
leaq 0x3429a(%rip), %rsi     # 0x51ce9
movq %r15, %rdi
callq 0x3390
movq %rax, 0x68(%rsp)
testq %rax, %rax
jne 0x1da6e
leaq 0xe0(%rsp), %rdi
callq 0x3d0f
leaq 0x70(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r14d, %esi
movl %ebp, %edx
callq 0xb45a
movss 0xc(%r13), %xmm0
movss %xmm0, 0x3c(%rsp)
movss 0x8(%r13), %xmm0
movss %xmm0, 0x38(%rsp)
movl (%r13), %eax
movl %eax, 0x34(%rsp)
movl 0x4(%r13), %eax
movl %eax, 0x30(%rsp)
movss 0x10(%r13), %xmm0
movss %xmm0, 0x2c(%rsp)
movss 0x14(%r13), %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x18(%r13), %xmm0
movss %xmm0, 0x24(%rsp)
movl 0x9160(%rsp), %r14d
movl %r14d, %eax
imull %ebx, %eax
leal 0x5(%rax), %ecx
movl %ecx, 0x20(%rsp)
testl %eax, %eax
movl $0x0, %r12d
movq %rax, 0x88(%rsp)
cmovgl %eax, %r12d
leaq 0x10e0(%rsp), %rbp
xorl %r13d, %r13d
movl %ebx, %r15d
movq 0x68(%rsp), %rdi
leaq 0x31eb9(%rip), %rsi     # 0x4f9c8
leaq 0x44(%rsp), %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x30a0
cmpl $0x2, %eax
jne 0x1dd6a
cmpl 0x40(%rsp), %r13d
jge 0x1dd6a
andl $0x0, 0x1c(%rsp)
movq %rbp, %rbx
movq %rbp, %rdi
leaq 0x1c(%rsp), %rsi
xorl %edx, %edx
callq 0x3bfb
movq %rax, %rbp
movl 0x1c(%rsp), %esi
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x1d445
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x48(%rsp), %rdi
movss 0x3c(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
movl 0x34(%rsp), %esi
movl 0x30(%rsp), %edx
movss 0x2c(%rsp), %xmm2
movss 0x28(%rsp), %xmm3
movss 0x24(%rsp), %xmm4
callq 0xdccf
cmpl $0x0, 0x9150(%rsp)
je 0x1dbd6
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xcb93
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1d5b9
ucomiss 0x2e483(%rip), %xmm1    # 0x4c078
jbe 0x1dd42
cvttss2si %xmm0, %esi
movaps %xmm0, 0xd0(%rsp)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvttss2si %xmm0, %edx
cvttss2si %xmm1, %ecx
movaps %xmm1, %xmm0
shufps $0x55, %xmm1, %xmm0     # xmm0 = xmm0[1,1],xmm1[1,1]
cvttss2si %xmm0, %r8d
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x90(%rsp), %rdi
movaps %xmm1, 0xc0(%rsp)
callq 0xdba7
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x90(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xa8(%rsp), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0xc3ee
movl %r13d, %eax
imull 0x20(%rsp), %eax
cltq
movsd 0x48(%rsp), %xmm0
cvtps2pd 0xd0(%rsp), %xmm1
movaps 0xc0(%rsp), %xmm3
cvtps2pd %xmm3, %xmm2
mulpd 0x2e602(%rip), %xmm2    # 0x4c2a0
addpd %xmm1, %xmm2
cvtdq2pd %xmm0, %xmm1
divpd %xmm1, %xmm2
cvtpd2ps %xmm2, %xmm1
cvtdq2ps %xmm0, %xmm0
divps %xmm0, %xmm3
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
movq 0x60(%rsp), %rsi
movupd %xmm1, (%rsi,%rax,4)
movq 0xb8(%rsp), %rcx
addl $0x4, %eax
movslq %eax, %rdx
leaq (%rsi,%rdx,4), %rdx
xorl %esi, %esi
cmpq %rsi, %r12
je 0x1dcea
movss (%rcx,%rsi,4), %xmm0
movss %xmm0, (%rdx,%rsi,4)
incq %rsi
jmp 0x1dcd6
cvtsi2ssl 0x44(%rsp), %xmm0
addl 0x88(%rsp), %eax
cltq
movq 0x60(%rsp), %rcx
movss %xmm0, (%rcx,%rax,4)
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x90(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xa8(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
incl %r13d
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq %rbp, %rdi
callq 0x3040
movq %rbx, %rbp
jmp 0x1db03
movq 0x68(%rsp), %rdi
callq 0x3130
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
addq $0x90f8, %rsp           # imm = 0x90F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq