#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*/ uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned long);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
scalar_t__ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
uint8_t get8(FILE *infile) {
  uint8_t buf[1];
  if (1 != fread(buf, 1, 1, infile)) {
    fprintf(stderr, "read error at 0x%lx\n", (unsigned long)ftell(infile));
    exit(EXIT_FAILURE);
  }
  return buf[0];
}


x86 assembly (clang, -O0):
<get8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     11a4 <get8+0x64>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe6f(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get8>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    116d <get8+0x2d>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e6c(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1050 <ftell@plt>
lea    0xe7b(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"read error at 0x%lx\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @get8(i32* %0) {
%2 = alloca i32*
%3 = alloca [1 x i32]
store i32* %0, i32** %2
%4 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%5 = load i32*, i32** %2
%6 = call i32 @fread(i32* %4, i32 1, i32 1, i32* %5)
%7 = icmp ne i32 1, %6
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i32*, i32** %2
%11 = call i64 @ftell(i32* %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %1
%16 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%17 = load i32, i32* %16
ret i32 %17
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"read error at 0x%lx\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @get8(i32* nocapture %0) {
%2 = alloca [1 x i32]
%3 = bitcast [1 x i32]* %2 to i8*
%4 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%5 = call i32 @fread(i32* %4, i32 1, i32 1, i32* %0)
%6 = icmp eq i32 %5, 1
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i64 @ftell(i32* %0)
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
%14 = load i32, i32* %4
ret i32 %14
}