#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 /*<<< orphan*/ O_WRONLY;
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  char map_line[100];
  unsigned int i;
  int f, fw, r;
  f = open("tests/test5.c", O_RDONLY);
  fw = open("tmpsrc5.c", O_WRONLY);
  while ((r = read(f, map_line, sizeof(map_line))) > 0) {
    write(fw, map_line, r);
    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    0x2e65(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x88(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x64,%edx
call   1040 <read@plt>
mov    %eax,-0x90(%rbp)
cmp    $0x0,%eax
jle    11ef <main+0xbf>
mov    -0x8c(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    -0x90(%rbp),%edx
call   1030 <write@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x77359400,-0x84(%rbp)
94 35 77
jae    11ea <main+0xba>
jmp    11d6 <main+0xa6>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11c1 <main+0x91>
jmp    117f <main+0x4f>
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,%r14d
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xeae(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0x64,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    11a0 <main+0x70>
mov    %rsp,%rbx
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1040 <read@plt>
test   %eax,%eax
jg     1180 <main+0x50>
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 = [10 x i8] c"tmpsrc5.c\00"
@O_WRONLY = global i32 0
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
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @O_RDONLY
%12 = call i32 @open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %8
%13 = load i32, i32* @O_WRONLY
%14 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %13)
store i32 %14, i32* %9
br label %15
15: ; preds = %32, %2
%16 = load i32, i32* %8
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = call i32 @read(i32 %16, i8* %17, i32 100)
store i32 %18, i32* %10
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %15
%21 = load i32, i32* %9
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %10
%24 = call i32 @write(i32 %21, i8* %22, i32 %23)
store i32 0, i32* %7
br label %25
25: ; preds = %29, %20
%26 = load i32, i32* %7
%27 = icmp ult i32 %26, 2000000000
br i1 %27, label %28, label %32
28: ; preds = %25
br label %29
29: ; preds = %28
%30 = load i32, i32* %7
%31 = add i32 %30, 1
store i32 %31, i32* %7
br label %25
32: ; preds = %25
br label %15
33: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"tests/test5.c\00"
@O_RDONLY = global i32 0
@.str.1 = [10 x i8] c"tmpsrc5.c\00"
@O_WRONLY = global i32 0
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 = load i32, i32* @O_WRONLY
%8 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @read(i32 %6, i8* %4, i32 100)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2, %11
%12 = phi i32 [ %14, %11 ], [ %9, %2 ]
%13 = call i32 @write(i32 %8, i8* %4, i32 %12)
%14 = call i32 @read(i32 %6, i8* %4, i32 100)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %11, label %16
16: ; preds = %11, %2
ret i32 0
}