// File: /workspace/github_c_makefile_star2_O1/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 0x17ac7
movslq %r14d, %rax
leaq 0x3d98f(%rip), %rcx     # 0x5544c
movslq -0x4(%rcx,%rax,4), %rsi
addq %rcx, %rsi
jmp 0x17ace
leaq 0x3dc6f(%rip), %rsi     # 0x5573d
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x3430
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 0x3260
movq %rax, %r11
testq %r15, %r15
jle 0x17b5d
movq 0x10(%rbx), %rax
movl %r12d, %ecx
movss 0x3b6f5(%rip), %xmm0    # 0x53210
movq %r11, %rdx
xorl %esi, %esi
testl %r12d, %r12d
jle 0x17b4f
movslq %ebp, %rdi
leaq (%rax,%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 0x17b32
incq %rsi
addl %r12d, %ebp
incq %rdx
cmpq %r15, %rsi
jne 0x17b20
testl %r14d, %r14d
je 0x17b92
cmpl $0x3, %r14d
je 0x17bd1
cmpl $0x2, %r14d
je 0x17bb5
xorl %ebp, %ebp
cmpl $0x1, %r14d
jne 0x17bf5
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %r11, %r8
movq %r11, %rbx
callq 0x12cd1
jmp 0x17bf0
movl %r15d, %r9d
imull %r13d, %r9d
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %r11, %r8
movq %r11, %rbx
callq 0x1472f
jmp 0x17bf0
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %r11, %r8
movq %r11, %rbx
callq 0x13191
jmp 0x17bf0
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movl 0x8(%rsp), %edx
movl %r15d, %ecx
movq %r11, %r8
movl 0xc(%rsp), %r9d
movq %r11, %rbx
callq 0x14f93
movq %rbx, %r11
movl %eax, %ebp
movq %r11, %rdi
callq 0x3040
testl %ebp, %ebp
je 0x17c13
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x523de(%rip), %rax     # 0x69ff8
movq (%rax), %rdi
leaq 0x3db35(%rip), %rsi     # 0x55759
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x3280
jmp 0x17c01