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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SYS_close;
int /*<<< orphan*/ SYS_open;
int /*<<< orphan*/ SYS_read;
int /*<<< orphan*/ findAndPrint(char *);
int syscall(int /*<<< orphan*/, ...);
void printStatus(char *path) {
  char readBuffer[1048576];
  int i;
  int fd = syscall(SYS_open, path, O_RDONLY);
  syscall(SYS_read, fd, readBuffer, sizeof(readBuffer));
  char *poof = readBuffer;
  while (*poof && poof) {
    i = 0;
    char temp_line[1000];
    while (*poof && *poof != '\n') {
      temp_line[i] = *poof;
      poof++;
      i++;
    }
    temp_line[i] = '\n';
    temp_line[i + 1] = 0;
    findAndPrint(temp_line);
    poof++;
  }
  syscall(SYS_close, fd);
}


x86 assembly (clang, -O0):
<printStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100420,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    0x2ea5(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %eax,-0x100018(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x100018(%rbp),%esi
lea    -0x100010(%rbp),%rdx
mov    $0x100000,%ecx
mov    $0x0,%al
call   1030 <syscall@plt>
lea    -0x100010(%rbp),%rax
mov    %rax,-0x100020(%rbp)
mov    -0x100020(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x100411(%rbp)
je     11ae <printStatus+0x8e>
cmpq   $0x0,-0x100020(%rbp)
setne  %al
mov    %al,-0x100411(%rbp)
mov    -0x100411(%rbp),%al
test   $0x1,%al
jne    11c1 <printStatus+0xa1>
jmp    1291 <printStatus+0x171>
movl   $0x0,-0x100014(%rbp)
mov    -0x100020(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x100412(%rbp)
je     11fc <printStatus+0xdc>
mov    -0x100020(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x100412(%rbp)
mov    -0x100412(%rbp),%al
test   $0x1,%al
jne    120f <printStatus+0xef>
jmp    124c <printStatus+0x12c>
mov    -0x100020(%rbp),%rax
mov    (%rax),%cl
movslq -0x100014(%rbp),%rax
mov    %cl,-0x100410(%rbp,%rax,1)
mov    -0x100020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x100020(%rbp)
mov    -0x100014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100014(%rbp)
jmp    11cb <printStatus+0xab>
movslq -0x100014(%rbp),%rax
movb   $0xa,-0x100410(%rbp,%rax,1)
0a
mov    -0x100014(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x100410(%rbp,%rax,1)
lea    -0x100410(%rbp),%rdi
call   1040 <findAndPrint@plt>
mov    -0x100020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x100020(%rbp)
jmp    1182 <printStatus+0x62>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
mov    -0x100018(%rbp),%esi
mov    $0x0,%al
call   1030 <syscall@plt>
add    $0x100420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printStatus>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1003f8,%rsp
mov    %rdi,%rsi
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
mov    0x2ea8(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    %eax,%r14d
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0x3f0(%rsp),%rbx
mov    $0x100000,%ecx
mov    %r14d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x3f0(%rsp),%al
test   %al,%al
je     11c6 <printStatus+0xa6>
mov    %rsp,%r15
jmp    11a4 <printStatus+0x84>
nop
mov    %ebp,%eax
movb   $0xa,(%rsp,%rax,1)
lea    0x1(%rbp),%eax
movb   $0x0,(%rsp,%rax,1)
mov    %r15,%rdi
call   1040 <findAndPrint@plt>
mov    0x1(%rbx,%rbp,1),%al
add    %rbp,%rbx
add    $0x1,%rbx
test   %al,%al
je     11c6 <printStatus+0xa6>
xor    %ebp,%ebp
test   %al,%al
je     1180 <printStatus+0x60>
nopw   0x0(%rax,%rax,1)
cmp    $0xa,%al
je     1180 <printStatus+0x60>
mov    %al,(%rsp,%rbp,1)
movzbl 0x1(%rbx,%rbp,1),%eax
add    $0x1,%rbp
test   %al,%al
jne    11b0 <printStatus+0x90>
jmp    1180 <printStatus+0x60>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <syscall@plt>
add    $0x1003f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SYS_open = global i32 0
@O_RDONLY = global i32 0
@SYS_read = global i32 0
@SYS_close = global i32 0
define void @printStatus(i8* %0) {
%2 = alloca i8*
%3 = alloca [1048576 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [1000 x i8]
store i8* %0, i8** %2
%8 = load i32, i32* @SYS_open
%9 = load i8*, i8** %2
%10 = load i32, i32* @O_RDONLY
%11 = call i32 (i32, ...) @syscall(i32 %8, i8* %9, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* @SYS_read
%13 = load i32, i32* %5
%14 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 0
%15 = call i32 (i32, ...) @syscall(i32 %12, i32 %13, i8* %14, i64 1048576)
%16 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 0
store i8* %16, i8** %6
br label %17
17: ; preds = %50, %1
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %6
%24 = icmp ne i8* %23, null
br label %25
25: ; preds = %22, %17
%26 = phi i1 [ false, %17 ], [ %24, %22 ]
br i1 %26, label %27, label %62
27: ; preds = %25
store i32 0, i32* %4
br label %28
28: ; preds = %40, %27
%29 = load i8*, i8** %6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = load i8*, i8** %6
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 10
br label %38
38: ; preds = %33, %28
%39 = phi i1 [ false, %28 ], [ %37, %33 ]
br i1 %39, label %40, label %50
40: ; preds = %38
%41 = load i8*, i8** %6
%42 = load i8, i8* %41
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %44
store i8 %42, i8* %45
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %6
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %28
50: ; preds = %38
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %52
store i8 10, i8* %53
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %56
store i8 0, i8* %57
%58 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%59 = call i32 @findAndPrint(i8* %58)
%60 = load i8*, i8** %6
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %6
br label %17
62: ; preds = %25
%63 = load i32, i32* @SYS_close
%64 = load i32, i32* %5
%65 = call i32 (i32, ...) @syscall(i32 %63, i32 %64)
ret void
}

LLVM IR (-O2):
@SYS_open = global i32 0
@O_RDONLY = global i32 0
@SYS_read = global i32 0
@SYS_close = global i32 0
define void @printStatus(i8* %0) {
%2 = alloca [1048576 x i8]
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @SYS_open
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 (i32, ...) @syscall(i32 %5, i8* %0, i32 %6)
%8 = load i32, i32* @SYS_read
%9 = call i32 (i32, ...) @syscall(i32 %8, i32 %7, i8* %4, i64 1048576)
%10 = load i8, i8* %4
%11 = icmp eq i8 %10, 0
br i1 %11, label %36, label %12
12: ; preds = %1
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
br label %14
14: ; preds = %12, %26
%15 = phi i8 [ %10, %12 ], [ %34, %26 ]
%16 = phi i8* [ %4, %12 ], [ %33, %26 ]
br label %17
17: ; preds = %21, %14
%18 = phi i8 [ %25, %21 ], [ %15, %14 ]
%19 = phi i64 [ %24, %21 ], [ 0, %14 ]
%20 = phi i8* [ %23, %21 ], [ %16, %14 ]
switch i8 %18, label %21 [
i8 0, label %26
i8 10, label %26
]
21: ; preds = %17
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %19
store i8 %18, i8* %22
%23 = getelementptr inbounds i8, i8* %20, i64 1
%24 = add nuw i64 %19, 1
%25 = load i8, i8* %23
br label %17
26: ; preds = %17, %17
%27 = and i64 %19, 4294967295
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %27
store i8 10, i8* %28
%29 = add i64 %19, 1
%30 = and i64 %29, 4294967295
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %30
store i8 0, i8* %31
%32 = call i32 @findAndPrint(i8* %13)
%33 = getelementptr inbounds i8, i8* %20, i64 1
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
br i1 %35, label %36, label %14
36: ; preds = %26, %1
%37 = load i32, i32* @SYS_close
%38 = call i32 (i32, ...) @syscall(i32 %37, i32 %7)
ret void
}