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

/* Variables and functions */
void float_encode(float v, uint8_t *buffer) {
  union {
    float v;
    uint32_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);
}


x86 assembly (clang, -O0):
<float_encode>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %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)
pop    %rbp
ret

x86 assembly (clang, -O2):
<float_encode>:
movd   %xmm0,%eax
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 { float }
define void @float_encode(float %0, i64* %1) {
%3 = alloca float
%4 = alloca i64*
%5 = alloca %union.anon
store float %0, float* %3
store i64* %1, i64** %4
%6 = load float, float* %3
%7 = bitcast %union.anon* %5 to float*
store float %6, float* %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
ret void
}

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