#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 */
scalar_t__ canDelete(char *);
int /*<<< orphan*/ concat(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int remove(char *);
int /*<<< orphan*/ toLog(int /*<<< orphan*/);
bool delete (char *filename) {
  if (canDelete(filename) != 0) {
    printf("Cannot delete file '%s'\n", filename);
    return false;
  }
  int status = remove(filename);
  if (status == -1) {
    toLog(concat("File could not be permanantly deleted: ", filename));
    printf("Cannot delete file '%s'\n", filename);
    return false;
  }
  toLog(concat("File permanantly deleted: ", filename));
  return true;
}


x86 assembly (clang, -O0):
<delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <canDelete@plt>
cmp    $0x0,%rax
je     118b <delete+0x3b>
mov    -0x10(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f2 <delete+0xa2>
mov    -0x10(%rbp),%rdi
call   1040 <remove@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11d4 <delete+0x84>
mov    -0x10(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1060 <concat@plt>
mov    %eax,%edi
call   1030 <toLog@plt>
mov    -0x10(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f2 <delete+0xa2>
mov    -0x10(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1060 <concat@plt>
mov    %eax,%edi
call   1030 <toLog@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete>:
push   %rbx
mov    %rdi,%rbx
call   1070 <canDelete@plt>
test   %rax,%rax
je     1171 <delete+0x21>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    %rbx,%rdi
call   1040 <remove@plt>
cmp    $0xffffffff,%eax
je     119b <delete+0x4b>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
call   1060 <concat@plt>
mov    %eax,%edi
call   1030 <toLog@plt>
mov    $0x1,%eax
pop    %rbx
ret
lea    0xe77(%rip),%rdi
mov    %rbx,%rsi
call   1060 <concat@plt>
mov    %eax,%edi
call   1030 <toLog@plt>
jmp    115e <delete+0xe>

LLVM IR (-O0):
@.str = [25 x i8] c"Cannot delete file '%s'\0A\00"
@.str.1 = [40 x i8] c"File could not be permanantly deleted: \00"
@.str.2 = [27 x i8] c"File permanantly deleted: \00"
define i32 @delete(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @canDelete(i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 0, i32* %2
br label %26
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @remove(i8* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i32 @concat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 @toLog(i32 %18)
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 0, i32* %2
br label %26
22: ; preds = %11
%23 = load i8*, i8** %3
%24 = call i32 @concat(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = call i32 @toLog(i32 %24)
store i32 1, i32* %2
br label %26
26: ; preds = %22, %16, %8
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [25 x i8] c"Cannot delete file '%s'\0A\00"
@.str.1 = [40 x i8] c"File could not be permanantly deleted: \00"
@.str.2 = [27 x i8] c"File permanantly deleted: \00"
define i32 @delete(i8* %0) {
%2 = tail call i64 @canDelete(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
6: ; preds = %1
%7 = tail call i32 @remove(i8* %0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = tail call i32 @concat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = tail call i32 @toLog(i32 %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
13: ; preds = %6
%14 = tail call i32 @concat(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%15 = tail call i32 @toLog(i32 %14)
br label %16
16: ; preds = %9, %13, %4
%17 = phi i32 [ 0, %4 ], [ 0, %9 ], [ 1, %13 ]
ret i32 %17
}