#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 uint8_t;
typedef int uint64_t;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int32_t ReadUint64Be(const void *in, uint64_t *value) {
  assert(in != NULL);
  assert(value != NULL);
  const uint8_t *buf = (const uint8_t *)in;
  uint64_t out = buf[0];
  out <<= 8;
  out |= buf[1];
  out <<= 8;
  out |= buf[2];
  out <<= 8;
  out |= buf[3];
  out <<= 8;
  out |= buf[4];
  out <<= 8;
  out |= buf[5];
  out <<= 8;
  out |= buf[6];
  out <<= 8;
  out |= buf[7];
  *value = out;
  return 8;
}


x86 assembly (clang, -O0):
<ReadUint64Be>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x8,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadUint64Be>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
mov    0x10(%rbx),%eax
mov    0x14(%rbx),%ecx
shl    $0x10,%eax
shl    $0x8,%ecx
or     %eax,%ecx
or     0x18(%rbx),%ecx
shl    $0x8,%ecx
or     0x1c(%rbx),%ecx
mov    %ecx,(%r14)
mov    $0x8,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @ReadUint64Be(i8* %0, i32* writeonly %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i32* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = getelementptr inbounds i8, i8* %0, i64 16
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
%12 = getelementptr inbounds i8, i8* %0, i64 20
%13 = bitcast i8* %12 to i32*
%14 = load i32, i32* %13
%15 = shl i32 %11, 16
%16 = shl i32 %14, 8
%17 = or i32 %16, %15
%18 = getelementptr inbounds i8, i8* %0, i64 24
%19 = bitcast i8* %18 to i32*
%20 = load i32, i32* %19
%21 = or i32 %17, %20
%22 = shl i32 %21, 8
%23 = getelementptr inbounds i8, i8* %0, i64 28
%24 = bitcast i8* %23 to i32*
%25 = load i32, i32* %24
%26 = or i32 %22, %25
store i32 %26, i32* %1
ret i32 8
}