#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ copy_file(char const *, char *, int);
int /*<<< orphan*/ testFree(char *);
char *testMallocPrintf(char *, char const *, ...);
int /*<<< orphan*/ unlink(char *);
void testSaveDb(const char *zFile, const char *zAux) {
  char *zLog = testMallocPrintf("%s-%s", zFile, zAux);
  char *zFileSave = testMallocPrintf("%s-save", zFile);
  char *zLogSave = testMallocPrintf("%s-%s-save", zFile, zAux);
  unlink(zFileSave);
  unlink(zLogSave);
  copy_file(zFile, zFileSave, 1);
  copy_file(zLog, zLogSave, 0);
  testFree(zLog);
  testFree(zFileSave);
  testFree(zLogSave);
}


x86 assembly (clang, -O0):
<testSaveDb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1050 <testMallocPrintf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1050 <testMallocPrintf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <testMallocPrintf@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x28(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1030 <copy_file@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <copy_file@plt>
mov    -0x18(%rbp),%rdi
call   1060 <testFree@plt>
mov    -0x20(%rbp),%rdi
call   1060 <testFree@plt>
mov    -0x28(%rbp),%rdi
call   1060 <testFree@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testSaveDb>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xeab(%rip),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <testMallocPrintf@plt>
mov    %rax,%r14
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <testMallocPrintf@plt>
mov    %rax,%r15
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <testMallocPrintf@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1040 <unlink@plt>
mov    %r12,%rdi
call   1040 <unlink@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <copy_file@plt>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1030 <copy_file@plt>
mov    %r14,%rdi
call   1060 <testFree@plt>
mov    %r15,%rdi
call   1060 <testFree@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <testFree@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s-%s\00"
@.str.1 = [8 x i8] c"%s-save\00"
@.str.2 = [11 x i8] c"%s-%s-save\00"
define void @testSaveDb(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i8* (i8*, i8*, ...) @testMallocPrintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
store i8* %10, i8** %5
%11 = load i8*, i8** %3
%12 = call i8* (i8*, i8*, ...) @testMallocPrintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = call i8* (i8*, i8*, ...) @testMallocPrintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %14)
store i8* %15, i8** %7
%16 = load i8*, i8** %6
%17 = call i32 @unlink(i8* %16)
%18 = load i8*, i8** %7
%19 = call i32 @unlink(i8* %18)
%20 = load i8*, i8** %3
%21 = load i8*, i8** %6
%22 = call i32 @copy_file(i8* %20, i8* %21, i32 1)
%23 = load i8*, i8** %5
%24 = load i8*, i8** %7
%25 = call i32 @copy_file(i8* %23, i8* %24, i32 0)
%26 = load i8*, i8** %5
%27 = call i32 @testFree(i8* %26)
%28 = load i8*, i8** %6
%29 = call i32 @testFree(i8* %28)
%30 = load i8*, i8** %7
%31 = call i32 @testFree(i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s-%s\00"
@.str.1 = [8 x i8] c"%s-save\00"
@.str.2 = [11 x i8] c"%s-%s-save\00"
define void @testSaveDb(i8* %0, i8* %1) {
%3 = tail call i8* (i8*, i8*, ...) @testMallocPrintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%4 = tail call i8* (i8*, i8*, ...) @testMallocPrintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%5 = tail call i8* (i8*, i8*, ...) @testMallocPrintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
%6 = tail call i32 @unlink(i8* %4)
%7 = tail call i32 @unlink(i8* %5)
%8 = tail call i32 @copy_file(i8* %0, i8* %4, i32 1)
%9 = tail call i32 @copy_file(i8* %3, i8* %5, i32 0)
%10 = tail call i32 @testFree(i8* %3)
%11 = tail call i32 @testFree(i8* %4)
%12 = tail call i32 @testFree(i8* %5)
ret void
}