#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 */
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned long fa_read_u32(FILE *fp) {
  unsigned long cx;
  unsigned char temp[4];
  fread(temp, sizeof(*temp), 4, fp);
  cx = (unsigned long)temp[0];
  cx |= (unsigned long)temp[1] << 8;
  cx |= (unsigned long)temp[2] << 16;
  cx |= (unsigned long)temp[3] << 24;
  return cx;
}


x86 assembly (clang, -O0):
<fa_read_u32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
movzbl -0x14(%rbp),%eax
mov    %rax,-0x10(%rbp)
movzbl -0x13(%rbp),%eax
shl    $0x8,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movzbl -0x12(%rbp),%eax
shl    $0x10,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movzbl -0x11(%rbp),%eax
shl    $0x18,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fa_read_u32>:
push   %rax
mov    %rdi,%rcx
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i64 @fa_read_u32(i32* %0) {
%2 = alloca i32*
%3 = alloca i64
%4 = alloca [4 x i8]
store i32* %0, i32** %2
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = load i32*, i32** %2
%7 = call i32 @fread(i8* %5, i32 1, i32 4, i32* %6)
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%9 = load i8, i8* %8
%10 = zext i8 %9 to i64
store i64 %10, i64* %3
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%12 = load i8, i8* %11
%13 = zext i8 %12 to i64
%14 = shl i64 %13, 8
%15 = load i64, i64* %3
%16 = or i64 %15, %14
store i64 %16, i64* %3
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%18 = load i8, i8* %17
%19 = zext i8 %18 to i64
%20 = shl i64 %19, 16
%21 = load i64, i64* %3
%22 = or i64 %21, %20
store i64 %22, i64* %3
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i64
%26 = shl i64 %25, 24
%27 = load i64, i64* %3
%28 = or i64 %27, %26
store i64 %28, i64* %3
%29 = load i64, i64* %3
ret i64 %29
}

LLVM IR (-O2):
define i64 @fa_read_u32(i32* nocapture %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = call i32 @fread(i8* %3, i32 1, i32 4, i32* %0)
%5 = load i8, i8* %3
%6 = zext i8 %5 to i64
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%8 = load i8, i8* %7
%9 = zext i8 %8 to i64
%10 = shl nuw nsw i64 %9, 8
%11 = or i64 %10, %6
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i64
%15 = shl nuw nsw i64 %14, 16
%16 = or i64 %11, %15
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i64
%20 = shl nuw nsw i64 %19, 24
%21 = or i64 %16, %20
ret i64 %21
}