int write_float32(char **p_base, char *p_end, float f) {
  if (p_end < (*p_base + sizeof(float))) {
    msg2(180,
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/JammyStuff/vermont/refs/heads/master/src/"
         "common/ipfixlolib/encoding.c",
         __PRETTY_FUNCTION__, __func__, 2,
         "error in write_float32: buffer too small!");
    return -1;
  }
  char *p_float = (char *)&f;
  char *p_pos = *p_base;
  *(p_pos + 3) = *p_float;
  *(p_pos + 2) = *(p_float + 1);
  *(p_pos + 1) = *(p_float + 2);
  *p_pos = *(p_float + 3);
  return 0;
}


x86 assembly (clang, -O0):
<write_float32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
jae    1177 <write_float32+0x67>
mov    $0xb4,%edi
lea    0xeb7(%rip),%rsi
lea    0xf50(%rip),%rdx
lea    0xf73(%rip),%rcx
mov    $0x2,%r8d
lea    0xf74(%rip),%r9
mov    $0x0,%al
call   1030 <msg2@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c7 <write_float32+0xb7>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x28(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x28(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_float32>:
push   %rax
mov    (%rdi),%rax
lea    0x4(%rax),%rcx
cmp    %rsi,%rcx
jbe    1152 <write_float32+0x42>
lea    0xedc(%rip),%rsi
lea    0xf75(%rip),%rdx
lea    0xf98(%rip),%rcx
lea    0xf9f(%rip),%r9
mov    $0xb4,%edi
mov    $0x2,%r8d
xor    %eax,%eax
call   1030 <msg2@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
movd   %xmm0,%ecx
bswap  %ecx
mov    %ecx,(%rax)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [160 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JammyStuff/vermont/refs/heads/master/src/common/ipfixlolib/encoding.c\00"
@__PRETTY_FUNCTION__.write_float32 = [42 x i8] c"int write_float32(char **, char *, float)\00"
@__func__.write_float32 = [14 x i8] c"write_float32\00"
@.str.1 = [42 x i8] c"error in write_float32: buffer too small!\00"
define i32 @write_float32(i8** %0, i8* %1, float %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca float
%8 = alloca i8*
%9 = alloca i8*
store i8** %0, i8*** %5
store i8* %1, i8** %6
store float %2, float* %7
%10 = load i8*, i8** %6
%11 = load i8**, i8*** %5
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 4
%14 = icmp ult i8* %10, %13
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @msg2 to i32 (i32, i8*, i8*, i8*, i32, i8*, ...)*)(i32 180, i8* getelementptr inbounds ([160 x i8], [160 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @__PRETTY_FUNCTION__.write_float32, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @__func__.write_float32, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %39
17: ; preds = %3
%18 = bitcast float* %7 to i8*
store i8* %18, i8** %8
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
store i8* %20, i8** %9
%21 = load i8*, i8** %8
%22 = load i8, i8* %21
%23 = load i8*, i8** %9
%24 = getelementptr inbounds i8, i8* %23, i64 3
store i8 %22, i8* %24
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = load i8*, i8** %9
%29 = getelementptr inbounds i8, i8* %28, i64 2
store i8 %27, i8* %29
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i64 1
store i8 %32, i8* %34
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i64 3
%37 = load i8, i8* %36
%38 = load i8*, i8** %9
store i8 %37, i8* %38
store i32 0, i32* %4
br label %39
39: ; preds = %17, %15
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
@.str = [160 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JammyStuff/vermont/refs/heads/master/src/common/ipfixlolib/encoding.c\00"
@__PRETTY_FUNCTION__.write_float32 = [42 x i8] c"int write_float32(char **, char *, float)\00"
@__func__.write_float32 = [14 x i8] c"write_float32\00"
@.str.1 = [42 x i8] c"error in write_float32: buffer too small!\00"
define i32 @write_float32(i8** nocapture %0, i8* readnone %1, float %2) {
%4 = load i8*, i8** %0
%5 = getelementptr inbounds i8, i8* %4, i64 4
%6 = icmp ugt i8* %5, %1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @msg2 to i32 (i32, i8*, i8*, i8*, i32, i8*, ...)*)(i32 180, i8* getelementptr inbounds ([160 x i8], [160 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @__PRETTY_FUNCTION__.write_float32, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @__func__.write_float32, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
br label %21
9: ; preds = %3
%10 = bitcast float %2 to i32
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %4, i64 3
store i8 %11, i8* %12
%13 = lshr i32 %10, 8
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %4, i64 2
store i8 %14, i8* %15
%16 = lshr i32 %10, 16
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds i8, i8* %4, i64 1
store i8 %17, i8* %18
%19 = lshr i32 %10, 24
%20 = trunc i32 %19 to i8
store i8 %20, i8* %4
br label %21
21: ; preds = %9, %7
%22 = phi i32 [ -1, %7 ], [ 0, %9 ]
ret i32 %22
}