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

/* Variables and functions */
void LittleEndianWriteU64(uint64_t value, uint8_t *bytes) {
  bytes[0] = (uint8_t)value;
  bytes[1] = (uint8_t)(value >> 8);
  bytes[2] = (uint8_t)(value >> 16);
  bytes[3] = (uint8_t)(value >> 24);
  bytes[4] = (uint8_t)(value >> 32);
  bytes[5] = (uint8_t)(value >> 40);
  bytes[6] = (uint8_t)(value >> 48);
  bytes[7] = (uint8_t)(value >> 56);
}


x86 assembly (clang, -O0):
<LittleEndianWriteU64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movslq -0x4(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x4(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x4(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x4(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x38(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<LittleEndianWriteU64>:
movslq %edi,%rax
mov    %rax,(%rsi)
mov    %eax,%ecx
sar    $0x8,%ecx
movslq %ecx,%rcx
mov    %rcx,0x8(%rsi)
mov    %eax,%ecx
sar    $0x10,%ecx
movslq %ecx,%rcx
mov    %rcx,0x10(%rsi)
sar    $0x18,%eax
cltq
mov    %rax,0x18(%rsi)
ret

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

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