#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 libcperciva_be64enc(void *pp, uint64_t x) {
  uint8_t *p = (uint8_t *)pp;
  p[7] = x & 0xff;
  p[6] = (x >> 8) & 0xff;
  p[5] = (x >> 16) & 0xff;
  p[4] = (x >> 24) & 0xff;
  p[3] = (x >> 32) & 0xff;
  p[2] = (x >> 40) & 0xff;
  p[1] = (x >> 48) & 0xff;
  p[0] = (x >> 56) & 0xff;
}


x86 assembly (clang, -O0):
<libcperciva_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),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%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),%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    $0x30,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

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

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

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