#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*/ status_set_tracking(char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
bool backup_import(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, "Backup file not encrypted.\nAre you sure you're"
                    " importing Steel backup file?\n");
    return false;
  }
  if (!copy_file(source, dest)) {
    fprintf(stderr, "Backing up %s failed.\n", source);
    return false;
  }
  status_set_tracking(dest);
  return true;
}


x86 assembly (clang, -O0):
<backup_import>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <db_file_exists@plt>
cmp    $0x0,%rax
jne    119a <backup_import+0x4a>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1256 <backup_import+0x106>
mov    -0x18(%rbp),%rdi
call   1050 <db_file_exists@plt>
cmp    $0x0,%rax
je     11d4 <backup_import+0x84>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1256 <backup_import+0x106>
mov    -0x10(%rbp),%rdi
call   1070 <is_file_encrypted@plt>
cmp    $0x0,%eax
jne    1209 <backup_import+0xb9>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1256 <backup_import+0x106>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <copy_file@plt>
cmp    $0x0,%eax
jne    1246 <backup_import+0xf6>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1256 <backup_import+0x106>
mov    -0x18(%rbp),%rdi
call   1040 <status_set_tracking@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backup_import>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <db_file_exists@plt>
test   %rax,%rax
je     1188 <backup_import+0x38>
mov    %r14,%rdi
call   1050 <db_file_exists@plt>
test   %rax,%rax
je     11ab <backup_import+0x5b>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdx
jmp    119d <backup_import+0x4d>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
call   1070 <is_file_encrypted@plt>
test   %eax,%eax
je     11d5 <backup_import+0x85>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <copy_file@plt>
test   %eax,%eax
je     11f0 <backup_import+0xa0>
mov    %r14,%rdi
call   1040 <status_set_tracking@plt>
mov    $0x1,%ebp
jmp    11a4 <backup_import+0x54>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11a4 <backup_import+0x54>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
jmp    1198 <backup_import+0x48>

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 = [77 x i8] c"Backup file not encrypted.\0AAre you sure you're importing Steel backup file?\0A\00"
@.str.3 = [23 x i8] c"Backing up %s failed.\0A\00"
define i32 @backup_import(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 %40
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 %40
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 ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %40
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 %40
37: ; preds = %28
%38 = load i8*, i8** %5
%39 = call i32 @status_set_tracking(i8* %38)
store i32 1, i32* %3
br label %40
40: ; preds = %37, %33, %25, %17, %9
%41 = load i32, i32* %3
ret i32 %41
}

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 = [77 x i8] c"Backup file not encrypted.\0AAre you sure you're importing Steel backup file?\0A\00"
@.str.3 = [23 x i8] c"Backing up %s failed.\0A\00"
define i32 @backup_import(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 %28
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 %28
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 ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
br label %28
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 %28
26: ; preds = %20
%27 = tail call i32 @status_set_tracking(i8* %1)
br label %28
28: ; preds = %26, %23, %17, %11, %5
%29 = phi i32 [ 0, %11 ], [ 1, %26 ], [ 0, %23 ], [ 0, %17 ], [ 0, %5 ]
ret i32 %29
}