#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 getFileSizeEx(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;
  *outSize = getFileSizeEx(fin) - inOffset;
  if (*outSize <= 0)
    return NULL;
  result = malloc(size);
  *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
call   1050 <getFileSizeEx@plt>
mov    %eax,%ecx
sub    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jg     1174 <inEx+0x44>
movq   $0x0,-0x8(%rbp)
jmp    11a6 <inEx+0x76>
mov    -0x18(%rbp),%edi
call   1040 <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,%r15
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%rbp
call   1050 <getFileSizeEx@plt>
sub    %r12d,%eax
mov    %eax,(%r15)
jle    1175 <inEx+0x45>
mov    %r14d,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1030 <inEx2@plt>
mov    %eax,(%r15)
jmp    1177 <inEx+0x47>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
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 = call i32 @getFileSizeEx(i32* %11)
%13 = load i32, i32* %7
%14 = sub nsw i32 %12, %13
%15 = load i32*, i32** %9
store i32 %14, i32* %15
%16 = load i32*, i32** %9
%17 = load i32, i32* %16
%18 = icmp sle i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %4
store i8* null, i8** %5
br label %30
20: ; preds = %4
%21 = load i32, i32* %8
%22 = call i8* @malloc(i32 %21)
store i8* %22, i8** %10
%23 = load i32*, i32** %6
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = load i8*, i8** %10
%27 = call i32 @inEx2(i32* %23, i32 %24, i32 %25, i8* %26, i32 0)
%28 = load i32*, i32** %9
store i32 %27, i32* %28
%29 = load i8*, i8** %10
store i8* %29, i8** %5
br label %30
30: ; preds = %20, %19
%31 = load i8*, i8** %5
ret i8* %31
}

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