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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int main(int argc, char **argv) {
  char map_line[100];
  unsigned int i;
  int f, r;
  f = open("tests/test5.c", O_RDONLY);
  while ((r = read(f, map_line, sizeof(map_line))) > 0) {
    map_line[r] = '\0';
    printf("%s", map_line);
    for (i = 0; i < 2000000000; i++)
      ;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0xea7(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x64,%edx
call   1040 <read@plt>
mov    %eax,-0x8c(%rbp)
cmp    $0x0,%eax
jle    11db <main+0xab>
movslq -0x8c(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x77359400,-0x84(%rbp)
94 35 77
jae    11d6 <main+0xa6>
jmp    11c2 <main+0x92>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11ad <main+0x7d>
jmp    1164 <main+0x34>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%esi
lea    0xeb8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x64,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    1194 <main+0x64>
lea    0xea5(%rip),%r14
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1040 <read@plt>
test   %eax,%eax
jg     1170 <main+0x40>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"tests/test5.c\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @O_RDONLY
%11 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %8
br label %12
12: ; preds = %30, %2
%13 = load i32, i32* %8
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%15 = call i32 @read(i32 %13, i8* %14, i32 100)
store i32 %15, i32* %9
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %12
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 0, i32* %7
br label %23
23: ; preds = %27, %17
%24 = load i32, i32* %7
%25 = icmp ult i32 %24, 2000000000
br i1 %25, label %26, label %30
26: ; preds = %23
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add i32 %28, 1
store i32 %29, i32* %7
br label %23
30: ; preds = %23
br label %12
31: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"tests/test5.c\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @read(i32 %6, i8* %4, i32 100)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %2, %9
%10 = phi i32 [ %14, %9 ], [ %7, %2 ]
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %11
store i8 0, i8* %12
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%14 = call i32 @read(i32 %6, i8* %4, i32 100)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %9, label %16
16: ; preds = %9, %2
ret i32 0
}