#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 void FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose_fastcall(void *);
int /*<<< orphan*/ fgets_callee(char *, int, void *);
void *fopen_callee(char *, char *);
int /*<<< orphan*/ fputs_callee(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printn(void *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
main() {
  FILE *fp;
  char line[81];
  int i;
  fp = fopen_callee("filetest.c", "r");
  if ((fp == ((void *)(0)))) {
    fputs_callee("\nCan't open file, sorry", stdout);
    exit(0);
  }
  printn(fp, 10, stdout);
  for (i = 0; i != 5; i++) {
    fgets_callee(line, 80, fp);
    fputs_callee(line, stdout);
  }
  fclose_fastcall(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <fopen_callee@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b0 <main+0x50>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe69(%rip),%rdi
call   1070 <fputs_callee@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1030 <printn@plt>
movl   $0x0,-0x74(%rbp)
cmpl   $0x5,-0x74(%rbp)
je     120a <main+0xaa>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets_callee@plt>
lea    -0x70(%rbp),%rdi
mov    0x2deb(%rip),%rax
mov    (%rax),%esi
call   1070 <fputs_callee@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11ce <main+0x6e>
mov    -0x10(%rbp),%rdi
call   1050 <fclose_fastcall@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xe90(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1040 <fopen_callee@plt>
mov    0x2e5d(%rip),%r15
mov    (%r15),%edx
test   %rax,%rax
je     123d <main+0xdd>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1030 <printn@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets_callee@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1070 <fputs_callee@plt>
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets_callee@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1070 <fputs_callee@plt>
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets_callee@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1070 <fputs_callee@plt>
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets_callee@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1070 <fputs_callee@plt>
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1060 <fgets_callee@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1070 <fputs_callee@plt>
mov    %rbx,%rdi
call   1050 <fclose_fastcall@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdc9(%rip),%rdi
mov    %edx,%esi
call   1070 <fputs_callee@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"filetest.c\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"\0ACan't open file, sorry\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [81 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i8* @fopen_callee(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @stdout
%10 = call i32 @fputs_callee(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %0
%13 = load i8*, i8** %2
%14 = load i32, i32* @stdout
%15 = call i32 @printn(i8* %13, i32 10, i32 %14)
store i32 0, i32* %4
br label %16
16: ; preds = %26, %12
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 5
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%21 = load i8*, i8** %2
%22 = call i32 @fgets_callee(i8* %20, i32 80, i8* %21)
%23 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%24 = load i32, i32* @stdout
%25 = call i32 @fputs_callee(i8* %23, i32 %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %16
29: ; preds = %16
%30 = load i8*, i8** %2
%31 = call i32 @fclose_fastcall(i8* %30)
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [11 x i8] c"filetest.c\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"\0ACan't open file, sorry\00"
@stdout = global i32 0
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 i8* @fopen_callee(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i8* %3, null
%5 = load i32, i32* @stdout
br i1 %4, label %6, label %9
6: ; preds = %0
%7 = tail call i32 @fputs_callee(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %0
%10 = tail call i32 @printn(i8* %3, i32 10, i32 %5)
%11 = call i32 @fgets_callee(i8* %2, i32 80, i8* %3)
%12 = load i32, i32* @stdout
%13 = call i32 @fputs_callee(i8* %2, i32 %12)
%14 = call i32 @fgets_callee(i8* %2, i32 80, i8* %3)
%15 = load i32, i32* @stdout
%16 = call i32 @fputs_callee(i8* %2, i32 %15)
%17 = call i32 @fgets_callee(i8* %2, i32 80, i8* %3)
%18 = load i32, i32* @stdout
%19 = call i32 @fputs_callee(i8* %2, i32 %18)
%20 = call i32 @fgets_callee(i8* %2, i32 80, i8* %3)
%21 = load i32, i32* @stdout
%22 = call i32 @fputs_callee(i8* %2, i32 %21)
%23 = call i32 @fgets_callee(i8* %2, i32 80, i8* %3)
%24 = load i32, i32* @stdout
%25 = call i32 @fputs_callee(i8* %2, i32 %24)
%26 = call i32 @fclose_fastcall(i8* %3)
ret i32 0
}