#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 */
long rand();
float floatrand() {
  float result;
  float expo;
  long a, c;
  long i;
  a = rand();
  c = rand();
  result = (float)((a - 1073741824) >> 6);
  for (i = 512, expo = 2; i <= 16384; i *= 2, expo = expo * expo) {
    if (c & i) {
      result *= expo;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<floatrand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <rand@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x40000000,%rax
sar    $0x6,%rax
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x4(%rbp)
movq   $0x200,-0x20(%rbp)
movss  0xeaa(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
cmpq   $0x4000,-0x20(%rbp)
jg     11af <floatrand+0x9f>
mov    -0x18(%rbp),%rax
and    -0x20(%rbp),%rax
cmp    $0x0,%rax
je     118a <floatrand+0x7a>
movss  -0x8(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    118f <floatrand+0x7f>
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    115b <floatrand+0x4b>
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floatrand>:
push   %rbx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <rand@plt>
add    $0xffffffffc0000000,%rbx
sar    $0x6,%rbx
cvtsi2ss %rbx,%xmm0
xor    %ecx,%ecx
test   $0x200,%eax
sete   %cl
lea    0xebd(%rip),%rdx
mulss  (%rdx,%rcx,4),%xmm0
xor    %ecx,%ecx
test   $0x400,%eax
sete   %cl
lea    0xeaf(%rip),%rdx
mulss  (%rdx,%rcx,4),%xmm0
xor    %ecx,%ecx
test   $0x800,%eax
sete   %cl
lea    0xea1(%rip),%rdx
mulss  (%rdx,%rcx,4),%xmm0
xor    %ecx,%ecx
test   $0x1000,%eax
sete   %cl
lea    0xe93(%rip),%rdx
mulss  (%rdx,%rcx,4),%xmm0
xor    %ecx,%ecx
test   $0x2000,%eax
sete   %cl
lea    0xe85(%rip),%rdx
mulss  (%rdx,%rcx,4),%xmm0
xor    %ecx,%ecx
test   $0x4000,%eax
sete   %cl
lea    0xe77(%rip),%rax
mulss  (%rax,%rcx,4),%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define float @floatrand() {
%1 = alloca float
%2 = alloca float
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = call i64 (...) @rand()
store i64 %6, i64* %3
%7 = call i64 (...) @rand()
store i64 %7, i64* %4
%8 = load i64, i64* %3
%9 = sub nsw i64 %8, 1073741824
%10 = ashr i64 %9, 6
%11 = sitofp i64 %10 to float
store float %11, float* %1
store i64 512, i64* %5
store float 2.000000e+00, float* %2
br label %12
12: ; preds = %25, %0
%13 = load i64, i64* %5
%14 = icmp sle i64 %13, 16384
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = load i64, i64* %4
%17 = load i64, i64* %5
%18 = and i64 %16, %17
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load float, float* %2
%22 = load float, float* %1
%23 = fmul float %22, %21
store float %23, float* %1
br label %24
24: ; preds = %20, %15
br label %25
25: ; preds = %24
%26 = load i64, i64* %5
%27 = mul nsw i64 %26, 2
store i64 %27, i64* %5
%28 = load float, float* %2
%29 = load float, float* %2
%30 = fmul float %28, %29
store float %30, float* %2
br label %12
31: ; preds = %12
%32 = load float, float* %1
ret float %32
}

LLVM IR (-O2):
define float @floatrand() {
%1 = tail call i64 (...) @rand()
%2 = tail call i64 (...) @rand()
%3 = add nsw i64 %1, -1073741824
%4 = ashr i64 %3, 6
%5 = sitofp i64 %4 to float
%6 = and i64 %2, 512
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, float 1.000000e+00, float 2.000000e+00
%9 = fmul float %8, %5
%10 = and i64 %2, 1024
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, float 1.000000e+00, float 4.000000e+00
%13 = fmul float %9, %12
%14 = and i64 %2, 2048
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, float 1.000000e+00, float 1.600000e+01
%17 = fmul float %13, %16
%18 = and i64 %2, 4096
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, float 1.000000e+00, float 2.560000e+02
%21 = fmul float %17, %20
%22 = and i64 %2, 8192
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, float 1.000000e+00, float 6.553600e+04
%25 = fmul float %21, %24
%26 = and i64 %2, 16384
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, float 1.000000e+00, float 0x41F0000000000000
%29 = fmul float %25, %28
ret float %29
}