#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 uint64_t;

/* Variables and functions */
uint64_t read_u64_be(unsigned char *buf) {
  uint64_t n = 0;
  n |= (uint64_t)buf[0] << 56;
  n |= (uint64_t)buf[1] << 48;
  n |= (uint64_t)buf[2] << 40;
  n |= (uint64_t)buf[3] << 32;
  n |= buf[4] << 24;
  n |= buf[5] << 16;
  n |= buf[6] << 8;
  n |= buf[7];
  return n;
}


x86 assembly (clang, -O0):
<read_u64_be>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    $0x38,%ecx
shl    %cl,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    $0x30,%ecx
shl    %cl,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
mov    $0x28,%ecx
shl    %cl,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
mov    $0x20,%ecx
shl    %cl,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%eax
shl    $0x18,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
shl    $0x10,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x6(%rax),%eax
shl    $0x8,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x7(%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_u64_be>:
ret

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

LLVM IR (-O2):
define i32 @read_u64_be(i8* nocapture readnone %0) {
ret i32 poison
}