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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ sigsafe_printf(char *, int);
int /*<<< orphan*/ write(int, char *, int);
void dumpit(char *f) {
  int fd = open(f, O_RDONLY);
  char buf[100];
  int nr_read;
  do {
    if (2 <= 0)
      sigsafe_printf("maps fd: %d\n", fd);
    fflush(NULL);
  } while (0);
  do {
    nr_read = read(fd, &buf[0], sizeof(buf));
    write(1, buf, nr_read);
  } while (nr_read > 0);
  close(fd);
}


x86 assembly (clang, -O0):
<dumpit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
jmp    1182 <dumpit+0x32>
mov    -0xc(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
call   1050 <read@plt>
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmpl   $0x0,-0x74(%rbp)
jg     1182 <dumpit+0x32>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpit>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%r14d
xor    %edi,%edi
call   1060 <fflush@plt>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1050 <read@plt>
mov    %eax,%ebp
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %ebp,%ebp
jg     1180 <dumpit+0x30>
mov    %r14d,%edi
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <close@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
define void @dumpit(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = load i32, i32* @O_RDONLY
%8 = call i32 @open(i8* %6, i32 %7)
store i32 %8, i32* %3
br label %9
9: ; preds = %1
%10 = call i32 @fflush(i32* null)
br label %11
11: ; preds = %9
br label %12
12: ; preds = %19, %11
%13 = load i32, i32* %3
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = call i32 @read(i32 %13, i8* %14, i32 100)
store i32 %15, i32* %5
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%17 = load i32, i32* %5
%18 = call i32 @write(i32 1, i8* %16, i32 %17)
br label %19
19: ; preds = %12
%20 = load i32, i32* %5
%21 = icmp sgt i32 %20, 0
br i1 %21, label %12, label %22
22: ; preds = %19
%23 = load i32, i32* %3
%24 = call i32 @close(i32 %23)
ret void
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
define void @dumpit(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* %0, i32 %3)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @fflush(i32* null)
br label %7
7: ; preds = %7, %1
%8 = call i32 @read(i32 %4, i8* %5, i32 100)
%9 = call i32 @write(i32 1, i8* %5, i32 %8)
%10 = icmp sgt i32 %8, 0
br i1 %10, label %7, label %11
11: ; preds = %7
%12 = tail call i32 @close(i32 %4)
ret void
}