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

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


x86 assembly (clang, -O0):
<ncbi_long8_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
movzbl -0x11(%rbp),%eax
shl    $0x8,%eax
movzbl -0x12(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x13(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x14(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x15(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x16(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movzbl -0x17(%rbp),%ecx
add    %ecx,%eax
shl    $0x8,%eax
movslq %eax,%rcx
movzbl -0x18(%rbp),%eax
add    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ncbi_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>
movzbl 0xb(%rsp),%eax
movzbl 0xa(%rsp),%ecx
shl    $0x10,%eax
shl    $0x8,%ecx
or     %eax,%ecx
movzbl 0x9(%rsp),%eax
or     %ecx,%eax
shl    $0x8,%eax
cltq
movzbl 0x8(%rsp),%ecx
or     %rax,%rcx
mov    %rcx,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @ncbi_long8_read(i32* nocapture %0, i64* 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 3
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
%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 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = or i32 %14, %17
%19 = shl nuw i32 %18, 8
%20 = sext i32 %19 to i64
%21 = load i8, i8* %4
%22 = zext i8 %21 to i64
%23 = or i64 %20, %22
store i64 %23, i64* %1
ret void
}