#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 fread(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned long fa_read_ulong(FILE *fp) {
  unsigned long cx;
  unsigned char temp[4];
  int ret;
  ret = fread(temp, sizeof(*temp), 4, fp);
  cx = 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_ulong>:
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>
mov    %eax,-0x18(%rbp)
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_ulong>:
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_ulong(i32* %0) {
%2 = alloca i32*
%3 = alloca i64
%4 = alloca [4 x i8]
%5 = alloca i32
store i32* %0, i32** %2
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = load i32*, i32** %2
%8 = call i32 @fread(i8* %6, i32 1, i32 4, i32* %7)
store i32 %8, i32* %5
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%10 = load i8, i8* %9
%11 = zext i8 %10 to i64
store i64 %11, i64* %3
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i64
%15 = shl i64 %14, 8
%16 = load i64, i64* %3
%17 = or i64 %16, %15
store i64 %17, i64* %3
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%19 = load i8, i8* %18
%20 = zext i8 %19 to i64
%21 = shl i64 %20, 16
%22 = load i64, i64* %3
%23 = or i64 %22, %21
store i64 %23, i64* %3
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%25 = load i8, i8* %24
%26 = zext i8 %25 to i64
%27 = shl i64 %26, 24
%28 = load i64, i64* %3
%29 = or i64 %28, %27
store i64 %29, i64* %3
%30 = load i64, i64* %3
ret i64 %30
}

LLVM IR (-O2):
define i64 @fa_read_ulong(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
}