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

/* Variables and functions */
unsigned long fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, unsigned long, int);
unsigned long getword(FILE *in, unsigned long offset, int mode) {
  int i;
  unsigned long head = 0;
  fseek(in, offset, mode);
  for (i = 0; i < 4; i++) {
    head = head << 8;
    head |= fgetc(in);
  }
  return head;
}


x86 assembly (clang, -O0):
<getword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <fseek@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1187 <getword+0x67>
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
or     -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1152 <getword+0x32>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getword>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <fseek@plt>
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %rax,%r12
shl    $0x10,%r15
shl    $0x8,%r12
or     %r15,%r12
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %rax,%rbx
or     %r12,%rbx
shl    $0x8,%rbx
mov    %r14,%rdi
call   1030 <fgetc@plt>
or     %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @getword(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
store i64 0, i64* %8
%9 = load i32*, i32** %4
%10 = load i64, i64* %5
%11 = load i32, i32* %6
%12 = call i32 @fseek(i32* %9, i64 %10, i32 %11)
store i32 0, i32* %7
br label %13
13: ; preds = %23, %3
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i64, i64* %8
%18 = shl i64 %17, 8
store i64 %18, i64* %8
%19 = load i32*, i32** %4
%20 = call i64 @fgetc(i32* %19)
%21 = load i64, i64* %8
%22 = or i64 %21, %20
store i64 %22, i64* %8
br label %23
23: ; preds = %16
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %13
26: ; preds = %13
%27 = load i64, i64* %8
ret i64 %27
}

LLVM IR (-O2):
define i64 @getword(i32* nocapture %0, i64 %1, i32 %2) {
%4 = tail call i32 @fseek(i32* %0, i64 %1, i32 %2)
%5 = tail call i64 @fgetc(i32* %0)
%6 = tail call i64 @fgetc(i32* %0)
%7 = shl i64 %5, 16
%8 = shl i64 %6, 8
%9 = or i64 %7, %8
%10 = tail call i64 @fgetc(i32* %0)
%11 = or i64 %10, %9
%12 = shl i64 %11, 8
%13 = tail call i64 @fgetc(i32* %0)
%14 = or i64 %13, %12
ret i64 %14
}