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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int buffer_to_output(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fread(char *, long, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(long);
int /*<<< orphan*/ stderr;
int input_to_output(FILE *pInput, FILE *pOutput) {
  char *pHog = NULL;
  long lSize = 0;
  int iRetval = 0;
  fseek(pInput, 0, SEEK_END);
  lSize = ftell(pInput);
  fseek(pInput, 0, SEEK_SET);
  pHog = (char *)malloc(lSize + 1);
  if (pHog) {
    *(pHog + lSize) = '\0';
    fread(pHog, lSize, 1, pInput);
    iRetval = buffer_to_output(pHog, pOutput);
    free(pHog);
    pHog = NULL;
  } else {
    fprintf(stderr, "MANTOMAK:  Out of Memory....\n");
    iRetval = 1;
  }
  return (iRetval);
}


x86 assembly (clang, -O0):
<input_to_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e0d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1230 <input_to_output+0xc0>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <buffer_to_output@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
jmp    124c <input_to_output+0xdc>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_to_output>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r12,%rdi
call   1060 <ftell@plt>
mov    %rax,%r15
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
lea    0x1(%r15),%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     11ee <input_to_output+0x7e>
mov    %rax,%rbx
movb   $0x0,(%rax,%r15,1)
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <buffer_to_output@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
jmp    1208 <input_to_output+0x98>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"MANTOMAK: Out of Memory....\0A\00"
define i32 @input_to_output(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i8* null, i8** %5
store i64 0, i64* %6
store i32 0, i32* %7
%8 = load i32*, i32** %3
%9 = load i32, i32* @SEEK_END
%10 = call i32 @fseek(i32* %8, i32 0, i32 %9)
%11 = load i32*, i32** %3
%12 = call i64 @ftell(i32* %11)
store i64 %12, i64* %6
%13 = load i32*, i32** %3
%14 = load i32, i32* @SEEK_SET
%15 = call i32 @fseek(i32* %13, i32 0, i32 %14)
%16 = load i64, i64* %6
%17 = add nsw i64 %16, 1
%18 = call i64 @malloc(i64 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %5
%20 = load i8*, i8** %5
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %35
22: ; preds = %2
%23 = load i8*, i8** %5
%24 = load i64, i64* %6
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8 0, i8* %25
%26 = load i8*, i8** %5
%27 = load i64, i64* %6
%28 = load i32*, i32** %3
%29 = call i32 @fread(i8* %26, i64 %27, i32 1, i32* %28)
%30 = load i8*, i8** %5
%31 = load i32*, i32** %4
%32 = call i32 @buffer_to_output(i8* %30, i32* %31)
store i32 %32, i32* %7
%33 = load i8*, i8** %5
%34 = call i32 @free(i8* %33)
store i8* null, i8** %5
br label %38
35: ; preds = %2
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %7
br label %38
38: ; preds = %35, %22
%39 = load i32, i32* %7
ret i32 %39
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"MANTOMAK: Out of Memory....\0A\00"
define i32 @input_to_output(i32* nocapture %0, i32* %1) {
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @fseek(i32* %0, i32 0, i32 %3)
%5 = tail call i64 @ftell(i32* %0)
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %0, i32 0, i32 %6)
%8 = add nsw i64 %5, 1
%9 = tail call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
%11 = icmp eq i64 %9, 0
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = getelementptr inbounds i8, i8* %10, i64 %5
store i8 0, i8* %13
%14 = tail call i32 @fread(i8* %10, i64 %5, i32 1, i32* %0)
%15 = tail call i32 @buffer_to_output(i8* %10, i32* %1)
%16 = tail call i32 @free(i8* %10)
br label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %17, %12
%21 = phi i32 [ %15, %12 ], [ 1, %17 ]
ret i32 %21
}