#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *TranslatePHP(int /*<<< orphan*/);
int /*<<< orphan*/ TranslateSmartQuotes(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char const *);
scalar_t__ stat(char const *, struct stat *);
char *InputBuffer(const char *fileName) {
  struct stat statBuf;
  if (stat(fileName, &statBuf) != 0) {
    perror(fileName);
    exit(2);
  }
  FILE *fp = fopen(fileName, "r");
  if (!fp) {
    perror(fileName);
    exit(2);
  }
  char *data = (char *)malloc(sizeof(char) * (statBuf.st_size + 1));
  if (!data) {
    perror("InputBuffer_data");
    exit(2);
  }
  if (statBuf.st_size && fread(data, statBuf.st_size, 1, fp) != 1) {
    perror(fileName);
    exit(2);
  }
  fclose(fp);
  data[statBuf.st_size] = 0;
  return TranslatePHP(TranslateSmartQuotes(data));
}


x86 assembly (clang, -O0):
<InputBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
je     11c6 <InputBuffer+0x36>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f8 <InputBuffer+0x68>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1230 <InputBuffer+0xa0>
lea    0xde1(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x10(%rbp)
je     126b <InputBuffer+0xdb>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     126b <InputBuffer+0xdb>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
call   1050 <TranslateSmartQuotes@plt>
mov    %eax,%edi
call   1060 <TranslatePHP@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InputBuffer>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%rsi
call   1070 <stat@plt>
test   %rax,%rax
jne    121d <InputBuffer+0x8d>
lea    0xe4e(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     121d <InputBuffer+0x8d>
mov    %rax,%r15
mov    0x8(%rsp),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1222 <InputBuffer+0x92>
mov    %rax,%rbx
mov    0x8(%rsp),%esi
test   %esi,%esi
je     11f3 <InputBuffer+0x63>
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    121d <InputBuffer+0x8d>
mov    %r15,%rdi
call   1040 <fclose@plt>
movslq 0x8(%rsp),%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
call   1050 <TranslateSmartQuotes@plt>
mov    %eax,%edi
call   1060 <TranslatePHP@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
jmp    1229 <InputBuffer+0x99>
lea    0xdd9(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"InputBuffer_data\00"
define i8* @InputBuffer(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @stat(i8* %6, %struct.stat* %3)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @perror(i8* %10)
%12 = call i32 @exit(i32 2)
unreachable
13: ; preds = %1
%14 = load i8*, i8** %2
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %4
%16 = load i32*, i32** %4
%17 = icmp ne i32* %16, null
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i32 @perror(i8* %19)
%21 = call i32 @exit(i32 2)
unreachable
22: ; preds = %13
%23 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = mul i64 1, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %5
%31 = load i8*, i8** %5
%32 = icmp ne i8* %31, null
br i1 %32, label %36, label %33
33: ; preds = %22
%34 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 2)
unreachable
36: ; preds = %22
%37 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %51
40: ; preds = %36
%41 = load i8*, i8** %5
%42 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%43 = load i32, i32* %42
%44 = load i32*, i32** %4
%45 = call i32 @fread(i8* %41, i32 %43, i32 1, i32* %44)
%46 = icmp ne i32 %45, 1
br i1 %46, label %47, label %51
47: ; preds = %40
%48 = load i8*, i8** %2
%49 = call i32 @perror(i8* %48)
%50 = call i32 @exit(i32 2)
unreachable
51: ; preds = %40, %36
%52 = load i32*, i32** %4
%53 = call i32 @fclose(i32* %52)
%54 = load i8*, i8** %5
%55 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%56 = load i32, i32* %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %54, i64 %57
store i8 0, i8* %58
%59 = load i8*, i8** %5
%60 = call i32 @TranslateSmartQuotes(i8* %59)
%61 = call i8* @TranslatePHP(i32 %60)
ret i8* %61
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"InputBuffer_data\00"
define i8* @InputBuffer(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = call i32 @perror(i8* %0)
%8 = call i32 @exit(i32 2)
unreachable
9: ; preds = %1
%10 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @perror(i8* %0)
%14 = call i32 @exit(i32 2)
unreachable
15: ; preds = %9
%16 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = icmp eq i64 %19, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 2)
unreachable
25: ; preds = %15
%26 = load i32, i32* %16
%27 = icmp eq i32 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = call i32 @fread(i8* %20, i32 %26, i32 1, i32* %10)
%30 = icmp eq i32 %29, 1
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = call i32 @perror(i8* %0)
%33 = call i32 @exit(i32 2)
unreachable
34: ; preds = %28, %25
%35 = call i32 @fclose(i32* %10)
%36 = load i32, i32* %16
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %20, i64 %37
store i8 0, i8* %38
%39 = call i32 @TranslateSmartQuotes(i8* %20)
%40 = call i8* @TranslatePHP(i32 %39)
ret i8* %40
}