#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*/ w;
typedef scalar_t__ uint8_t;
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int *, scalar_t__ const *, int);
uint64_t load64(const uint8_t *src) {
  const union {
    long one;
    char little;
  } is_endian = {1};
  if (is_endian.little) {
    uint64_t w;
    memcpy(&w, src, sizeof(w));
    return w;
  } else {
    uint64_t w = ((uint64_t)src[0]) | ((uint64_t)src[1] << 8) |
                 ((uint64_t)src[2] << 16) | ((uint64_t)src[3] << 24) |
                 ((uint64_t)src[4] << 32) | ((uint64_t)src[5] << 40) |
                 ((uint64_t)src[6] << 48) | ((uint64_t)src[7] << 56);
    return w;
  }
}


x86 assembly (clang, -O0):
<load64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpb   $0x0,-0x18(%rbp)
je     114e <load64+0x3e>
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <load64+0xc9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x10(%rcx),%rcx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x18(%rcx),%rcx
shl    $0x18,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x20(%rcx),%rcx
mov    %ecx,%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x28(%rcx),%rcx
mov    %ecx,%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x30(%rcx),%rcx
mov    %ecx,%edx
mov    $0x30,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x38(%rcx),%rcx
mov    %ecx,%edx
mov    $0x38,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%union.anon = type { i64 }
@__const.load64.is_endian = %union.anon { i64 1 }
define i32 @load64(i64* %0) {
%2 = alloca i32
%3 = alloca i64*
%4 = alloca %union.anon
%5 = alloca i32
%6 = alloca i32
store i64* %0, i64** %3
%7 = bitcast %union.anon* %4 to i8*
%8 = bitcast %union.anon* %4 to i8*
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i64*, i64** %3
%13 = call i32 @memcpy(i32* %5, i64* %12, i32 4)
%14 = load i32, i32* %5
store i32 %14, i32* %2
br label %63
15: ; preds = %1
%16 = load i64*, i64** %3
%17 = getelementptr inbounds i64, i64* %16, i64 0
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = load i64*, i64** %3
%21 = getelementptr inbounds i64, i64* %20, i64 1
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = shl i32 %23, 8
%25 = or i32 %19, %24
%26 = load i64*, i64** %3
%27 = getelementptr inbounds i64, i64* %26, i64 2
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = shl i32 %29, 16
%31 = or i32 %25, %30
%32 = load i64*, i64** %3
%33 = getelementptr inbounds i64, i64* %32, i64 3
%34 = load i64, i64* %33
%35 = trunc i64 %34 to i32
%36 = shl i32 %35, 24
%37 = or i32 %31, %36
%38 = load i64*, i64** %3
%39 = getelementptr inbounds i64, i64* %38, i64 4
%40 = load i64, i64* %39
%41 = trunc i64 %40 to i32
%42 = shl i32 %41, 32
%43 = or i32 %37, %42
%44 = load i64*, i64** %3
%45 = getelementptr inbounds i64, i64* %44, i64 5
%46 = load i64, i64* %45
%47 = trunc i64 %46 to i32
%48 = shl i32 %47, 40
%49 = or i32 %43, %48
%50 = load i64*, i64** %3
%51 = getelementptr inbounds i64, i64* %50, i64 6
%52 = load i64, i64* %51
%53 = trunc i64 %52 to i32
%54 = shl i32 %53, 48
%55 = or i32 %49, %54
%56 = load i64*, i64** %3
%57 = getelementptr inbounds i64, i64* %56, i64 7
%58 = load i64, i64* %57
%59 = trunc i64 %58 to i32
%60 = shl i32 %59, 56
%61 = or i32 %55, %60
store i32 %61, i32* %6
%62 = load i32, i32* %6
store i32 %62, i32* %2
br label %63
63: ; preds = %15, %11
%64 = load i32, i32* %2
ret i32 %64
}

LLVM IR (-O2):
define i32 @load64(i64* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @memcpy(i32* %2, i64* %0, i32 4)
%5 = load i32, i32* %2
ret i32 %5
}