#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 int64_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fread(char *, size_t, size_t, int /*<<< orphan*/ *);
void src_long8_read(FILE *fd, int64_t *val) {
  int val_h;
  unsigned int val_l;
  unsigned char b[8];
  fread((char *)&b[0], (size_t)1, (size_t)8, fd);
  val_h = (((((b[0] << 8) + b[1]) << 8) + b[2]) << 8) + b[3];
  val_l = (((((b[4] << 8) + b[5]) << 8) + b[6]) << 8) + b[7];
  *val = val_h * 4294967296LL + val_l;
}


x86 assembly (clang, -O0):
<src_long8_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
movzbl -0x20(%rbp),%eax
shl    $0x8,%eax
movzbl -0x1f(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x1e(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x1d(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
movzbl -0x1c(%rbp),%eax
shl    $0x8,%eax
movzbl -0x1b(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x1a(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x19(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x20,%rax
mov    -0x18(%rbp),%ecx
add    %rcx,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<src_long8_read>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%rcx
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
mov    0xc(%rsp),%eax
bswap  %eax
mov    %eax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @src_long8_read(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [8 x i8]
store i32* %0, i32** %3
store i32* %1, i32** %4
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%9 = load i32*, i32** %3
%10 = call i32 @fread(i8* %8, i64 1, i64 8, i32* %9)
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = shl i32 %13, 8
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = add nsw i32 %14, %17
%19 = shl i32 %18, 8
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 2
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = add nsw i32 %19, %22
%24 = shl i32 %23, 8
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 3
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = add nsw i32 %24, %27
store i32 %28, i32* %5
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 4
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = shl i32 %31, 8
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 5
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = add nsw i32 %32, %35
%37 = shl i32 %36, 8
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 6
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = add nsw i32 %37, %40
%42 = shl i32 %41, 8
%43 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 7
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = add nsw i32 %42, %45
store i32 %46, i32* %6
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = mul nsw i64 %48, 4294967296
%50 = load i32, i32* %6
%51 = zext i32 %50 to i64
%52 = add nsw i64 %49, %51
%53 = trunc i64 %52 to i32
%54 = load i32*, i32** %4
store i32 %53, i32* %54
ret void
}

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