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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long, long);
int /*<<< orphan*/ stderr;
int fsReadChar(unsigned char *buffer, long fileSize, long *contentOffset,
               unsigned char *c) {
  if (*contentOffset >= fileSize) {
    fprintf(stderr, "Error: Out of bounds (offset(%ld) >= fileSize(%ld)).\n",
            *contentOffset, fileSize);
    return -1;
  }
  *c = buffer[*contentOffset];
  *contentOffset += 1;
  return 0;
}


x86 assembly (clang, -O0):
<fsReadChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jl     1165 <fsReadChar+0x55>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rcx
lea    0xeac(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118e <fsReadChar+0x7e>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsReadChar>:
push   %rax
mov    %rdx,%rax
mov    (%rdx),%rdx
cmp    %rsi,%rdx
jge    1129 <fsReadChar+0x19>
mov    (%rdi,%rdx,1),%dl
mov    %dl,(%rcx)
addq   $0x1,(%rax)
xor    %eax,%eax
pop    %rcx
ret
mov    %rsi,%r8
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
mov    %r8,%rcx
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [54 x i8] c"Error: Out of bounds (offset(%ld) >= fileSize(%ld)).\0A\00"
define i32 @fsReadChar(i8* %0, i64 %1, i64* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i8*
store i8* %0, i8** %6
store i64 %1, i64* %7
store i64* %2, i64** %8
store i8* %3, i8** %9
%10 = load i64*, i64** %8
%11 = load i64, i64* %10
%12 = load i64, i64* %7
%13 = icmp sge i64 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %4
%15 = load i32, i32* @stderr
%16 = load i64*, i64** %8
%17 = load i64, i64* %16
%18 = load i64, i64* %7
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i64 %17, i64 %18)
store i32 -1, i32* %5
br label %30
20: ; preds = %4
%21 = load i8*, i8** %6
%22 = load i64*, i64** %8
%23 = load i64, i64* %22
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = load i8*, i8** %9
store i8 %25, i8* %26
%27 = load i64*, i64** %8
%28 = load i64, i64* %27
%29 = add nsw i64 %28, 1
store i64 %29, i64* %27
store i32 0, i32* %5
br label %30
30: ; preds = %20, %14
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [54 x i8] c"Error: Out of bounds (offset(%ld) >= fileSize(%ld)).\0A\00"
define i32 @fsReadChar(i8* nocapture %0, i64 %1, i64* nocapture %2, i8* nocapture writeonly %3) {
%5 = load i64, i64* %2
%6 = icmp slt i64 %5, %1
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i64 %5, i64 %1)
br label %15
10: ; preds = %4
%11 = getelementptr inbounds i8, i8* %0, i64 %5
%12 = load i8, i8* %11
store i8 %12, i8* %3
%13 = load i64, i64* %2
%14 = add nsw i64 %13, 1
store i64 %14, i64* %2
br label %15
15: ; preds = %10, %7
%16 = phi i32 [ -1, %7 ], [ 0, %10 ]
ret i32 %16
}