#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 *, char const *, int);
int /*<<< orphan*/ testFree(char *);
char *testMallocPrintf(char *, char const *, ...);
void testRestoreDb(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);
  copy_file(zFileSave, zFile, 1);
  copy_file(zLogSave, zLog, 0);
  testFree(zLog);
  testFree(zFileSave);
  testFree(zLogSave);
}


x86 assembly (clang, -O0):
<testRestoreDb>:
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    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <testMallocPrintf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <testMallocPrintf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <testMallocPrintf@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x1,%edx
call   1030 <copy_file@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1030 <copy_file@plt>
mov    -0x18(%rbp),%rdi
call   1050 <testFree@plt>
mov    -0x20(%rbp),%rdi
call   1050 <testFree@plt>
mov    -0x28(%rbp),%rdi
call   1050 <testFree@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testRestoreDb>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <testMallocPrintf@plt>
mov    %rax,%r14
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <testMallocPrintf@plt>
mov    %rax,%r12
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <testMallocPrintf@plt>
mov    %rax,%r15
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <copy_file@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <copy_file@plt>
mov    %r14,%rdi
call   1050 <testFree@plt>
mov    %r12,%rdi
call   1050 <testFree@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <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 @testRestoreDb(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 = load i8*, i8** %3
%18 = call i32 @copy_file(i8* %16, i8* %17, i32 1)
%19 = load i8*, i8** %7
%20 = load i8*, i8** %5
%21 = call i32 @copy_file(i8* %19, i8* %20, i32 0)
%22 = load i8*, i8** %5
%23 = call i32 @testFree(i8* %22)
%24 = load i8*, i8** %6
%25 = call i32 @testFree(i8* %24)
%26 = load i8*, i8** %7
%27 = call i32 @testFree(i8* %26)
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 @testRestoreDb(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 @copy_file(i8* %4, i8* %0, i32 1)
%7 = tail call i32 @copy_file(i8* %5, i8* %3, i32 0)
%8 = tail call i32 @testFree(i8* %3)
%9 = tail call i32 @testFree(i8* %4)
%10 = tail call i32 @testFree(i8* %5)
ret void
}