#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 *, unsigned char, long,
                           unsigned char);
int fsReadChar(unsigned char *, long, long *, unsigned char *);
int /*<<< orphan*/ stderr;
int fsExpectChar(unsigned char *buffer, long fileSize, long *contentOffset,
                 unsigned char c) {
  int r = 0;
  unsigned char _buffer;
  if ((r = fsReadChar(buffer, fileSize, contentOffset, &_buffer)) != 0) {
    return r;
  }
  if (_buffer != c) {
    fprintf(stderr,
            "Error: Couldn't read '%c' at offset %ld, got '%c' instead.\n", c,
            *contentOffset, _buffer);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<fsExpectChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %al,-0x21(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x29(%rbp),%rcx
call   1030 <fsReadChar@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
je     116c <fsExpectChar+0x4c>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b6 <fsExpectChar+0x96>
movzbl -0x29(%rbp),%eax
movzbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
je     11af <fsExpectChar+0x8f>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
lea    0xe6a(%rip),%rsi
movzbl %al,%edx
movzbl -0x29(%rbp),%r8d
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b6 <fsExpectChar+0x96>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsExpectChar>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%rbx
lea    0x7(%rsp),%rcx
call   1030 <fsReadChar@plt>
test   %eax,%eax
jne    1167 <fsExpectChar+0x47>
mov    0x7(%rsp),%sil
xor    %eax,%eax
cmp    %bpl,%sil
je     1167 <fsExpectChar+0x47>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rcx
movzbl %bpl,%edx
movzbl %sil,%r8d
lea    0xea3(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [60 x i8] c"Error: Couldn't read '%c' at offset %ld, got '%c' instead.\0A\00"
define i32 @fsExpectChar(i8* %0, i64 %1, i64* %2, i8 zeroext %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i8
%10 = alloca i32
%11 = alloca i8
store i8* %0, i8** %6
store i64 %1, i64* %7
store i64* %2, i64** %8
store i8 %3, i8* %9
store i32 0, i32* %10
%12 = load i8*, i8** %6
%13 = load i64, i64* %7
%14 = load i64*, i64** %8
%15 = call i32 @fsReadChar(i8* %12, i64 %13, i64* %14, i8* %11)
store i32 %15, i32* %10
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = load i32, i32* %10
store i32 %18, i32* %5
br label %33
19: ; preds = %4
%20 = load i8, i8* %11
%21 = zext i8 %20 to i32
%22 = load i8, i8* %9
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %21, %23
br i1 %24, label %25, label %32
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i8, i8* %9
%28 = load i64*, i64** %8
%29 = load i64, i64* %28
%30 = load i8, i8* %11
%31 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8 zeroext %27, i64 %29, i8 zeroext %30)
store i32 -1, i32* %5
br label %33
32: ; preds = %19
store i32 0, i32* %5
br label %33
33: ; preds = %32, %25, %17
%34 = load i32, i32* %5
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [60 x i8] c"Error: Couldn't read '%c' at offset %ld, got '%c' instead.\0A\00"
define i32 @fsExpectChar(i8* %0, i64 %1, i64* %2, i8 zeroext %3) {
%5 = alloca i8
%6 = call i32 @fsReadChar(i8* %0, i64 %1, i64* %2, i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = load i8, i8* %5
%10 = icmp eq i8 %9, %3
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = load i64, i64* %2
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8 zeroext %3, i64 %13, i8 zeroext %9)
br label %15
15: ; preds = %8, %4, %11
%16 = phi i32 [ -1, %11 ], [ %6, %4 ], [ 0, %8 ]
ret i32 %16
}