#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 const *, int);
int /*<<< orphan*/ testFree(char *);
char *testMallocPrintf(char *, char const *);
int /*<<< orphan*/ unlink(char const *);
void testCopyLsmdb(const char *zFrom, const char *zTo) {
  char *zLog1 = testMallocPrintf("%s-log", zFrom);
  char *zLog2 = testMallocPrintf("%s-log", zTo);
  char *zShm1 = testMallocPrintf("%s-shm", zFrom);
  char *zShm2 = testMallocPrintf("%s-shm", zTo);
  unlink(zShm2);
  unlink(zLog2);
  unlink(zTo);
  copy_file(zFrom, zTo, 1);
  copy_file(zLog1, zLog2, 0);
  copy_file(zShm1, zShm2, 0);
  testFree(zLog1);
  testFree(zLog2);
  testFree(zShm1);
  testFree(zShm2);
}


x86 assembly (clang, -O0):
<testCopyLsmdb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1050 <testMallocPrintf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1050 <testMallocPrintf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1050 <testMallocPrintf@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1050 <testMallocPrintf@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x20(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x10(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1030 <copy_file@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <copy_file@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%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>
mov    -0x30(%rbp),%rdi
call   1060 <testFree@plt>
add    $0x30,%rsp
pop    %rbp
ret

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

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

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