#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*/ uint16_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*/ read16(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
uint16_t get16(FILE *infile) {
  uint8_t buf[2];
  if (2 != fread(buf, 1, 2, infile)) {
    fprintf(stderr, "read error at 0x%lx\n", (unsigned long)ftell(infile));
    exit(EXIT_FAILURE);
  }
  return read16(buf);
}


x86 assembly (clang, -O0):
<get16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
je     11b7 <get16+0x67>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <ftell@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x10(%rbp),%rdi
call   1040 <read16@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get16>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x2,%eax
jne    117f <get16+0x2f>
mov    %rsp,%rdi
call   1040 <read16@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e5a(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1060 <ftell@plt>
lea    0xe69(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1070 <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 @get16(i32* %0) {
%2 = alloca i32*
%3 = alloca [2 x i32]
store i32* %0, i32** %2
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%5 = load i32*, i32** %2
%6 = call i32 @fread(i32* %4, i32 1, i32 2, i32* %5)
%7 = icmp ne i32 2, %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 [2 x i32], [2 x i32]* %3, i64 0, i64 0
%17 = call i32 @read16(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 @get16(i32* nocapture %0) {
%2 = alloca [2 x i32]
%3 = bitcast [2 x i32]* %2 to i8*
%4 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%5 = call i32 @fread(i32* %4, i32 1, i32 2, i32* %0)
%6 = icmp eq i32 %5, 2
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 = call i32 @read16(i32* %4)
ret i32 %14
}