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

/* Variables and functions */
void be64enc(void *buf, uint64_t x) {
  uint8_t *b = (uint8_t *)buf;
  b[0] = (x >> 56) & 0xff;
  b[1] = (x >> 48) & 0xff;
  b[2] = (x >> 40) & 0xff;
  b[3] = (x >> 32) & 0xff;
  b[4] = (x >> 24) & 0xff;
  b[5] = (x >> 16) & 0xff;
  b[6] = (x >> 8) & 0xff;
  b[7] = x & 0xff;
}


x86 assembly (clang, -O0):
<be64enc>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x1c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<be64enc>:
mov    %esi,%eax
mov    %esi,%ecx
movzbl %ah,%edx
movzbl %al,%esi
shr    $0x18,%eax
mov    %eax,0x10(%rdi)
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %eax,0x14(%rdi)
mov    %edx,0x18(%rdi)
mov    %esi,0x1c(%rdi)
ret

LLVM IR (-O0):
define void @be64enc(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to i32*
store i32* %7, i32** %5
%8 = load i32, i32* %4
%9 = ashr i32 %8, 56
%10 = and i32 %9, 255
%11 = load i32*, i32** %5
%12 = getelementptr inbounds i32, i32* %11, i64 0
store i32 %10, i32* %12
%13 = load i32, i32* %4
%14 = ashr i32 %13, 48
%15 = and i32 %14, 255
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 %15, i32* %17
%18 = load i32, i32* %4
%19 = ashr i32 %18, 40
%20 = and i32 %19, 255
%21 = load i32*, i32** %5
%22 = getelementptr inbounds i32, i32* %21, i64 2
store i32 %20, i32* %22
%23 = load i32, i32* %4
%24 = ashr i32 %23, 32
%25 = and i32 %24, 255
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 3
store i32 %25, i32* %27
%28 = load i32, i32* %4
%29 = ashr i32 %28, 24
%30 = and i32 %29, 255
%31 = load i32*, i32** %5
%32 = getelementptr inbounds i32, i32* %31, i64 4
store i32 %30, i32* %32
%33 = load i32, i32* %4
%34 = ashr i32 %33, 16
%35 = and i32 %34, 255
%36 = load i32*, i32** %5
%37 = getelementptr inbounds i32, i32* %36, i64 5
store i32 %35, i32* %37
%38 = load i32, i32* %4
%39 = ashr i32 %38, 8
%40 = and i32 %39, 255
%41 = load i32*, i32** %5
%42 = getelementptr inbounds i32, i32* %41, i64 6
store i32 %40, i32* %42
%43 = load i32, i32* %4
%44 = and i32 %43, 255
%45 = load i32*, i32** %5
%46 = getelementptr inbounds i32, i32* %45, i64 7
store i32 %44, i32* %46
ret void
}

LLVM IR (-O2):
define void @be64enc(i8* nocapture writeonly %0, i32 %1) {
%3 = lshr i32 %1, 24
%4 = getelementptr inbounds i8, i8* %0, i64 16
%5 = bitcast i8* %4 to i32*
store i32 %3, i32* %5
%6 = lshr i32 %1, 16
%7 = and i32 %6, 255
%8 = getelementptr inbounds i8, i8* %0, i64 20
%9 = bitcast i8* %8 to i32*
store i32 %7, i32* %9
%10 = lshr i32 %1, 8
%11 = and i32 %10, 255
%12 = getelementptr inbounds i8, i8* %0, i64 24
%13 = bitcast i8* %12 to i32*
store i32 %11, i32* %13
%14 = and i32 %1, 255
%15 = getelementptr inbounds i8, i8* %0, i64 28
%16 = bitcast i8* %15 to i32*
store i32 %14, i32* %16
ret void
}