#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 */
typedef int /*<<< orphan*/ fLoc;
typedef int /*<<< orphan*/ FILE_MENU;

/* Variables and functions */
int /*<<< orphan*/ createNewFic(char *);
int /*<<< orphan*/ editFic(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ iscntrl(char);
unsigned int performMenu(char const *const *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readFic(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(void) {
  const char *const FILE_MENU[] = {"Read file", "Edit existing file",
                                   "Create new file"};
  unsigned option =
      performMenu(FILE_MENU, sizeof(FILE_MENU) / sizeof(*FILE_MENU));
  printf("Enter the file location: ");
  char fLoc[256];
  if (!fgets(fLoc, sizeof(fLoc), stdin)) {
    fprintf(stderr, "Unable to get input from stdin.\n");
    return 1;
  }
  size_t offset = 0;
  while (offset < sizeof(fLoc) && !iscntrl(fLoc[offset])) {
    offset++;
  }
  fLoc[offset] = '\0';
  switch (option) {
  case 1:
    if (readFic(fLoc)) {
      return 1;
    }
    break;
  case 2:
    if (editFic(fLoc)) {
      return 1;
    }
    break;
  case 3:
    if (createNewFic(fLoc)) {
      return 1;
    }
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2c57(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c54(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c51(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1090 <performMenu@plt>
mov    %eax,-0x24(%rbp)
lea    0xe62(%rip),%rdi
call   1050 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%eax
jne    1214 <main+0x94>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    134b <main+0x1cb>
movq   $0x0,-0x138(%rbp)
xor    %eax,%eax
cmpq   $0x100,-0x138(%rbp)
mov    %al,-0x139(%rbp)
jae    125a <main+0xda>
mov    -0x138(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%edi
ff
call   1040 <iscntrl@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x139(%rbp)
mov    -0x139(%rbp),%al
test   $0x1,%al
jne    126d <main+0xed>
jmp    1284 <main+0x104>
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    121f <main+0x9f>
mov    -0x138(%rbp),%rax
movb   $0x0,-0x130(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
mov    %eax,-0x140(%rbp)
sub    $0x1,%eax
je     12d2 <main+0x152>
jmp    12aa <main+0x12a>
mov    -0x140(%rbp),%eax
sub    $0x2,%eax
je     12f8 <main+0x178>
jmp    12be <main+0x13e>
mov    -0x140(%rbp),%eax
sub    $0x3,%eax
je     131e <main+0x19e>
jmp    1344 <main+0x1c4>
lea    -0x130(%rbp),%rdi
call   1030 <readFic@plt>
cmp    $0x0,%eax
je     12f3 <main+0x173>
movl   $0x1,-0x4(%rbp)
jmp    134b <main+0x1cb>
jmp    1344 <main+0x1c4>
lea    -0x130(%rbp),%rdi
call   10a0 <editFic@plt>
cmp    $0x0,%eax
je     1319 <main+0x199>
movl   $0x1,-0x4(%rbp)
jmp    134b <main+0x1cb>
jmp    1344 <main+0x1c4>
lea    -0x130(%rbp),%rdi
call   1060 <createNewFic@plt>
cmp    $0x0,%eax
je     133f <main+0x1bf>
movl   $0x1,-0x4(%rbp)
jmp    134b <main+0x1cb>
jmp    1344 <main+0x1c4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x128,%rsp
mov    0x2c70(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0x2c54(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
call   1090 <performMenu@plt>
mov    %eax,%ebp
lea    0xe77(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
test   %eax,%eax
je     1220 <main+0xa0>
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl 0x20(%rsp,%rbx,1),%edi
call   1040 <iscntrl@plt>
test   %eax,%eax
jne    1200 <main+0x80>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    11e0 <main+0x60>
mov    $0x100,%ebx
movb   $0x0,0x20(%rsp,%rbx,1)
cmp    $0x3,%ebp
je     123c <main+0xbc>
cmp    $0x2,%ebp
je     1248 <main+0xc8>
cmp    $0x1,%ebp
jne    125d <main+0xdd>
lea    0x20(%rsp),%rdi
call   1030 <readFic@plt>
jmp    1252 <main+0xd2>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    125f <main+0xdf>
lea    0x20(%rsp),%rdi
call   1060 <createNewFic@plt>
jmp    1252 <main+0xd2>
lea    0x20(%rsp),%rdi
call   10a0 <editFic@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    125f <main+0xdf>
xor    %eax,%eax
add    $0x128,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Read file\00"
@.str.1 = [19 x i8] c"Edit existing file\00"
@.str.2 = [16 x i8] c"Create new file\00"
@__const.main.FILE_MENU = [3 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [26 x i8] c"Enter the file location: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.4 = [33 x i8] c"Unable to get input from stdin.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8*]
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca i64
store i32 0, i32* %1
%6 = bitcast [3 x i8*]* %2 to i8*
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%8 = call i32 @performMenu(i8** %7, i32 3)
store i32 %8, i32* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 256, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %56
17: ; preds = %0
store i64 0, i64* %5
br label %18
18: ; preds = %30, %17
%19 = load i64, i64* %5
%20 = icmp ult i64 %19, 256
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i64, i64* %5
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @iscntrl(i8 signext %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br label %28
28: ; preds = %21, %18
%29 = phi i1 [ false, %18 ], [ %27, %21 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i64, i64* %5
%32 = add i64 %31, 1
store i64 %32, i64* %5
br label %18
33: ; preds = %28
%34 = load i64, i64* %5
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %34
store i8 0, i8* %35
%36 = load i32, i32* %3
switch i32 %36, label %55 [
i32 1, label %37
i32 2, label %43
i32 3, label %49
]
37: ; preds = %33
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%39 = call i32 @readFic(i8* %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 1, i32* %1
br label %56
42: ; preds = %37
br label %55
43: ; preds = %33
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%45 = call i32 @editFic(i8* %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 1, i32* %1
br label %56
48: ; preds = %43
br label %55
49: ; preds = %33
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%51 = call i32 @createNewFic(i8* %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %49
store i32 1, i32* %1
br label %56
54: ; preds = %49
br label %55
55: ; preds = %33, %54, %48, %42
store i32 0, i32* %1
br label %56
56: ; preds = %55, %53, %47, %41, %14
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str = [10 x i8] c"Read file\00"
@.str.1 = [19 x i8] c"Edit existing file\00"
@.str.2 = [16 x i8] c"Create new file\00"
@__const.main.FILE_MENU = [3 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [26 x i8] c"Enter the file location: \00"
@stdin = global i32 0
@stderr = global i32 0
@.str.4 = [33 x i8] c"Unable to get input from stdin.\0A\00"
define i32 @main() {
%1 = alloca [3 x i8*]
%2 = alloca [256 x i8]
%3 = bitcast [3 x i8*]* %1 to i8*
%4 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%5 = call i32 @performMenu(i8** %4, i32 3)
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 256, i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %36
14: ; preds = %0, %20
%15 = phi i64 [ %21, %20 ], [ 0, %0 ]
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @iscntrl(i8 signext %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = add nuw nsw i64 %15, 1
%22 = icmp eq i64 %21, 256
br i1 %22, label %23, label %14
23: ; preds = %20, %14
%24 = phi i64 [ 256, %20 ], [ %15, %14 ]
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %24
store i8 0, i8* %25
switch i32 %5, label %35 [
i32 1, label %26
i32 2, label %29
i32 3, label %32
]
26: ; preds = %23
%27 = call i32 @readFic(i8* %7)
%28 = icmp eq i32 %27, 0
br i1 %28, label %35, label %36
29: ; preds = %23
%30 = call i32 @editFic(i8* %7)
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %36
32: ; preds = %23
%33 = call i32 @createNewFic(i8* %7)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32, %29, %26, %23
br label %36
36: ; preds = %35, %26, %29, %32, %11
%37 = phi i32 [ 1, %11 ], [ 0, %35 ], [ 1, %26 ], [ 1, %29 ], [ 1, %32 ]
ret i32 %37
}