// File: /workspace/github_c_makefile_star2_O0/Matthias-Wandel[P]imgcomp/src/util.c
// Function: BackupImageFile
char * BackupImageFile(char * Name, int DiffMag, int DoNotCopy)
{
    static char DstPath[500];
    static char SuffixChar = ' ';
    static time_t LastSaveTime;
    char * extension;
    int a;
    struct stat statbuf;    
    time_t mtime;
    
    if (SaveDir[0] == '\0') return NULL; // Picture saving not enabled.
    
    if (stat(Name, &statbuf) == -1) {
        perror(Name);
        exit(1);
    }
    mtime = statbuf.st_mtime;
        
    // Get extension (.jpg or .mp4) of file we started with.
    extension = "\0";
    for (a=0;Name[a];a++){
        if (Name[a] == '.') extension = Name+a;
    }

    {
        char NameSuffix[20];
        if (LastSaveTime == mtime){
            // If it's the same second, cycle through suffixes a-z
            SuffixChar = (SuffixChar >= 'a' && SuffixChar <'z') ? SuffixChar+1 : 'a';
        }else{
            // New time. No need for a suffix.
            SuffixChar = ' ';
            LastSaveTime = mtime;
        }
        sprintf(NameSuffix, "%c%04d%s",SuffixChar, DiffMag, extension);
        DestNameFromTime(DstPath, SaveDir, mtime, NameSuffix);
        EnsurePathExists(DstPath, 1);
        if (!DoNotCopy){
            if (CopyJpgCmd[0]){
                // Apply a command, such as jpegtran to copy the file
                CopyJpgFileCmd(Name, DstPath);
            }else{
                // Just copy it from inside the program.
                CopyFile(Name, DstPath);
            }
        }
    }
    BackupImageCount ++;
    return DstPath;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
leaq 0x8aa4(%rip), %rax      # 0x14ae0
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xc051
movq $0x0, -0x8(%rbp)
jmp 0xc1e0
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x32b0
cmpl $-0x1, %eax
jne 0xc079
movq -0x10(%rbp), %rdi
callq 0x3430
movl $0x1, %edi
callq 0x3480
movq -0x60(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq 0x5427(%rip), %rax      # 0x114b2
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xc0d1
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2e, %eax
jne 0xc0c4
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0xc0c6
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc096
movq 0xaa40(%rip), %rax      # 0x16b18
cmpq -0xc0(%rbp), %rax
jne 0xc126
movsbl 0x8239(%rip), %eax      # 0x14321
cmpl $0x61, %eax
jl 0xc10b
movsbl 0x822d(%rip), %eax      # 0x14321
cmpl $0x7a, %eax
jge 0xc10b
movsbl 0x8221(%rip), %eax      # 0x14321
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0xc118
movl $0x61, %eax
movl %eax, -0xe4(%rbp)
jmp 0xc118
movl -0xe4(%rbp), %eax
movb %al, 0x81fd(%rip)       # 0x14321
jmp 0xc13b
movb $0x20, 0x81f4(%rip)     # 0x14321
movq -0xc0(%rbp), %rax
movq %rax, 0xa9dd(%rip)      # 0x16b18
leaq -0xe0(%rbp), %rdi
movsbl 0x81d8(%rip), %edx      # 0x14321
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %r8
leaq 0x51b1(%rip), %rsi      # 0x11308
movb $0x0, %al
callq 0x3470
movq -0xc0(%rbp), %rdx
leaq -0xe0(%rbp), %rcx
leaq 0xa7ad(%rip), %rdi      # 0x16920
leaq 0x8966(%rip), %rsi      # 0x14ae0
callq 0xc1f0
leaq 0xa79a(%rip), %rdi      # 0x16920
movl $0x1, %esi
callq 0xbb80
cmpl $0x0, -0x18(%rbp)
jne 0xc1c6
leaq 0x8ae3(%rip), %rax      # 0x14c80
cmpb $0x0, (%rax)
je 0xc1b4
movq -0x10(%rbp), %rdi
leaq 0xa773(%rip), %rsi      # 0x16920
callq 0xc290
jmp 0xc1c4
movq -0x10(%rbp), %rdi
leaq 0xa761(%rip), %rsi      # 0x16920
callq 0xc540
jmp 0xc1c6
movl 0xa954(%rip), %eax      # 0x16b20
addl $0x1, %eax
movl %eax, 0xa94b(%rip)      # 0x16b20
leaq 0xa744(%rip), %rax      # 0x16920
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)