#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);
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--;
  }
  mant = x >> 8;
  b.i = (exp << 23) | mant;
  return b.f;
}


x86 assembly (clang, -O0):
<my_random_float2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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
call   1030 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1167 <my_random_float2+0x47>
mov    -0xc(%rbp),%eax
sub    $0x1f,%eax
mov    %eax,-0xc(%rbp)
jmp    116c <my_random_float2+0x4c>
jmp    1171 <my_random_float2+0x51>
jmp    1136 <my_random_float2+0x16>
jmp    1176 <my_random_float2+0x56>
mov    -0x4(%rbp),%eax
and    -0x10(%rbp),%eax
cmp    $0x0,%eax
je     119c <my_random_float2+0x7c>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <my_random_float2+0x56>
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x17,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_random_float2>:
push   %rbp
push   %r14
push   %rbx
mov    $0x9d,%ebp
lea    0xed0(%rip),%r14
xor    %eax,%eax
call   1040 <random@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0xffffffe1,%ebp
test   %ebx,%ebx
je     1130 <my_random_float2+0x10>
test   $0x1,%bl
je     1169 <my_random_float2+0x49>
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %eax,%eax
add    $0xffffffff,%ebp
test   %ebx,%eax
jne    1160 <my_random_float2+0x40>
sar    $0x8,%ebx
shl    $0x17,%ebp
or     %ebx,%ebp
movd   %ebp,%xmm0
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%union.anon = type { float }
@.str = [4 x i8] c"%d\0A\00"
define float @my_random_float2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %union.anon
store i32 126, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %0, %16
%7 = call i32 (...) @random()
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 31
store i32 %14, i32* %3
br label %16
15: ; preds = %6
br label %17
16: ; preds = %12
br label %6
17: ; preds = %15
br label %18
18: ; preds = %23, %17
%19 = load i32, i32* %1
%20 = load i32, i32* %4
%21 = and i32 %19, %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i32, i32* %4
%25 = shl i32 %24, 1
store i32 %25, i32* %4
%26 = load i32, i32* %3
%27 = add nsw i32 %26, -1
store i32 %27, i32* %3
br label %18
28: ; preds = %18
%29 = load i32, i32* %1
%30 = ashr i32 %29, 8
store i32 %30, i32* %2
%31 = load i32, i32* %3
%32 = shl i32 %31, 23
%33 = load i32, i32* %2
%34 = or i32 %32, %33
%35 = bitcast %union.anon* %5 to i32*
store i32 %34, i32* %35
%36 = bitcast %union.anon* %5 to float*
%37 = load float, float* %36
ret float %37
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\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 @printf(i8* 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 = ashr i32 %3, 8
%20 = shl i32 %18, 23
%21 = or i32 %20, %19
%22 = bitcast i32 %21 to float
ret float %22
}