#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_SET;
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int inEx2(FILE *fin, int inOffset, int size, unsigned char *dest,
          int outOffset) {
  unsigned char *d;
  int remain, l;
  fseek(fin, inOffset, SEEK_SET);
  d = dest + outOffset;
  remain = size;
  while (remain > 0) {
    l = fread(d, 1, size, fin);
    d += l;
    remain -= l;
  }
  return size - remain;
}


x86 assembly (clang, -O0):
<inEx2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    11a7 <inEx2+0x87>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
jmp    1164 <inEx2+0x44>
mov    -0x10(%rbp),%eax
sub    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inEx2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r15d
mov    %rcx,%rbx
mov    %edx,%r12d
mov    %rdi,%r14
mov    0x2ea5(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    %r12d,%ebp
test   %r12d,%r12d
jle    117c <inEx2+0x5c>
movslq %r15d,%rax
add    %rax,%rbx
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
cltq
add    %rax,%rbx
sub    %eax,%ebp
jg     1160 <inEx2+0x40>
sub    %ebp,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @inEx2(i32* %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%14 = load i32*, i32** %6
%15 = load i32, i32* %7
%16 = load i32, i32* @SEEK_SET
%17 = call i32 @fseek(i32* %14, i32 %15, i32 %16)
%18 = load i8*, i8** %9
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8* %21, i8** %11
%22 = load i32, i32* %8
store i32 %22, i32* %12
br label %23
23: ; preds = %26, %5
%24 = load i32, i32* %12
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load i8*, i8** %11
%28 = load i32, i32* %8
%29 = load i32*, i32** %6
%30 = call i32 @fread(i8* %27, i32 1, i32 %28, i32* %29)
store i32 %30, i32* %13
%31 = load i32, i32* %13
%32 = load i8*, i8** %11
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8, i8* %32, i64 %33
store i8* %34, i8** %11
%35 = load i32, i32* %13
%36 = load i32, i32* %12
%37 = sub nsw i32 %36, %35
store i32 %37, i32* %12
br label %23
38: ; preds = %23
%39 = load i32, i32* %8
%40 = load i32, i32* %12
%41 = sub nsw i32 %39, %40
ret i32 %41
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @inEx2(i32* nocapture %0, i32 %1, i32 %2, i8* nocapture %3, i32 %4) {
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %0, i32 %1, i32 %6)
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = sext i32 %4 to i64
%11 = getelementptr inbounds i8, i8* %3, i64 %10
br label %12
12: ; preds = %9, %12
%13 = phi i8* [ %17, %12 ], [ %11, %9 ]
%14 = phi i32 [ %18, %12 ], [ %2, %9 ]
%15 = tail call i32 @fread(i8* %13, i32 1, i32 %2, i32* %0)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = sub nsw i32 %14, %15
%19 = icmp sgt i32 %18, 0
br i1 %19, label %12, label %20
20: ; preds = %12, %5
%21 = phi i32 [ %2, %5 ], [ %18, %12 ]
%22 = sub nsw i32 %2, %21
ret i32 %22
}