#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 int uint8_t;
typedef int uint32_t;

/* Variables and functions */
int readInBit();
float readFloat(void) {
  uint32_t dataRead;
  for (int i = 0; i < 32; i++) {
    dataRead <<= 1;
    uint8_t newBit = readInBit();
    dataRead |= newBit;
  }
  return *((float *)(&dataRead));
}


x86 assembly (clang, -O0):
<readFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    1153 <readFloat+0x43>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <readInBit@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    111f <readFloat+0xf>
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFloat>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
shl    $0x2,%ebx
add    %eax,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebx
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebp
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebx
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebp
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebx
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebp
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebx
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebp
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebx
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebp
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebx
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebp
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebx
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebp
or     %r14d,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%r14d
shl    $0x2,%ebp
add    %eax,%r14d
xor    %eax,%eax
call   1030 <readInBit@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
add    %ebx,%ebx
xor    %eax,%eax
call   1030 <readInBit@plt>
or     %ebx,%eax
movd   %eax,%xmm0
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define float @readFloat() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
br label %4
4: ; preds = %14, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 32
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = load i32, i32* %1
%9 = shl i32 %8, 1
store i32 %9, i32* %1
%10 = call i32 (...) @readInBit()
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = load i32, i32* %1
%13 = or i32 %12, %11
store i32 %13, i32* %1
br label %14
14: ; preds = %7
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %4
17: ; preds = %4
%18 = bitcast i32* %1 to float*
%19 = load float, float* %18
ret float %19
}

LLVM IR (-O2):
define float @readFloat() {
%1 = tail call i32 (...) @readInBit()
%2 = tail call i32 (...) @readInBit()
%3 = shl i32 %1, 2
%4 = shl i32 %2, 1
%5 = or i32 %3, %4
%6 = tail call i32 (...) @readInBit()
%7 = or i32 %6, %5
%8 = tail call i32 (...) @readInBit()
%9 = shl i32 %7, 2
%10 = shl i32 %8, 1
%11 = or i32 %9, %10
%12 = tail call i32 (...) @readInBit()
%13 = or i32 %12, %11
%14 = tail call i32 (...) @readInBit()
%15 = shl i32 %13, 2
%16 = shl i32 %14, 1
%17 = or i32 %15, %16
%18 = tail call i32 (...) @readInBit()
%19 = or i32 %18, %17
%20 = tail call i32 (...) @readInBit()
%21 = shl i32 %19, 2
%22 = shl i32 %20, 1
%23 = or i32 %21, %22
%24 = tail call i32 (...) @readInBit()
%25 = or i32 %24, %23
%26 = tail call i32 (...) @readInBit()
%27 = shl i32 %25, 2
%28 = shl i32 %26, 1
%29 = or i32 %27, %28
%30 = tail call i32 (...) @readInBit()
%31 = or i32 %30, %29
%32 = tail call i32 (...) @readInBit()
%33 = shl i32 %31, 2
%34 = shl i32 %32, 1
%35 = or i32 %33, %34
%36 = tail call i32 (...) @readInBit()
%37 = or i32 %36, %35
%38 = tail call i32 (...) @readInBit()
%39 = shl i32 %37, 2
%40 = shl i32 %38, 1
%41 = or i32 %39, %40
%42 = tail call i32 (...) @readInBit()
%43 = or i32 %42, %41
%44 = tail call i32 (...) @readInBit()
%45 = shl i32 %43, 2
%46 = shl i32 %44, 1
%47 = or i32 %45, %46
%48 = tail call i32 (...) @readInBit()
%49 = or i32 %48, %47
%50 = tail call i32 (...) @readInBit()
%51 = shl i32 %49, 2
%52 = shl i32 %50, 1
%53 = or i32 %51, %52
%54 = tail call i32 (...) @readInBit()
%55 = or i32 %54, %53
%56 = tail call i32 (...) @readInBit()
%57 = shl i32 %55, 2
%58 = shl i32 %56, 1
%59 = or i32 %57, %58
%60 = tail call i32 (...) @readInBit()
%61 = or i32 %60, %59
%62 = tail call i32 (...) @readInBit()
%63 = shl i32 %61, 2
%64 = shl i32 %62, 1
%65 = or i32 %63, %64
%66 = tail call i32 (...) @readInBit()
%67 = or i32 %66, %65
%68 = tail call i32 (...) @readInBit()
%69 = shl i32 %67, 2
%70 = shl i32 %68, 1
%71 = or i32 %69, %70
%72 = tail call i32 (...) @readInBit()
%73 = or i32 %72, %71
%74 = tail call i32 (...) @readInBit()
%75 = shl i32 %73, 2
%76 = shl i32 %74, 1
%77 = or i32 %75, %76
%78 = tail call i32 (...) @readInBit()
%79 = or i32 %78, %77
%80 = tail call i32 (...) @readInBit()
%81 = shl i32 %79, 2
%82 = shl i32 %80, 1
%83 = or i32 %81, %82
%84 = tail call i32 (...) @readInBit()
%85 = or i32 %84, %83
%86 = tail call i32 (...) @readInBit()
%87 = shl i32 %85, 2
%88 = shl i32 %86, 1
%89 = or i32 %87, %88
%90 = tail call i32 (...) @readInBit()
%91 = or i32 %90, %89
%92 = shl i32 %91, 1
%93 = tail call i32 (...) @readInBit()
%94 = or i32 %93, %92
%95 = bitcast i32 %94 to float
ret float %95
}