#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *textFile;
  textFile = fopen("numbers2.txt", "r");
  char line[256];
  if (textFile == NULL) {
    printf("[ERROR] Can't open the file.\n");
    return 0;
  } else {
    while (fgets(line, sizeof(line), textFile) != NULL) {
      printf("%s", line);
    }
    fclose(textFile);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    0xead(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118e <main+0x4e>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11dc <main+0x9c>
jmp    1193 <main+0x53>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11cc <main+0x8c>
lea    -0x110(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1193 <main+0x53>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xe9d(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11cc <main+0x7c>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c2 <main+0x72>
lea    0xe7c(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    11d8 <main+0x88>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"numbers2.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"[ERROR] Can't open the file.\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [256 x i8]
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %22
9: ; preds = %0
br label %10
10: ; preds = %15, %9
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32* @fgets(i8* %11, i32 256, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16)
br label %10
18: ; preds = %10
%19 = load i32*, i32** %2
%20 = call i32 @fclose(i32* %19)
br label %21
21: ; preds = %18
store i32 0, i32* %1
br label %22
22: ; preds = %21, %7
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [13 x i8] c"numbers2.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
@str = [29 x i8] c"[ERROR] Can't open the file.\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = icmp eq i32* %2, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32* @fgets(i8* %3, i32 256, i32* %2)
%7 = icmp eq i32* %6, null
br i1 %7, label %14, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %16
10: ; preds = %5, %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%12 = call i32* @fgets(i8* %3, i32 256, i32* %2)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %10
14: ; preds = %10, %5
%15 = call i32 @fclose(i32* %2)
br label %16
16: ; preds = %14, %8
ret i32 0
}