#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int fcheck(char[]);
  char strng[81];
  int result;
  printf("\nPlease enter your desired file to check if it exists \n(suggested "
         "file name: 509_pe5_txt.dat) -->");
  gets(strng);
  result = fcheck(strng);
  switch (result) {
  case 0:
    printf("\nYour file %s is not present.\n", strng);
    break;
  case 1:
    printf("\nYour file %s is present.\n", strng);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    %rdi,-0x70(%rbp)
call   1050 <gets@plt>
mov    -0x70(%rbp),%rdi
call   1030 <fcheck@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x68(%rbp)
test   %eax,%eax
je     118a <main+0x5a>
jmp    1179 <main+0x49>
mov    -0x68(%rbp),%eax
sub    $0x1,%eax
je     11a1 <main+0x71>
jmp    11b3 <main+0x83>
lea    -0x60(%rbp),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b3 <main+0x83>
lea    -0x60(%rbp),%rsi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <fcheck@plt>
test   %eax,%eax
je     1168 <main+0x38>
cmp    $0x1,%eax
jne    1179 <main+0x49>
lea    0xf1b(%rip),%rdi
jmp    116f <main+0x3f>
lea    0xef3(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [98 x i8] c"\0APlease enter your desired file to check if it exists \0A(suggested file name: 509_pe5_txt.dat) -->\00"
@.str.1 = [31 x i8] c"\0AYour file %s is not present.\0A\00"
@.str.2 = [27 x i8] c"\0AYour file %s is present.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%8 = call i32 @fcheck(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
switch i32 %9, label %16 [
i32 0, label %10
i32 1, label %13
]
10: ; preds = %0
%11 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %16
13: ; preds = %0
%14 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %0, %13, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [98 x i8] c"\0APlease enter your desired file to check if it exists \0A(suggested file name: 509_pe5_txt.dat) -->\00"
@.str.1 = [31 x i8] c"\0AYour file %s is not present.\0A\00"
@.str.2 = [27 x i8] c"\0AYour file %s is present.\0A\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @fcheck(i8* %2)
switch i32 %5, label %10 [
i32 0, label %7
i32 1, label %6
]
6: ; preds = %0
br label %7
7: ; preds = %0, %6
%8 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), %0 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %8, i8* %2)
br label %10
10: ; preds = %7, %0
ret i32 0
}