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

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


x86 assembly (clang, -O0):
<h_u64_to_le>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x38(%rax)
mov    -0xc(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0xc(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0xc(%rbp),%eax
sar    $0x18,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0xc(%rbp),%eax
sar    $0x0,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<h_u64_to_le>:
mov    %esi,%eax
sar    $0x18,%eax
cltq
mov    %rax,0x18(%rdi)
mov    %esi,%eax
sar    $0x10,%eax
cltq
mov    %rax,0x10(%rdi)
movslq %esi,%rax
sar    $0x8,%esi
movslq %esi,%rcx
mov    %rcx,0x8(%rdi)
mov    %rax,(%rdi)
ret

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

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