#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getFileName(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ processText(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  char fileName[30];
  srand(time(NULL));
  FILE *ifp;
  getFileName(fileName, 30);
  ifp = fopen(fileName, "r");
  if (ifp == NULL) {
    printf("Sorry, file does not exist\n");
    return 0;
  }
  fclose(ifp);
  processText(fileName);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x30(%rbp),%rdi
mov    $0x1e,%esi
call   1090 <getFileName@plt>
lea    -0x30(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11d4 <main+0x64>
lea    0xe3f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f9 <main+0x89>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x30(%rbp),%rdi
call   1030 <processText@plt>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   10a0 <getFileName@plt>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     11d3 <main+0x53>
mov    %rax,%rdi
call   1060 <fclose@plt>
mov    %rsp,%rdi
call   1050 <processText@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11df <main+0x5f>
lea    0xe28(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [28 x i8] c"Sorry, file does not exist\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%7 = call i32 @getFileName(i8* %6, i32 30)
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %3
%10 = load i32*, i32** %3
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %20
14: ; preds = %0
%15 = load i32*, i32** %3
%16 = call i32 @fclose(i32* %15)
%17 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%18 = call i32 @processText(i8* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %20
20: ; preds = %14, %12
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@str = [27 x i8] c"Sorry, file does not exist\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = call i32 @getFileName(i8* %2, i32 30)
%6 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %14
10: ; preds = %0
%11 = call i32 @fclose(i32* %6)
%12 = call i32 @processText(i8* %2)
%13 = call i32 @putchar(i32 10)
br label %14
14: ; preds = %10, %8
ret i32 0
}