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

/* Variables and functions */
void double_encode(double v, uint8_t *buffer) {
  union {
    double v;
    uint64_t e;
  } u;
  u.v = v;
  buffer[0] = (uint8_t)(u.e & 0xff);
  buffer[1] = (uint8_t)(u.e >> 8 & 0xff);
  buffer[2] = (uint8_t)(u.e >> 16 & 0xff);
  buffer[3] = (uint8_t)(u.e >> 24 & 0xff);
  buffer[4] = (uint8_t)(u.e >> 32 & 0xff);
  buffer[5] = (uint8_t)(u.e >> 40 & 0xff);
  buffer[6] = (uint8_t)(u.e >> 48 & 0xff);
  buffer[7] = (uint8_t)(u.e >> 56 & 0xff);
}


x86 assembly (clang, -O0):
<double_encode>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x18(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x18(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x18(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x18(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
and    $0xff,%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x38(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_encode>:
movq   %xmm0,%rax
movzbl %al,%ecx
mov    %rcx,(%rdi)
movzbl %ah,%ecx
mov    %rcx,0x8(%rdi)
mov    %eax,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %rcx,0x10(%rdi)
shr    $0x18,%eax
mov    %rax,0x18(%rdi)
ret

LLVM IR (-O0):
%union.anon = type { double }
define void @double_encode(double %0, i64* %1) {
%3 = alloca double
%4 = alloca i64*
%5 = alloca %union.anon
store double %0, double* %3
store i64* %1, i64** %4
%6 = load double, double* %3
%7 = bitcast %union.anon* %5 to double*
store double %6, double* %7
%8 = bitcast %union.anon* %5 to i32*
%9 = load i32, i32* %8
%10 = and i32 %9, 255
%11 = sext i32 %10 to i64
%12 = load i64*, i64** %4
%13 = getelementptr inbounds i64, i64* %12, i64 0
store i64 %11, i64* %13
%14 = bitcast %union.anon* %5 to i32*
%15 = load i32, i32* %14
%16 = ashr i32 %15, 8
%17 = and i32 %16, 255
%18 = sext i32 %17 to i64
%19 = load i64*, i64** %4
%20 = getelementptr inbounds i64, i64* %19, i64 1
store i64 %18, i64* %20
%21 = bitcast %union.anon* %5 to i32*
%22 = load i32, i32* %21
%23 = ashr i32 %22, 16
%24 = and i32 %23, 255
%25 = sext i32 %24 to i64
%26 = load i64*, i64** %4
%27 = getelementptr inbounds i64, i64* %26, i64 2
store i64 %25, i64* %27
%28 = bitcast %union.anon* %5 to i32*
%29 = load i32, i32* %28
%30 = ashr i32 %29, 24
%31 = and i32 %30, 255
%32 = sext i32 %31 to i64
%33 = load i64*, i64** %4
%34 = getelementptr inbounds i64, i64* %33, i64 3
store i64 %32, i64* %34
%35 = bitcast %union.anon* %5 to i32*
%36 = load i32, i32* %35
%37 = ashr i32 %36, 32
%38 = and i32 %37, 255
%39 = sext i32 %38 to i64
%40 = load i64*, i64** %4
%41 = getelementptr inbounds i64, i64* %40, i64 4
store i64 %39, i64* %41
%42 = bitcast %union.anon* %5 to i32*
%43 = load i32, i32* %42
%44 = ashr i32 %43, 40
%45 = and i32 %44, 255
%46 = sext i32 %45 to i64
%47 = load i64*, i64** %4
%48 = getelementptr inbounds i64, i64* %47, i64 5
store i64 %46, i64* %48
%49 = bitcast %union.anon* %5 to i32*
%50 = load i32, i32* %49
%51 = ashr i32 %50, 48
%52 = and i32 %51, 255
%53 = sext i32 %52 to i64
%54 = load i64*, i64** %4
%55 = getelementptr inbounds i64, i64* %54, i64 6
store i64 %53, i64* %55
%56 = bitcast %union.anon* %5 to i32*
%57 = load i32, i32* %56
%58 = ashr i32 %57, 56
%59 = and i32 %58, 255
%60 = sext i32 %59 to i64
%61 = load i64*, i64** %4
%62 = getelementptr inbounds i64, i64* %61, i64 7
store i64 %60, i64* %62
ret void
}

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