#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*/ database_directory(char *);
scalar_t__ file_exists(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ system(char *);
int database_restore(char backup_filename[]) {
  char directory[1024];
  char command[1024];
  if (file_exists(backup_filename) == 0)
    return -1;
  database_directory(directory);
  sprintf(command, "tar -C %s -zxpf %s", directory, backup_filename);
  system(command);
  return 1;
}


x86 assembly (clang, -O0):
<database_restore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <file_exists@plt>
cmp    $0x0,%rax
jne    116e <database_restore+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <database_restore+0x6b>
lea    -0x410(%rbp),%rdi
call   1050 <database_directory@plt>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe6d(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x810(%rbp),%rdi
call   1040 <system@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<database_restore>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rdi,%rbx
call   1030 <file_exists@plt>
test   %rax,%rax
je     1190 <database_restore+0x50>
lea    0x400(%rsp),%r14
mov    %r14,%rdi
call   1050 <database_directory@plt>
lea    0xe90(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1060 <sprintf@plt>
mov    %r15,%rdi
call   1040 <system@plt>
mov    $0x1,%eax
jmp    1195 <database_restore+0x55>
mov    $0xffffffff,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"tar -C %s -zxpf %s\00"
define i32 @database_restore(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @file_exists(i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %19
10: ; preds = %1
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%12 = call i32 @database_directory(i8* %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%18 = call i32 @system(i8* %17)
store i32 1, i32* %2
br label %19
19: ; preds = %10, %9
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [19 x i8] c"tar -C %s -zxpf %s\00"
define i32 @database_restore(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = tail call i64 @file_exists(i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = call i32 @database_directory(i8* %4)
%10 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %0)
%11 = call i32 @system(i8* %5)
br label %12
12: ; preds = %1, %8
%13 = phi i32 [ 1, %8 ], [ -1, %1 ]
ret i32 %13
}