// File: /workspace/github_c_makefile_star2_O3/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 0x18356
movslq %r14d, %rax
leaq 0x3f1dc(%rip), %rcx     # 0x57528
movslq -0x4(%rcx,%rax,4), %rsi
addq %rcx, %rsi
jmp 0x1835d
leaq 0x3f4b8(%rip), %rsi     # 0x57815
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x3420
movl (%rbx), %r13d
movl 0x4(%rbx), %r12d
movl %r12d, 0x8(%rsp)
imull %r13d, %r12d
movslq 0x8(%rbx), %r15
movl %r15d, %eax
imull %r12d, %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x3250
testq %r15, %r15
jle 0x183e9
movq 0x10(%rbx), %r11
movl %r12d, %ecx
movss 0x3ce99(%rip), %xmm0    # 0x55240
movq %rax, %rdx
xorl %esi, %esi
testl %r12d, %r12d
jle 0x183db
movslq %ebp, %rdi
leaq (%r11,%rdi,4), %rdi
movq %rdx, %r8
xorl %r9d, %r9d
movss (%rdi,%r9,4), %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %r10d
movb %r10b, (%r8)
incq %r9
addq %r15, %r8
cmpq %r9, %rcx
jne 0x183be
incq %rsi
addl %r12d, %ebp
incq %rdx
cmpq %r15, %rsi
jne 0x183ac
testl %r14d, %r14d
je 0x18425
cmpl $0x1, %r14d
je 0x18448
cmpl $0x2, %r14d
je 0x18464
cmpl $0x3, %r14d
jne 0x1849e
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rax, %r8
movl 0xc(%rsp), %r9d
movq %rax, %rbx
callq 0x15a40
jmp 0x1847e
movl %r15d, %r9d
imull %r13d, %r9d
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rax, %r8
movq %rax, %rbx
callq 0x15114
jmp 0x1847e
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rax, %r8
movq %rax, %rbx
callq 0x13834
jmp 0x1847e
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %rax, %r8
movq %rax, %rbx
callq 0x13c6a
movl %eax, %ebp
movq %rbx, %rdi
callq 0x3040
testl %ebp, %ebp
je 0x184a6
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0x3040
movq 0x53b4b(%rip), %rax     # 0x6bff8
movq (%rax), %rdi
leaq 0x3f37a(%rip), %rsi     # 0x57831
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x3270
jmp 0x1848c