// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/image.c
// Function: save_image_options
void save_image_options(image im, const char *name, IMTYPE f, int quality)
{
    char buff[256];
    //sprintf(buff, "%s (%d)", name, windows);
    if(f == PNG)       sprintf(buff, "%s.png", name);
    else if (f == BMP) sprintf(buff, "%s.bmp", name);
    else if (f == TGA) sprintf(buff, "%s.tga", name);
    else if (f == JPG) sprintf(buff, "%s.jpg", name);
    else               sprintf(buff, "%s.png", name);
    unsigned char *data = calloc(im.w*im.h*im.c, sizeof(char));
    int i,k;
    for(k = 0; k < im.c; ++k){
        for(i = 0; i < im.w*im.h; ++i){
            data[i*im.c+k] = (unsigned char) (255*im.data[i + k*im.w*im.h]);
        }
    }
    int success = 0;
    if(f == PNG)       success = stbi_write_png(buff, im.w, im.h, im.c, data, im.w*im.c);
    else if (f == BMP) success = stbi_write_bmp(buff, im.w, im.h, im.c, data);
    else if (f == TGA) success = stbi_write_tga(buff, im.w, im.h, im.c, data);
    else if (f == JPG) success = stbi_write_jpg(buff, im.w, im.h, im.c, data, quality);
    free(data);
    if(!success) fprintf(stderr, "Failed to write image %s\n", buff);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %edx, 0xc(%rsp)
movl %esi, %r14d
movq %rdi, %rdx
leaq 0x150(%rsp), %rbx
testl %esi, %esi
sete %al
cmpl $0x4, %esi
setae %cl
orb %al, %cl
jne 0xd565
movslq %r14d, %rax
leaq 0x40ef1(%rip), %rcx     # 0x4e44c
movslq -0x4(%rcx,%rax,4), %rsi
addq %rcx, %rsi
jmp 0xd56c
leaq 0x411c9(%rip), %rsi     # 0x4e735
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x3420
movl (%rbx), %eax
movl 0x4(%rbx), %r12d
movl %r12d, 0x8(%rsp)
movl %eax, 0x4(%rsp)
imull %eax, %r12d
movslq 0x8(%rbx), %r15
movl %r12d, %eax
imull %r15d, %eax
movslq %eax, %rdi
pushq $0x1
popq %rsi
callq 0x3250
testl %r12d, %r12d
movl $0x0, %r13d
cmovgl %r12d, %r13d
testl %r15d, %r15d
movl $0x0, %ecx
cmovgl %r15d, %ecx
movq 0x10(%rbx), %rdx
movq %rax, %rbx
movss 0x3ec45(%rip), %xmm0    # 0x4c210
movq %rax, %rsi
xorl %edi, %edi
cmpq %rcx, %rdi
je 0xd60c
movslq %ebp, %r8
leaq (%rdx,%r8,4), %r8
movq %rsi, %r9
xorl %r10d, %r10d
cmpq %r10, %r13
je 0xd601
movss (%r8,%r10,4), %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %r11d
movb %r11b, (%r9)
incq %r10
addq %r15, %r9
jmp 0xd5e2
incq %rdi
addl %r12d, %ebp
incq %rsi
jmp 0xd5d0
testl %r14d, %r14d
je 0xd63f
cmpl $0x3, %r14d
je 0xd67a
cmpl $0x2, %r14d
je 0xd660
xorl %ebp, %ebp
cmpl $0x1, %r14d
jne 0xd699
leaq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rbx, %r8
callq 0x9131
jmp 0xd697
movl %r15d, %r9d
movl 0x4(%rsp), %esi
imull %esi, %r9d
leaq 0x10(%rsp), %rdi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rbx, %r8
callq 0xa9ef
jmp 0xd697
leaq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rbx, %r8
callq 0x95e6
jmp 0xd697
leaq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rbx, %r8
movl 0xc(%rsp), %r9d
callq 0xb1e8
movl %eax, %ebp
movq %rbx, %rdi
callq 0x3040
testl %ebp, %ebp
je 0xd6b7
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5693a(%rip), %rax     # 0x63ff8
movq (%rax), %rdi
leaq 0x41089(%rip), %rsi     # 0x4e751
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x3270
jmp 0xd6a5