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


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

x86 assembly (clang, -O2):
<get32>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x4,%eax
jne    1182 <get32+0x32>
mov    %rsp,%rdi
call   1060 <read32@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e57(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1050 <ftell@plt>
lea    0xe66(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    0x2e2d(%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 @get32(i32* %0) {
%2 = alloca i32*
%3 = alloca [4 x i32]
store i32* %0, i32** %2
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%5 = load i32*, i32** %2
%6 = call i32 @fread(i32* %4, i32 1, i32 4, i32* %5)
%7 = icmp ne i32 4, %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 [4 x i32], [4 x i32]* %3, i64 0, i64 0
%17 = call i32 @read32(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 @get32(i32* nocapture %0) {
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%5 = call i32 @fread(i32* %4, i32 1, i32 4, i32* %0)
%6 = icmp eq i32 %5, 4
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 @read32(i32* %4)
ret i32 %14
}