#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*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int inEx2(int /*<<< orphan*/ *, int, int, unsigned char *, int /*<<< orphan*/);
unsigned char *malloc(int);
unsigned char *inEx(FILE *fin, int inOffset, int size, int *outSize) {
  unsigned char *result;
  fseek(fin, 0, SEEK_END);
  *outSize = ftell(fin) - inOffset;
  if (*outSize <= 0)
    return 0;
  result = malloc(*outSize);
  *outSize = inEx2(fin, inOffset, size, result, 0);
  return result;
}


x86 assembly (clang, -O0):
<inEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,%ecx
sub    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jg     1198 <inEx+0x58>
movq   $0x0,-0x8(%rbp)
jmp    11cd <inEx+0x8d>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
xor    %r8d,%r8d
call   1030 <inEx2@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inEx>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %rbp,%rdi
call   1040 <ftell@plt>
sub    %r12d,%eax
mov    %eax,(%r14)
jle    1197 <inEx+0x57>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1030 <inEx2@plt>
mov    %eax,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_END = global i32 0
define i8* @inEx(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%11 = load i32*, i32** %6
%12 = load i32, i32* @SEEK_END
%13 = call i32 @fseek(i32* %11, i32 0, i32 %12)
%14 = load i32*, i32** %6
%15 = call i32 @ftell(i32* %14)
%16 = load i32, i32* %7
%17 = sub nsw i32 %15, %16
%18 = load i32*, i32** %9
store i32 %17, i32* %18
%19 = load i32*, i32** %9
%20 = load i32, i32* %19
%21 = icmp sle i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %4
store i8* null, i8** %5
br label %34
23: ; preds = %4
%24 = load i32*, i32** %9
%25 = load i32, i32* %24
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %10
%27 = load i32*, i32** %6
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = load i8*, i8** %10
%31 = call i32 @inEx2(i32* %27, i32 %28, i32 %29, i8* %30, i32 0)
%32 = load i32*, i32** %9
store i32 %31, i32* %32
%33 = load i8*, i8** %10
store i8* %33, i8** %5
br label %34
34: ; preds = %23, %22
%35 = load i8*, i8** %5
ret i8* %35
}

LLVM IR (-O2):
@SEEK_END = global i32 0
define i8* @inEx(i32* %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i32* %0, i32 0, i32 %5)
%7 = tail call i32 @ftell(i32* %0)
%8 = sub nsw i32 %7, %1
store i32 %8, i32* %3
%9 = icmp slt i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %4
%11 = tail call i8* @malloc(i32 %8)
%12 = tail call i32 @inEx2(i32* %0, i32 %1, i32 %2, i8* %11, i32 0)
store i32 %12, i32* %3
br label %13
13: ; preds = %4, %10
%14 = phi i8* [ %11, %10 ], [ null, %4 ]
ret i8* %14
}