int stfloat(f, p)
float f;
register char *p;
{
  register unsigned val;
  union {
    float fval;
    int ival;
  } uval;
  uval.fval = f;
  val = uval.ival;
  p += 32 / 8;
  *--p = val & 255;
  *--p = (val >> 8) & 255;
  *--p = (val >> 16) & 255;
  *--p = (val >> 24) & 255;
  return (0);
}


x86 assembly (clang, -O0):
<stfloat>:
push   %rbp
mov    %rsp,%rbp
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x14(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x14(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x14(%rbp),%eax
shr    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,-0x1(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stfloat>:
cvtsd2ss %xmm0,%xmm0
movd   %xmm0,%eax
bswap  %eax
mov    %eax,(%rdi)
xor    %eax,%eax
ret

LLVM IR (-O0):
%union.anon = type { float }
define i32 @stfloat(double %0, i8* %1) {
%3 = alloca float
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %union.anon
%7 = fptrunc double %0 to float
store float %7, float* %3
store i8* %1, i8** %4
%8 = load float, float* %3
%9 = bitcast %union.anon* %6 to float*
store float %8, float* %9
%10 = bitcast %union.anon* %6 to i32*
%11 = load i32, i32* %10
store i32 %11, i32* %5
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 4
store i8* %13, i8** %4
%14 = load i32, i32* %5
%15 = and i32 %14, 255
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 -1
store i8* %18, i8** %4
store i8 %16, i8* %18
%19 = load i32, i32* %5
%20 = lshr i32 %19, 8
%21 = and i32 %20, 255
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %4
store i8 %22, i8* %24
%25 = load i32, i32* %5
%26 = lshr i32 %25, 16
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 -1
store i8* %30, i8** %4
store i8 %28, i8* %30
%31 = load i32, i32* %5
%32 = lshr i32 %31, 24
%33 = and i32 %32, 255
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 -1
store i8* %36, i8** %4
store i8 %34, i8* %36
ret i32 0
}

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