// File: /workspace/github_c_makefile_star2_O3/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 $0x90e8, %rsp           # imm = 0x90E8
movl %r9d, %ebp
movl %r8d, %r15d
movq %rdx, 0x78(%rsp)
movl %esi, %ebx
leaq 0x2c6e3(%rip), %rsi     # 0x58a4f
leaq 0x2c700(%rip), %r12     # 0x58a73
leaq 0xd0(%rsp), %r14
movq %r12, %rdx
movq %r14, %rcx
callq 0xf02d
leaq 0x2c6d0(%rip), %rsi     # 0x58a5d
movq %r14, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0xf02d
leaq 0x2b48a(%rip), %rsi     # 0x5782c
leaq 0x2e568(%rip), %r12     # 0x5a911
movq %r14, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0xf02d
leaq 0x2c6aa(%rip), %rsi     # 0x58a68
movq %r14, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0xf02d
leaq 0x2c69a(%rip), %rsi     # 0x58a6d
movq %r14, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0xf02d
leaq 0x2ea41(%rip), %rsi     # 0x5ae29
movq %r14, %rdi
callq 0x3390
movq %rax, %r14
testq %rax, %rax
jne 0x2c405
leaq 0xd0(%rsp), %rdi
callq 0xe925
leaq 0x60(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
movl $0x1, %ecx
callq 0x15d43
leaq 0x2c658(%rip), %rsi     # 0x58a78
leaq 0x24(%rsp), %rdx
leaq 0x10d0(%rsp), %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x30a0
cmpl $0x2, %eax
setne %al
movl %ebx, 0x44(%rsp)
testl %ebx, %ebx
setle %cl
orb %al, %cl
jne 0x2c716
movl 0x9150(%rsp), %ecx
leaq 0x9120(%rsp), %rax
movss 0xc(%rax), %xmm0
movss %xmm0, 0x40(%rsp)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x3c(%rsp)
movl (%rax), %edx
movl %edx, 0x38(%rsp)
movl 0x4(%rax), %r15d
movss 0x10(%rax), %xmm0
movss %xmm0, 0x34(%rsp)
movss 0x14(%rax), %xmm0
movss %xmm0, 0x30(%rsp)
movss 0x18(%rax), %xmm0
movss %xmm0, 0x2c(%rsp)
movl %ecx, %ebx
imull 0x9148(%rsp), %ebx
leal 0x5(%rbx), %eax
movl %eax, 0x28(%rsp)
leaq 0x10d0(%rsp), %r12
xorl %r13d, %r13d
movl $0x0, 0x20(%rsp)
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0xe7d7
movq %rax, %rbp
movl 0x20(%rsp), %esi
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x2bb35
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x48(%rsp), %rdi
movss 0x40(%rsp), %xmm0
movss 0x3c(%rsp), %xmm1
movl 0x38(%rsp), %esi
movl %r15d, %edx
movss 0x34(%rsp), %xmm2
movss 0x30(%rsp), %xmm3
movss 0x2c(%rsp), %xmm4
callq 0x18c21
cmpl $0x0, 0x9140(%rsp)
je 0x2c557
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1786a
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x2bf26
ucomiss 0x28b2a(%rip), %xmm1    # 0x550a0
jbe 0x2c6cd
cvttss2si %xmm0, %esi
movaps %xmm0, 0xc0(%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 0x80(%rsp), %rdi
movaps %xmm1, 0xb0(%rsp)
callq 0x18a89
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x98(%rsp), %rdi
movl 0x9148(%rsp), %esi
movl 0x9150(%rsp), %edx
callq 0x170fa
movl %r13d, %eax
imull 0x28(%rsp), %eax
movslq %eax, %rcx
movsd 0x48(%rsp), %xmm0
cvtps2pd 0xc0(%rsp), %xmm1
movaps 0xb0(%rsp), %xmm3
cvtps2pd %xmm3, %xmm2
mulpd 0x28cb8(%rip), %xmm2    # 0x552e0
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 0x78(%rsp), %rdi
movupd %xmm1, (%rdi,%rcx,4)
testl %ebx, %ebx
jle 0x2c679
movq 0xa8(%rsp), %rdx
addl $0x4, %eax
leaq (%rdi,%rcx,4), %rcx
addq $0x10, %rcx
xorl %esi, %esi
movss (%rdx,%rsi,4), %xmm0
movss %xmm0, (%rcx,%rsi,4)
incq %rsi
cmpq %rsi, %rbx
jne 0x2c665
jmp 0x2c67c
addl $0x4, %eax
xorps %xmm0, %xmm0
cvtsi2ssl 0x24(%rsp), %xmm0
addl %ebx, %eax
cltq
movss %xmm0, (%rdi,%rax,4)
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x98(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
incl %r13d
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq %rbp, %rdi
callq 0x3040
movq %r14, %rdi
leaq 0x2c381(%rip), %rsi     # 0x58a78
leaq 0x24(%rsp), %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x30a0
cmpl $0x2, %eax
jne 0x2c716
cmpl 0x44(%rsp), %r13d
jl 0x2c4ba
movq %r14, %rdi
callq 0x3130
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
addq $0x90e8, %rsp           # imm = 0x90E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq