#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*/ printf(char *, ...);
int random();
float my_random_float2() {
  int x;
  int mant;
  int exp = 126;
  int mask = 1;
  union {
    float f;
    int i;
  } b;
  while (1) {
    x = random();
    printf("%d\n", x);
    if (x == 0) {
      exp -= 31;
    } else {
      break;
    }
  }
  while (x & mask) {
    mask <<= 1;
    exp--;
  }
  long a = x;
  while (a) {
    if (a & 1)
      printf("1");
    else
      printf("0");
    a >>= 1;
  }
  printf("that was x\n");
  long c = exp;
  while (c) {
    if (c & 1)
      printf("1");
    else
      printf("0");
    c >>= 1;
  }
  printf("that was exp\n");
  mant = x >> 8;
  long m = mant;
  while (m) {
    if (m & 1)
      printf("1");
    else
      printf("0");
    m >>= 1;
  }
  printf("that was mant\n");
  b.i = (exp << 23) | mant;
  long n = b.i;
  while (n) {
    if (n & 1)
      printf("1");
    else
      printf("0");
    n >>= 1;
  }
  printf("\n");
  return b.f;
}


x86 assembly (clang, -O0):
<my_random_float2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x7e,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    $0x0,%al
call   1040 <random@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1169 <my_random_float2+0x49>
mov    -0xc(%rbp),%eax
sub    $0x1f,%eax
mov    %eax,-0xc(%rbp)
jmp    116e <my_random_float2+0x4e>
jmp    1173 <my_random_float2+0x53>
jmp    1136 <my_random_float2+0x16>
jmp    1178 <my_random_float2+0x58>
mov    -0x4(%rbp),%eax
and    -0x10(%rbp),%eax
cmp    $0x0,%eax
je     119e <my_random_float2+0x7e>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <my_random_float2+0x58>
movslq -0x4(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f5 <my_random_float2+0xd5>
mov    -0x20(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11d6 <my_random_float2+0xb6>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e4 <my_random_float2+0xc4>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a6 <my_random_float2+0x86>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     125a <my_random_float2+0x13a>
mov    -0x28(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     123b <my_random_float2+0x11b>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1249 <my_random_float2+0x129>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    120b <my_random_float2+0xeb>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12c8 <my_random_float2+0x1a8>
mov    -0x30(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     12a9 <my_random_float2+0x189>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b7 <my_random_float2+0x197>
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1279 <my_random_float2+0x159>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
shl    $0x17,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1339 <my_random_float2+0x219>
mov    -0x38(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     131a <my_random_float2+0x1fa>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1328 <my_random_float2+0x208>
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    12ea <my_random_float2+0x1ca>
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_random_float2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x9d,%r12d
lea    0xea7(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <random@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffe1,%r12d
test   %r15d,%r15d
je     1160 <my_random_float2+0x20>
test   $0x1,%r15b
je     119b <my_random_float2+0x5b>
mov    $0x1,%eax
nopw   0x0(%rax,%rax,1)
add    %eax,%eax
add    $0xffffffff,%r12d
test   %r15d,%eax
jne    1190 <my_random_float2+0x50>
movslq %r15d,%rbp
mov    %rbp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
sar    %rbx
cmp    $0x1,%rbp
mov    %rbx,%rbp
ja     11b0 <my_random_float2+0x70>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
test   %r12d,%r12d
je     11f9 <my_random_float2+0xb9>
movslq %r12d,%rbp
mov    %rbp,%rbx
mov    %ebp,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
sar    %rbx
cmp    $0x1,%rbp
mov    %rbx,%rbp
ja     11e0 <my_random_float2+0xa0>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
mov    %r15d,%r14d
sar    $0x8,%r14d
cmp    $0x100,%r15d
jb     1239 <my_random_float2+0xf9>
movslq %r14d,%rbp
mov    %rbp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
sar    %rbx
cmp    $0x1,%rbp
mov    %rbx,%rbp
ja     1220 <my_random_float2+0xe0>
lea    0xddc(%rip),%rdi
call   1040 <puts@plt>
shl    $0x17,%r12d
or     %r14d,%r12d
je     1279 <my_random_float2+0x139>
movslq %r12d,%rbp
mov    %rbp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
sar    %rbx
cmp    $0x1,%rbp
mov    %rbx,%rbp
ja     1260 <my_random_float2+0x120>
mov    %r12d,0xc(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%union.anon = type { float }
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [12 x i8] c"that was x\0A\00"
@.str.4 = [14 x i8] c"that was exp\0A\00"
@.str.5 = [15 x i8] c"that was mant\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define float @my_random_float2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %union.anon
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 126, i32* %3
store i32 1, i32* %4
br label %10
10: ; preds = %0, %20
%11 = call i32 (...) @random()
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 31
store i32 %18, i32* %3
br label %20
19: ; preds = %10
br label %21
20: ; preds = %16
br label %10
21: ; preds = %19
br label %22
22: ; preds = %27, %21
%23 = load i32, i32* %1
%24 = load i32, i32* %4
%25 = and i32 %23, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i32, i32* %4
%29 = shl i32 %28, 1
store i32 %29, i32* %4
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
br label %22
32: ; preds = %22
%33 = load i32, i32* %1
%34 = sext i32 %33 to i64
store i64 %34, i64* %6
br label %35
35: ; preds = %46, %32
%36 = load i64, i64* %6
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %49
38: ; preds = %35
%39 = load i64, i64* %6
%40 = and i64 %39, 1
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %46
44: ; preds = %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
%47 = load i64, i64* %6
%48 = ashr i64 %47, 1
store i64 %48, i64* %6
br label %35
49: ; preds = %35
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
store i64 %52, i64* %7
br label %53
53: ; preds = %64, %49
%54 = load i64, i64* %7
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %67
56: ; preds = %53
%57 = load i64, i64* %7
%58 = and i64 %57, 1
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %64
62: ; preds = %56
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %64
64: ; preds = %62, %60
%65 = load i64, i64* %7
%66 = ashr i64 %65, 1
store i64 %66, i64* %7
br label %53
67: ; preds = %53
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%69 = load i32, i32* %1
%70 = ashr i32 %69, 8
store i32 %70, i32* %2
%71 = load i32, i32* %2
%72 = sext i32 %71 to i64
store i64 %72, i64* %8
br label %73
73: ; preds = %84, %67
%74 = load i64, i64* %8
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %87
76: ; preds = %73
%77 = load i64, i64* %8
%78 = and i64 %77, 1
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %84
82: ; preds = %76
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %84
84: ; preds = %82, %80
%85 = load i64, i64* %8
%86 = ashr i64 %85, 1
store i64 %86, i64* %8
br label %73
87: ; preds = %73
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%89 = load i32, i32* %3
%90 = shl i32 %89, 23
%91 = load i32, i32* %2
%92 = or i32 %90, %91
%93 = bitcast %union.anon* %5 to i32*
store i32 %92, i32* %93
%94 = bitcast %union.anon* %5 to i32*
%95 = load i32, i32* %94
%96 = sext i32 %95 to i64
store i64 %96, i64* %9
br label %97
97: ; preds = %108, %87
%98 = load i64, i64* %9
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %111
100: ; preds = %97
%101 = load i64, i64* %9
%102 = and i64 %101, 1
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %100
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %108
106: ; preds = %100
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %108
108: ; preds = %106, %104
%109 = load i64, i64* %9
%110 = ashr i64 %109, 1
store i64 %110, i64* %9
br label %97
111: ; preds = %97
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%113 = bitcast %union.anon* %5 to float*
%114 = load float, float* %113
ret float %114
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@str = [11 x i8] c"that was x\00"
@str.7 = [13 x i8] c"that was exp\00"
@str.8 = [14 x i8] c"that was mant\00"
define float @my_random_float2() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 126, %0 ], [ %6, %1 ]
%3 = tail call i32 (...) @random()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %3, 0
%6 = add nsw i32 %2, -31
br i1 %5, label %1, label %7
7: ; preds = %1
%8 = and i32 %3, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7, %10
%11 = phi i32 [ %14, %10 ], [ %2, %7 ]
%12 = phi i32 [ %13, %10 ], [ 1, %7 ]
%13 = shl i32 %12, 1
%14 = add nsw i32 %11, -1
%15 = and i32 %13, %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %10
17: ; preds = %10, %7
%18 = phi i32 [ %2, %7 ], [ %14, %10 ]
%19 = sext i32 %3 to i64
br label %20
20: ; preds = %17, %20
%21 = phi i64 [ %26, %20 ], [ %19, %17 ]
%22 = and i64 %21, 1
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i32 48, i32 49
%25 = tail call i32 @putchar(i32 %24)
%26 = ashr i64 %21, 1
%27 = icmp ult i64 %21, 2
br i1 %27, label %28, label %20
28: ; preds = %20
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%30 = icmp eq i32 %18, 0
br i1 %30, label %41, label %31
31: ; preds = %28
%32 = sext i32 %18 to i64
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ %39, %33 ], [ %32, %31 ]
%35 = and i64 %34, 1
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i32 48, i32 49
%38 = tail call i32 @putchar(i32 %37)
%39 = ashr i64 %34, 1
%40 = icmp ult i64 %34, 2
br i1 %40, label %41, label %33
41: ; preds = %33, %28
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%43 = ashr i32 %3, 8
%44 = icmp ult i32 %3, 256
br i1 %44, label %55, label %45
45: ; preds = %41
%46 = sext i32 %43 to i64
br label %47
47: ; preds = %45, %47
%48 = phi i64 [ %53, %47 ], [ %46, %45 ]
%49 = and i64 %48, 1
%50 = icmp eq i64 %49, 0
%51 = select i1 %50, i32 48, i32 49
%52 = tail call i32 @putchar(i32 %51)
%53 = ashr i64 %48, 1
%54 = icmp ult i64 %48, 2
br i1 %54, label %55, label %47
55: ; preds = %47, %41
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0))
%57 = shl i32 %18, 23
%58 = or i32 %57, %43
%59 = icmp eq i32 %58, 0
br i1 %59, label %70, label %60
60: ; preds = %55
%61 = sext i32 %58 to i64
br label %62
62: ; preds = %60, %62
%63 = phi i64 [ %68, %62 ], [ %61, %60 ]
%64 = and i64 %63, 1
%65 = icmp eq i64 %64, 0
%66 = select i1 %65, i32 48, i32 49
%67 = tail call i32 @putchar(i32 %66)
%68 = ashr i64 %63, 1
%69 = icmp ult i64 %63, 2
br i1 %69, label %70, label %62
70: ; preds = %62, %55
%71 = bitcast i32 %58 to float
%72 = tail call i32 @putchar(i32 10)
ret float %71
}