#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 uint_fast32_t;
typedef int uint32_t;
typedef int int_fast64_t;
typedef int int_fast32_t;

/* Variables and functions */
int rand();
int_fast64_t recF32FromF32(uint32_t in, bool addRandomness) {
  bool sign;
  int exp;
  int_fast32_t fract;
  sign = in >> 31 & 1;
  exp = in >> 23 & 0xFF;
  fract = in & 0x7FFFFF;
  if (exp == 0xFF) {
    if (fract) {
      exp = 0x1C0;
    } else {
      exp = 0x180;
      if (addRandomness) {
        fract = (((uint_fast32_t)rand() << 15) + rand()) & 0x7FFFFF;
      }
    }
    if (addRandomness)
      exp |= rand() & 0x3F;
  } else {
    if (exp == 0) {
      if (fract < 0x80) {
        if (!fract) {
          if (addRandomness)
            exp = rand() & 0x3F;
          goto done;
        }
        exp -= 16;
        fract <<= 16;
      } else if (fract < 0x8000) {
        exp -= 8;
        fract <<= 8;
      }
      if (fract < 0x80000) {
        exp -= 4;
        fract <<= 4;
      }
      if (fract < 0x200000) {
        exp -= 2;
        fract <<= 2;
      }
      if (!(fract & 0x400000)) {
        --exp;
        fract <<= 1;
      }
      fract = (fract << 1) - 0x800000;
    }
    exp += 0x081;
  }
done:
  return (int_fast64_t)sign << 32 | (int_fast64_t)exp << 23 | fract;
}


x86 assembly (clang, -O0):
<recF32FromF32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1f,%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x17,%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7fffff,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xff,-0x10(%rbp)
jne    11be <recF32FromF32+0xae>
cmpl   $0x0,-0x14(%rbp)
je     1166 <recF32FromF32+0x56>
movl   $0x1c0,-0x10(%rbp)
jmp    119f <recF32FromF32+0x8f>
movl   $0x180,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     119a <recF32FromF32+0x8a>
mov    $0x0,%al
call   1030 <rand@plt>
shl    $0xf,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
and    $0x7fffff,%eax
mov    %eax,-0x14(%rbp)
jmp    119f <recF32FromF32+0x8f>
cmpl   $0x0,-0x8(%rbp)
je     11b9 <recF32FromF32+0xa9>
mov    $0x0,%al
call   1030 <rand@plt>
and    $0x3f,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    12b0 <recF32FromF32+0x1a0>
cmpl   $0x0,-0x10(%rbp)
jne    12a5 <recF32FromF32+0x195>
cmpl   $0x80,-0x14(%rbp)
jge    1212 <recF32FromF32+0x102>
cmpl   $0x0,-0x14(%rbp)
jne    11fb <recF32FromF32+0xeb>
cmpl   $0x0,-0x8(%rbp)
je     11f6 <recF32FromF32+0xe6>
mov    $0x0,%al
call   1030 <rand@plt>
and    $0x3f,%eax
mov    %eax,-0x10(%rbp)
jmp    12b5 <recF32FromF32+0x1a5>
mov    -0x10(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x14(%rbp)
jmp    1236 <recF32FromF32+0x126>
cmpl   $0x8000,-0x14(%rbp)
jge    1231 <recF32FromF32+0x121>
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    1236 <recF32FromF32+0x126>
cmpl   $0x80000,-0x14(%rbp)
jge    1255 <recF32FromF32+0x145>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x200000,-0x14(%rbp)
jge    1274 <recF32FromF32+0x164>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x400000,%eax
cmp    $0x0,%eax
jne    1297 <recF32FromF32+0x187>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
sub    $0x800000,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x81,%eax
mov    %eax,-0x10(%rbp)
jmp    12b5 <recF32FromF32+0x1a5>
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    -0x10(%rbp),%ecx
shl    $0x17,%ecx
or     %ecx,%eax
or     -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recF32FromF32>:
push   %rbx
mov    %esi,%ebx
mov    %edi,%eax
shr    $0x17,%eax
test   %al,%al
je     1140 <recF32FromF32+0x30>
cmp    $0xff,%al
jne    113e <recF32FromF32+0x2e>
test   $0x7fffff,%edi
jne    113a <recF32FromF32+0x2a>
test   %ebx,%ebx
je     113a <recF32FromF32+0x2a>
xor    %eax,%eax
call   1030 <rand@plt>
xor    %eax,%eax
call   1030 <rand@plt>
test   %ebx,%ebx
jne    114c <recF32FromF32+0x3c>
pop    %rbx
ret
test   %ebx,%ebx
je     113e <recF32FromF32+0x2e>
and    $0x7fffff,%edi
jne    113e <recF32FromF32+0x2e>
xor    %eax,%eax
call   1030 <rand@plt>
pop    %rbx
ret

LLVM IR (-O0):
define i32 @recF32FromF32(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = ashr i32 %8, 31
%10 = and i32 %9, 1
store i32 %10, i32* %5
%11 = load i32, i32* %3
%12 = ashr i32 %11, 23
%13 = and i32 %12, 255
store i32 %13, i32* %6
%14 = load i32, i32* %3
%15 = and i32 %14, 8388607
store i32 %15, i32* %7
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 255
br i1 %17, label %18, label %41
18: ; preds = %2
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 448, i32* %6
br label %32
22: ; preds = %18
store i32 384, i32* %6
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = call i32 (...) @rand()
%27 = shl i32 %26, 15
%28 = call i32 (...) @rand()
%29 = add nsw i32 %27, %28
%30 = and i32 %29, 8388607
store i32 %30, i32* %7
br label %31
31: ; preds = %25, %22
br label %32
32: ; preds = %31, %21
%33 = load i32, i32* %4
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = call i32 (...) @rand()
%37 = and i32 %36, 63
%38 = load i32, i32* %6
%39 = or i32 %38, %37
store i32 %39, i32* %6
br label %40
40: ; preds = %35, %32
br label %103
41: ; preds = %2
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %100
44: ; preds = %41
%45 = load i32, i32* %7
%46 = icmp slt i32 %45, 128
br i1 %46, label %47, label %62
47: ; preds = %44
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
br i1 %49, label %57, label %50
50: ; preds = %47
%51 = load i32, i32* %4
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = call i32 (...) @rand()
%55 = and i32 %54, 63
store i32 %55, i32* %6
br label %56
56: ; preds = %53, %50
br label %104
57: ; preds = %47
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, 16
store i32 %59, i32* %6
%60 = load i32, i32* %7
%61 = shl i32 %60, 16
store i32 %61, i32* %7
br label %71
62: ; preds = %44
%63 = load i32, i32* %7
%64 = icmp slt i32 %63, 32768
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = load i32, i32* %6
%67 = sub nsw i32 %66, 8
store i32 %67, i32* %6
%68 = load i32, i32* %7
%69 = shl i32 %68, 8
store i32 %69, i32* %7
br label %70
70: ; preds = %65, %62
br label %71
71: ; preds = %70, %57
%72 = load i32, i32* %7
%73 = icmp slt i32 %72, 524288
br i1 %73, label %74, label %79
74: ; preds = %71
%75 = load i32, i32* %6
%76 = sub nsw i32 %75, 4
store i32 %76, i32* %6
%77 = load i32, i32* %7
%78 = shl i32 %77, 4
store i32 %78, i32* %7
br label %79
79: ; preds = %74, %71
%80 = load i32, i32* %7
%81 = icmp slt i32 %80, 2097152
br i1 %81, label %82, label %87
82: ; preds = %79
%83 = load i32, i32* %6
%84 = sub nsw i32 %83, 2
store i32 %84, i32* %6
%85 = load i32, i32* %7
%86 = shl i32 %85, 2
store i32 %86, i32* %7
br label %87
87: ; preds = %82, %79
%88 = load i32, i32* %7
%89 = and i32 %88, 4194304
%90 = icmp ne i32 %89, 0
br i1 %90, label %96, label %91
91: ; preds = %87
%92 = load i32, i32* %6
%93 = add nsw i32 %92, -1
store i32 %93, i32* %6
%94 = load i32, i32* %7
%95 = shl i32 %94, 1
store i32 %95, i32* %7
br label %96
96: ; preds = %91, %87
%97 = load i32, i32* %7
%98 = shl i32 %97, 1
%99 = sub nsw i32 %98, 8388608
store i32 %99, i32* %7
br label %100
100: ; preds = %96, %41
%101 = load i32, i32* %6
%102 = add nsw i32 %101, 129
store i32 %102, i32* %6
br label %103
103: ; preds = %100, %40
br label %104
104: ; preds = %103, %56
%105 = load i32, i32* %5
%106 = shl i32 %105, 32
%107 = load i32, i32* %6
%108 = shl i32 %107, 23
%109 = or i32 %106, %108
%110 = load i32, i32* %7
%111 = or i32 %109, %110
ret i32 %111
}

LLVM IR (-O2):
define i32 @recF32FromF32(i32 %0, i32 %1) {
%3 = lshr i32 %0, 23
%4 = and i32 %0, 8388607
%5 = trunc i32 %3 to i8
switch i8 %5, label %20 [
i8 -1, label %6
i8 0, label %14
]
6: ; preds = %2
%7 = icmp ne i32 %4, 0
%8 = icmp eq i32 %1, 0
%9 = or i1 %7, %8
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32 (...) @rand()
%12 = tail call i32 (...) @rand()
br label %13
13: ; preds = %6, %10
br i1 %8, label %20, label %18
14: ; preds = %2
%15 = icmp ne i32 %4, 0
%16 = icmp eq i32 %1, 0
%17 = or i1 %16, %15
br i1 %17, label %20, label %18
18: ; preds = %14, %13
%19 = tail call i32 (...) @rand()
br label %20
20: ; preds = %18, %14, %2, %13
ret i32 poison
}