#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void myread() {
  FILE *fPointer = NULL;
  char buff[100];
  fPointer = fopen("words", "r");
  if (fPointer == NULL) {
    printf("Error to open file\n");
    exit(EXIT_FAILURE);
  }
  while (!feof(fPointer)) {
    fgets(buff, 100, fPointer);
    printf("%s", buff);
  }
  fclose(fPointer);
}


x86 assembly (clang, -O0):
<myread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xe89(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11ae <myread+0x4e>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11b3 <myread+0x53>
mov    -0x8(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d1 <myread+0x71>
jmp    11fa <myread+0x9a>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
lea    -0x70(%rbp),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b3 <myread+0x53>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myread>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xe80(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11eb <myread+0x7b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11d9 <myread+0x69>
mov    %rsp,%r14
lea    0xe5e(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11b0 <myread+0x40>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"words\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error to open file\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @myread() {
%1 = alloca i32*
%2 = alloca [100 x i8]
store i32* null, i32** %1
%3 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
br label %11
11: ; preds = %16, %10
%12 = load i32*, i32** %1
%13 = call i32 @feof(i32* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = load i32*, i32** %1
%19 = call i32 @fgets(i8* %17, i32 100, i32* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %11
22: ; preds = %11
%23 = load i32*, i32** %1
%24 = call i32 @fclose(i32* %23)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"words\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@str = [19 x i8] c"Error to open file\00"
define void @myread() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 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 i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @feof(i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %17
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %5, %12
%13 = call i32 @fgets(i8* %2, i32 100, i32* %3)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%15 = call i32 @feof(i32* %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %12, label %17
17: ; preds = %12, %5
%18 = call i32 @fclose(i32* %3)
ret void
}