#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 */
void u64_to_le(unsigned char *x, const uint64_t u) {
  x[0] = (unsigned char)u;
  x[1] = (unsigned char)(u >> 8);
  x[2] = (unsigned char)(u >> 16);
  x[3] = (unsigned char)(u >> 24);
  x[4] = (unsigned char)(u >> 32);
  x[5] = (unsigned char)(u >> 40);
  x[6] = (unsigned char)(u >> 48);
  x[7] = (unsigned char)(u >> 56);
}


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

x86 assembly (clang, -O2):
<u64_to_le>:
mov    %esi,(%rdi)
ret

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

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