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


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

x86 assembly (clang, -O2):
<badvpn_write_le64>:
mov    %edi,%eax
sar    $0x18,%eax
mov    %eax,0xc(%rsi)
mov    %edi,%eax
sar    $0x10,%eax
mov    %eax,0x8(%rsi)
mov    %edi,%eax
sar    $0x8,%eax
mov    %eax,0x4(%rsi)
mov    %edi,(%rsi)
ret

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

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