#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 */

/* Variables and functions */
int /*<<< orphan*/ size_buffer(char **, size_t *, size_t);
size_t float32Pack(const float *data, char **buffer, size_t *size,
                   size_t *pos) {
  union {
    float f;
    char c[4];
  } u;
  u.f = *data;
  size_buffer(buffer, size, *pos + sizeof(float));
  (*buffer)[(*pos)++] = u.c[3];
  (*buffer)[(*pos)++] = u.c[2];
  (*buffer)[(*pos)++] = u.c[1];
  (*buffer)[(*pos)++] = u.c[0];
  return sizeof(float);
}


x86 assembly (clang, -O0):
<float32Pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
add    $0x4,%rdx
call   1030 <size_buffer@plt>
mov    -0x25(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rsi
mov    (%rsi),%rcx
mov    %rcx,%rdi
add    $0x1,%rdi
mov    %rdi,(%rsi)
mov    %dl,(%rax,%rcx,1)
mov    -0x26(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rsi
mov    (%rsi),%rcx
mov    %rcx,%rdi
add    $0x1,%rdi
mov    %rdi,(%rsi)
mov    %dl,(%rax,%rcx,1)
mov    -0x27(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rsi
mov    (%rsi),%rcx
mov    %rcx,%rdi
add    $0x1,%rdi
mov    %rdi,(%rsi)
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rsi
mov    (%rsi),%rcx
mov    %rcx,%rdi
add    $0x1,%rdi
mov    %rdi,(%rsi)
mov    %dl,(%rax,%rcx,1)
mov    $0x4,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<float32Pack>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%rbx
mov    %rsi,%r14
mov    (%rdi),%ebp
mov    (%rcx),%rax
add    $0x4,%rax
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rax,%rdx
call   1030 <size_buffer@plt>
mov    %ebp,%eax
shr    $0x18,%eax
mov    (%r14),%rcx
mov    (%rbx),%rdx
lea    0x1(%rdx),%rsi
mov    %rsi,(%rbx)
mov    %al,(%rcx,%rdx,1)
mov    %ebp,%eax
shr    $0x10,%eax
mov    (%r14),%rcx
mov    (%rbx),%rdx
lea    0x1(%rdx),%rsi
mov    %rsi,(%rbx)
mov    %al,(%rcx,%rdx,1)
mov    (%r14),%rsi
mov    (%rbx),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%rbx)
mov    %ebp,%eax
mov    %ah,(%rsi,%rcx,1)
mov    (%r14),%rsi
mov    (%rbx),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%rbx)
mov    %al,(%rsi,%rcx,1)
mov    $0x4,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%union.anon = type { float }
define i64 @float32Pack(float* %0, i8** %1, i64* %2, i64* %3) {
%5 = alloca float*
%6 = alloca i8**
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca %union.anon
store float* %0, float** %5
store i8** %1, i8*** %6
store i64* %2, i64** %7
store i64* %3, i64** %8
%10 = load float*, float** %5
%11 = load float, float* %10
%12 = bitcast %union.anon* %9 to float*
store float %11, float* %12
%13 = load i8**, i8*** %6
%14 = load i64*, i64** %7
%15 = load i64*, i64** %8
%16 = load i64, i64* %15
%17 = add i64 %16, 4
%18 = call i32 @size_buffer(i8** %13, i64* %14, i64 %17)
%19 = bitcast %union.anon* %9 to [4 x i8]*
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 3
%21 = load i8, i8* %20
%22 = load i8**, i8*** %6
%23 = load i8*, i8** %22
%24 = load i64*, i64** %8
%25 = load i64, i64* %24
%26 = add i64 %25, 1
store i64 %26, i64* %24
%27 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %21, i8* %27
%28 = bitcast %union.anon* %9 to [4 x i8]*
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %28, i64 0, i64 2
%30 = load i8, i8* %29
%31 = load i8**, i8*** %6
%32 = load i8*, i8** %31
%33 = load i64*, i64** %8
%34 = load i64, i64* %33
%35 = add i64 %34, 1
store i64 %35, i64* %33
%36 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %30, i8* %36
%37 = bitcast %union.anon* %9 to [4 x i8]*
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %37, i64 0, i64 1
%39 = load i8, i8* %38
%40 = load i8**, i8*** %6
%41 = load i8*, i8** %40
%42 = load i64*, i64** %8
%43 = load i64, i64* %42
%44 = add i64 %43, 1
store i64 %44, i64* %42
%45 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %39, i8* %45
%46 = bitcast %union.anon* %9 to [4 x i8]*
%47 = getelementptr inbounds [4 x i8], [4 x i8]* %46, i64 0, i64 0
%48 = load i8, i8* %47
%49 = load i8**, i8*** %6
%50 = load i8*, i8** %49
%51 = load i64*, i64** %8
%52 = load i64, i64* %51
%53 = add i64 %52, 1
store i64 %53, i64* %51
%54 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 %48, i8* %54
ret i64 4
}

LLVM IR (-O2):
define i64 @float32Pack(float* nocapture %0, i8** %1, i64* %2, i64* nocapture %3) {
%5 = bitcast float* %0 to i32*
%6 = load i32, i32* %5
%7 = load i64, i64* %3
%8 = add i64 %7, 4
%9 = tail call i32 @size_buffer(i8** %1, i64* %2, i64 %8)
%10 = lshr i32 %6, 24
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %1
%13 = load i64, i64* %3
%14 = add i64 %13, 1
store i64 %14, i64* %3
%15 = getelementptr inbounds i8, i8* %12, i64 %13
store i8 %11, i8* %15
%16 = lshr i32 %6, 16
%17 = trunc i32 %16 to i8
%18 = load i8*, i8** %1
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
%21 = getelementptr inbounds i8, i8* %18, i64 %19
store i8 %17, i8* %21
%22 = lshr i32 %6, 8
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %1
%25 = load i64, i64* %3
%26 = add i64 %25, 1
store i64 %26, i64* %3
%27 = getelementptr inbounds i8, i8* %24, i64 %25
store i8 %23, i8* %27
%28 = trunc i32 %6 to i8
%29 = load i8*, i8** %1
%30 = load i64, i64* %3
%31 = add i64 %30, 1
store i64 %31, i64* %3
%32 = getelementptr inbounds i8, i8* %29, i64 %30
store i8 %28, i8* %32
ret i64 4
}