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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ die(char *, char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void dump_file_content(const char *path) {
  char buf[BUFSIZ];
  ssize_t n;
  FILE *fp;
  fp = fopen(path, "r");
  if (!fp)
    die("reading %s", path);
  do {
    n = fread(buf, 1, BUFSIZ, fp);
    if (n > 0)
      fwrite(buf, 1, n, stdout);
  } while (n > 0);
  fclose(fp);
}


x86 assembly (clang, -O0):
<dump_file_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b7 <dump_file_content+0x67>
mov    -0x8(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1060 <die@plt>
jmp    11bc <dump_file_content+0x6c>
mov    -0x30(%rbp),%rdi
mov    0x2e19(%rip),%rax
mov    (%rax),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jle    1201 <dump_file_content+0xb1>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    0x2de3(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
jmp    1206 <dump_file_content+0xb6>
cmpq   $0x0,-0x20(%rbp)
jg     11bc <dump_file_content+0x6c>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_file_content>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    0x2e7b(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe7f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    119d <dump_file_content+0x4d>
lea    0xe6d(%rip),%rdi
mov    %r15,%rsi
call   1060 <die@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jle    11ec <dump_file_content+0x9c>
mov    0x2e1b(%rip),%r15
nopl   (%rax)
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1070 <fwrite@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jg     11c0 <dump_file_content+0x70>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"reading %s\00"
@stdout = global i32 0
define void @dump_file_content(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32*
store i8* %0, i8** %2
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i8, i64 %8
store i64 %8, i64* %4
%11 = load i8*, i8** %2
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %1
%16 = load i8*, i8** %2
%17 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %1
br label %19
19: ; preds = %30, %18
%20 = load i32, i32* @BUFSIZ
%21 = load i32*, i32** %6
%22 = call i64 @fread(i8* %10, i32 1, i32 %20, i32* %21)
store i64 %22, i64* %5
%23 = load i64, i64* %5
%24 = icmp sgt i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i64, i64* %5
%27 = load i32, i32* @stdout
%28 = call i32 @fwrite(i8* %10, i32 1, i64 %26, i32 %27)
br label %29
29: ; preds = %25, %19
br label %30
30: ; preds = %29
%31 = load i64, i64* %5
%32 = icmp sgt i64 %31, 0
br i1 %32, label %19, label %33
33: ; preds = %30
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
%36 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"reading %s\00"
@stdout = global i32 0
define void @dump_file_content(i8* %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %1
%10 = load i32, i32* @BUFSIZ
%11 = call i64 @fread(i8* %4, i32 1, i32 %10, i32* %5)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %9, %13
%14 = phi i64 [ %18, %13 ], [ %11, %9 ]
%15 = load i32, i32* @stdout
%16 = call i32 @fwrite(i8* %4, i32 1, i64 %14, i32 %15)
%17 = load i32, i32* @BUFSIZ
%18 = call i64 @fread(i8* %4, i32 1, i32 %17, i32* %5)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %13, label %20
20: ; preds = %13, %9
%21 = call i32 @fclose(i32* %5)
ret void
}