#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 */
char *calloc(int, int);
char *float2bin(float input) {
  char *bin = calloc(33, sizeof(char));
  bin[32] = '\0';
  int cheater = *((int *)((char *)&input));
  for (int i = 0; i < 32; i++) {
    int bit = (cheater >> (31 - i)) & 1;
    if (bit) {
      bin[i] = '1';
    } else {
      bin[i] = '0';
    }
  }
  return bin;
}


x86 assembly (clang, -O0):
<float2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,0x20(%rax)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    119c <float2bin+0x8c>
mov    -0x14(%rbp),%eax
mov    $0x1f,%ecx
sub    -0x18(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117d <float2bin+0x6d>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    1189 <float2bin+0x79>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
jmp    118e <float2bin+0x7e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <float2bin+0x35>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<float2bin>:
sub    $0x18,%rsp
movdqa %xmm0,(%rsp)
mov    $0x21,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
movaps (%rsp),%xmm5
shufps $0x0,%xmm5,%xmm5
movaps 0xec9(%rip),%xmm1
andps  %xmm5,%xmm1
movaps 0xecf(%rip),%xmm2
andps  %xmm5,%xmm2
movaps 0xed5(%rip),%xmm3
andps  %xmm5,%xmm3
movaps 0xedb(%rip),%xmm4
andps  %xmm5,%xmm4
pxor   %xmm0,%xmm0
pcmpeqd %xmm0,%xmm4
pcmpeqd %xmm0,%xmm3
packssdw %xmm4,%xmm3
pcmpeqd %xmm0,%xmm2
pcmpeqd %xmm0,%xmm1
packssdw %xmm2,%xmm1
packsswb %xmm3,%xmm1
movdqa 0xec0(%rip),%xmm2
paddb  %xmm2,%xmm1
movdqu %xmm1,(%rax)
movaps 0xec1(%rip),%xmm1
andps  %xmm5,%xmm1
movaps 0xec7(%rip),%xmm3
andps  %xmm5,%xmm3
movaps 0xecd(%rip),%xmm4
andps  %xmm5,%xmm4
andps  0xed3(%rip),%xmm5
pcmpeqd %xmm0,%xmm5
pcmpeqd %xmm0,%xmm4
packssdw %xmm5,%xmm4
pcmpeqd %xmm0,%xmm3
pcmpeqd %xmm0,%xmm1
packssdw %xmm3,%xmm1
packsswb %xmm4,%xmm1
paddb  %xmm2,%xmm1
movdqu %xmm1,0x10(%rax)
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i8* @float2bin(float %0) {
%2 = alloca float
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store float %0, float* %2
%7 = call i8* @calloc(i32 33, i32 1)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 32
store i8 0, i8* %9
%10 = bitcast float* %2 to i8*
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
store i32 %12, i32* %4
store i32 0, i32* %5
br label %13
13: ; preds = %35, %1
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 32
br i1 %15, label %16, label %38
16: ; preds = %13
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = sub nsw i32 31, %18
%20 = ashr i32 %17, %19
%21 = and i32 %20, 1
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 49, i8* %28
br label %34
29: ; preds = %16
%30 = load i8*, i8** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 48, i8* %33
br label %34
34: ; preds = %29, %24
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %13
38: ; preds = %13
%39 = load i8*, i8** %3
ret i8* %39
}

LLVM IR (-O2):
define noalias i8* @float2bin(float %0) {
%2 = tail call dereferenceable_or_null(33) i8* @calloc(i32 33, i32 1)
%3 = insertelement <16 x float> undef, float %0, i64 0
%4 = bitcast <16 x float> %3 to <16 x i32>
%5 = shufflevector <16 x i32> %4, <16 x i32> poison, <16 x i32> zeroinitializer
%6 = and <16 x i32> %5, <i32 -2147483648, i32 1073741824, i32 536870912, i32 268435456, i32 134217728, i32 67108864, i32 33554432, i32 16777216, i32 8388608, i32 4194304, i32 2097152, i32 1048576, i32 524288, i32 262144, i32 131072, i32 65536>
%7 = icmp eq <16 x i32> %6, zeroinitializer
%8 = select <16 x i1> %7, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%9 = bitcast i8* %2 to <16 x i8>*
store <16 x i8> %8, <16 x i8>* %9
%10 = and <16 x i32> %5, <i32 32768, i32 16384, i32 8192, i32 4096, i32 2048, i32 1024, i32 512, i32 256, i32 128, i32 64, i32 32, i32 16, i32 8, i32 4, i32 2, i32 1>
%11 = icmp eq <16 x i32> %10, zeroinitializer
%12 = select <16 x i1> %11, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%13 = getelementptr inbounds i8, i8* %2, i64 16
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> %12, <16 x i8>* %14
ret i8* %2
}