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


x86 assembly (clang, -O0):
<cpu_to_be64wu>:
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
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%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):
<cpu_to_be64wu>:
mov    %esi,%eax
mov    %esi,%ecx
movzbl %sil,%edx
sar    $0x18,%esi
mov    %esi,0x10(%rdi)
sar    $0x10,%eax
mov    %eax,0x14(%rdi)
sar    $0x8,%ecx
mov    %ecx,0x18(%rdi)
mov    %edx,0x1c(%rdi)
ret

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

LLVM IR (-O2):
define void @cpu_to_be64wu(i32* nocapture writeonly %0, i32 %1) {
%3 = ashr i32 %1, 24
%4 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %3, i32* %4
%5 = ashr i32 %1, 16
%6 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %5, i32* %6
%7 = ashr i32 %1, 8
%8 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %7, i32* %8
%9 = and i32 %1, 255
%10 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %9, i32* %10
ret void
}