#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*/ cgets(char *);
int /*<<< orphan*/ cprintf(char *, ...);
int remove_app(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ textattr(int);
int delete_file(char *s) {
  char cfname[15];
  char *fname;
  int status;
  if (s == NULL) {
    cprintf("\n\rEnter (existing) file name: ");
    cfname[0] = 12;
    cgets(cfname);
    fname = cfname + 2;
  } else {
    strcpy(cfname, s);
    fname = cfname;
  }
  status = remove_app(fname, 1);
  if (status == 2) {
    textattr(0x0C);
    cprintf("\n\rError: file NOT removed. Data error. STATUS: %d", status);
    textattr(0x07);
  } else if (status == 1) {
    textattr(0x0C);
    cprintf("\n\rError: file NOT removed. Failed. STATUS: %d", status);
    textattr(0x07);
  } else {
    textattr(0x03);
    cprintf("\n\rFile removed successfully. STATUS: %d", status);
    textattr(0x07);
  }
  return status;
}


x86 assembly (clang, -O0):
<delete_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1193 <delete_file+0x43>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1060 <cprintf@plt>
movb   $0xc,-0x17(%rbp)
lea    -0x17(%rbp),%rdi
call   1070 <cgets@plt>
lea    -0x17(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    11a8 <delete_file+0x58>
lea    -0x17(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x17(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1040 <remove_app@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jne    11ed <delete_file+0x9d>
mov    $0xc,%edi
call   1050 <textattr@plt>
mov    -0x24(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1060 <cprintf@plt>
mov    $0x7,%edi
call   1050 <textattr@plt>
jmp    124b <delete_file+0xfb>
cmpl   $0x1,-0x24(%rbp)
jne    1221 <delete_file+0xd1>
mov    $0xc,%edi
call   1050 <textattr@plt>
mov    -0x24(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1060 <cprintf@plt>
mov    $0x7,%edi
call   1050 <textattr@plt>
jmp    1246 <delete_file+0xf6>
mov    $0x3,%edi
call   1050 <textattr@plt>
mov    -0x24(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1060 <cprintf@plt>
mov    $0x7,%edi
call   1050 <textattr@plt>
jmp    124b <delete_file+0xfb>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_file>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     116c <delete_file+0x1c>
mov    %rdi,%rsi
lea    0x1(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
jmp    118e <delete_file+0x3e>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1060 <cprintf@plt>
movb   $0xc,0x1(%rsp)
lea    0x1(%rsp),%rdi
call   1070 <cgets@plt>
lea    0x3(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <remove_app@plt>
mov    %eax,%ebx
cmp    $0x1,%eax
je     11bf <delete_file+0x6f>
cmp    $0x2,%ebx
jne    11d7 <delete_file+0x87>
mov    $0xc,%edi
call   1050 <textattr@plt>
lea    0xe67(%rip),%rdi
mov    $0x2,%esi
jmp    11ea <delete_file+0x9a>
mov    $0xc,%edi
call   1050 <textattr@plt>
lea    0xe81(%rip),%rdi
mov    $0x1,%esi
jmp    11ea <delete_file+0x9a>
mov    $0x3,%edi
call   1050 <textattr@plt>
lea    0xe97(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <cprintf@plt>
mov    $0x7,%edi
call   1050 <textattr@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0A\0DEnter (existing) file name: \00"
@.str.1 = [50 x i8] c"\0A\0DError: file NOT removed. Data error. STATUS: %d\00"
@.str.2 = [46 x i8] c"\0A\0DError: file NOT removed. Failed. STATUS: %d\00"
@.str.3 = [40 x i8] c"\0A\0DFile removed successfully. STATUS: %d\00"
define i32 @delete_file(i8* %0) {
%2 = alloca i8*
%3 = alloca [15 x i8]
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
store i8 12, i8* %10
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%12 = call i32 @cgets(i8* %11)
%13 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8* %14, i8** %4
br label %20
15: ; preds = %1
%16 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
store i8* %19, i8** %4
br label %20
20: ; preds = %15, %8
%21 = load i8*, i8** %4
%22 = call i32 @remove_app(i8* %21, i32 1)
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = call i32 @textattr(i32 12)
%27 = load i32, i32* %5
%28 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = call i32 @textattr(i32 7)
br label %44
30: ; preds = %20
%31 = load i32, i32* %5
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = call i32 @textattr(i32 12)
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = call i32 @textattr(i32 7)
br label %43
38: ; preds = %30
%39 = call i32 @textattr(i32 3)
%40 = load i32, i32* %5
%41 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = call i32 @textattr(i32 7)
br label %43
43: ; preds = %38, %33
br label %44
44: ; preds = %43, %25
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@.str = [31 x i8] c"\0A\0DEnter (existing) file name: \00"
@.str.1 = [50 x i8] c"\0A\0DError: file NOT removed. Data error. STATUS: %d\00"
@.str.2 = [46 x i8] c"\0A\0DError: file NOT removed. Failed. STATUS: %d\00"
@.str.3 = [40 x i8] c"\0A\0DFile removed successfully. STATUS: %d\00"
define i32 @delete_file(i8* %0) {
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i8 12, i8* %3
%7 = call i32 @cgets(i8* %3)
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 2
br label %11
9: ; preds = %1
%10 = call i32 @strcpy(i8* %3, i8* %0)
br label %11
11: ; preds = %9, %5
%12 = phi i8* [ %8, %5 ], [ %3, %9 ]
%13 = call i32 @remove_app(i8* %12, i32 1)
switch i32 %13, label %20 [
i32 2, label %14
i32 1, label %17
]
14: ; preds = %11
%15 = call i32 @textattr(i32 12)
%16 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %23
17: ; preds = %11
%18 = call i32 @textattr(i32 12)
%19 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %23
20: ; preds = %11
%21 = call i32 @textattr(i32 3)
%22 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %23
23: ; preds = %17, %20, %14
%24 = call i32 @textattr(i32 7)
ret i32 %13
}