#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 */
char *GetFileName();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
FILE *GetFile(void) {
  FILE *fp;
  char *FileName;
  while ((fp = fopen((FileName = GetFileName()), "rb")) == NULL) {
    printf("Could not find file %s\n", FileName);
    free(FileName);
  }
  free(FileName);
  return fp;
}


x86 assembly (clang, -O0):
<GetFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <GetFileName@plt>
mov    %rax,%rdi
mov    %rdi,-0x10(%rbp)
lea    0xea3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    118e <GetFile+0x4e>
mov    -0x10(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1148 <GetFile+0x8>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFile>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <GetFileName@plt>
mov    %rax,%r12
lea    0xea7(%rip),%rsi
mov    %rax,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
jne    11ad <GetFile+0x6d>
lea    0xe96(%rip),%r14
lea    0xe8c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1060 <GetFileName@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1180 <GetFile+0x40>
mov    %rax,%rbx
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [24 x i8] c"Could not find file %s\0A\00"
define i32* @GetFile() {
%1 = alloca i32*
%2 = alloca i8*
br label %3
3: ; preds = %7, %0
%4 = call i8* (...) @GetFileName()
store i8* %4, i8** %2
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %1
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 @free(i8* %10)
br label %3
12: ; preds = %3
%13 = load i8*, i8** %2
%14 = call i32 @free(i8* %13)
%15 = load i32*, i32** %1
ret i32* %15
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [24 x i8] c"Could not find file %s\0A\00"
define noalias i32* @GetFile() {
%1 = tail call i8* (...) @GetFileName()
%2 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %11
4: ; preds = %0, %4
%5 = phi i8* [ %8, %4 ], [ %1, %0 ]
%6 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = tail call i32 @free(i8* %5)
%8 = tail call i8* (...) @GetFileName()
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %4, label %11
11: ; preds = %4, %0
%12 = phi i8* [ %1, %0 ], [ %8, %4 ]
%13 = phi i32* [ %2, %0 ], [ %9, %4 ]
%14 = tail call i32 @free(i8* %12)
ret i32* %13
}