#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 *);
scalar_t__ db_file_exists(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ is_file_encrypted(char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
bool backup_export(const char *source, const char *dest) {
  if (!db_file_exists(source)) {
    fprintf(stderr, "%s does not exist.\n", source);
    return false;
  }
  if (db_file_exists(dest)) {
    fprintf(stderr, "%s already exists.\n", dest);
    return false;
  }
  if (!is_file_encrypted(source)) {
    fprintf(stdout, "Encrypt the file first before taking a backup.\n");
    return false;
  }
  if (!copy_file(source, dest)) {
    fprintf(stderr, "Backing up %s failed.\n", source);
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<backup_export>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <db_file_exists@plt>
cmp    $0x0,%rax
jne    118a <backup_export+0x4a>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123d <backup_export+0xfd>
mov    -0x18(%rbp),%rdi
call   1040 <db_file_exists@plt>
cmp    $0x0,%rax
je     11c4 <backup_export+0x84>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123d <backup_export+0xfd>
mov    -0x10(%rbp),%rdi
call   1060 <is_file_encrypted@plt>
cmp    $0x0,%eax
jne    11f9 <backup_export+0xb9>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123d <backup_export+0xfd>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <copy_file@plt>
cmp    $0x0,%eax
jne    1236 <backup_export+0xf6>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123d <backup_export+0xfd>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backup_export>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1040 <db_file_exists@plt>
test   %rax,%rax
je     1179 <backup_export+0x39>
mov    %rbp,%rdi
call   1040 <db_file_exists@plt>
test   %rax,%rax
je     119e <backup_export+0x5e>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
xor    %r14d,%r14d
mov    %rbp,%rdx
jmp    118f <backup_export+0x4f>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
xor    %r14d,%r14d
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
call   1060 <is_file_encrypted@plt>
test   %eax,%eax
je     11d1 <backup_export+0x91>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <copy_file@plt>
mov    $0x1,%r14d
test   %eax,%eax
jne    1196 <backup_export+0x56>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
jmp    1189 <backup_export+0x49>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1196 <backup_export+0x56>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"%s does not exist.\0A\00"
@.str.1 = [20 x i8] c"%s already exists.\0A\00"
@stdout = global i32 0
@.str.2 = [48 x i8] c"Encrypt the file first before taking a backup.\0A\00"
@.str.3 = [23 x i8] c"Backing up %s failed.\0A\00"
define i32 @backup_export(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = call i64 @db_file_exists(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %4
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 0, i32* %3
br label %38
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i64 @db_file_exists(i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %5
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %19)
store i32 0, i32* %3
br label %38
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = call i32 @is_file_encrypted(i8* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %21
%26 = load i32, i32* @stdout
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %38
28: ; preds = %21
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = call i32 @copy_file(i8* %29, i8* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %4
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %35)
store i32 0, i32* %3
br label %38
37: ; preds = %28
store i32 1, i32* %3
br label %38
38: ; preds = %37, %33, %25, %17, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"%s does not exist.\0A\00"
@.str.1 = [20 x i8] c"%s already exists.\0A\00"
@stdout = global i32 0
@.str.2 = [48 x i8] c"Encrypt the file first before taking a backup.\0A\00"
@.str.3 = [23 x i8] c"Backing up %s failed.\0A\00"
define i32 @backup_export(i8* %0, i8* %1) {
%3 = tail call i64 @db_file_exists(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %26
8: ; preds = %2
%9 = tail call i64 @db_file_exists(i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %26
14: ; preds = %8
%15 = tail call i32 @is_file_encrypted(i8* %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @stdout
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %26
20: ; preds = %14
%21 = tail call i32 @copy_file(i8* %0, i8* %1)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %26
26: ; preds = %20, %23, %17, %11, %5
%27 = phi i32 [ 0, %11 ], [ 0, %23 ], [ 0, %17 ], [ 0, %5 ], [ 1, %20 ]
ret i32 %27
}