#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 write64_le(uint64_t v, uint8_t buf[8]) {
  *buf++ = v & 0xff;
  *buf++ = (v >> 8) & 0xff;
  *buf++ = (v >> 16) & 0xff;
  *buf++ = (v >> 24) & 0xff;
  *buf++ = (v >> 32) & 0xff;
  *buf++ = (v >> 40) & 0xff;
  *buf++ = (v >> 48) & 0xff;
  *buf = (v >> 56) & 0xff;
}


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

x86 assembly (clang, -O2):
<write64_le>:
mov    %edi,%eax
movzbl %al,%ecx
mov    %ecx,(%rsi)
movzbl %ah,%ecx
mov    %ecx,0x4(%rsi)
mov    %edi,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %ecx,0x8(%rsi)
shr    $0x18,%eax
mov    %eax,0xc(%rsi)
ret

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

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