#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 put_uint64_le(unsigned char *ptr, uint64_t data) {
  ptr[0] = data & 0xff;
  ptr[1] = (data >> 8) & 0xff;
  ptr[2] = (data >> 16) & 0xff;
  ptr[3] = (data >> 24) & 0xff;
  ptr[4] = (data >> 32) & 0xff;
  ptr[5] = (data >> 40) & 0xff;
  ptr[6] = (data >> 48) & 0xff;
  ptr[7] = (data >> 56) & 0xff;
}


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

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

LLVM IR (-O0):
define void @put_uint64_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 = and i32 %5, 255
%7 = trunc i32 %6 to i8
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 %7, i8* %9
%10 = load i32, i32* %4
%11 = ashr i32 %10, 8
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %13, i8* %15
%16 = load i32, i32* %4
%17 = ashr i32 %16, 16
%18 = and i32 %17, 255
%19 = trunc i32 %18 to i8
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 2
store i8 %19, i8* %21
%22 = load i32, i32* %4
%23 = ashr i32 %22, 24
%24 = and i32 %23, 255
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 3
store i8 %25, i8* %27
%28 = load i32, i32* %4
%29 = ashr i32 %28, 32
%30 = and i32 %29, 255
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 4
store i8 %31, i8* %33
%34 = load i32, i32* %4
%35 = ashr i32 %34, 40
%36 = and i32 %35, 255
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 5
store i8 %37, i8* %39
%40 = load i32, i32* %4
%41 = ashr i32 %40, 48
%42 = and i32 %41, 255
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 6
store i8 %43, i8* %45
%46 = load i32, i32* %4
%47 = ashr i32 %46, 56
%48 = and i32 %47, 255
%49 = trunc i32 %48 to i8
%50 = load i8*, i8** %3
%51 = getelementptr inbounds i8, i8* %50, i64 7
store i8 %49, i8* %51
ret void
}

LLVM IR (-O2):
define void @put_uint64_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
}