#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 pow(int, int);
int /*<<< orphan*/ printf(char *, float);
float give_my_mantissa(int mantissa) {
  float float_part = 0.0;
  int bit = 0;
  for (int i = 0; i < 23; i++) {
    bit = (mantissa >> i) & 1;
    float_part += bit / pow(2, 23 - i);
  }
  printf("float_part = %f\n", float_part);
  return float_part;
}


x86 assembly (clang, -O0):
<give_my_mantissa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x17,-0x10(%rbp)
jge    1195 <give_my_mantissa+0x75>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x17,%esi
sub    -0x10(%rbp),%esi
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1141 <give_my_mantissa+0x21>
movss  -0x8(%rbp),%xmm0
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<give_my_mantissa>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %ebp,%ebp
mov    $0x16,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r14d,%ebx
mov    %ebp,%ecx
shr    %cl,%ebx
and    $0x1,%ebx
lea    0x1(%r15),%esi
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    %ebx,%eax
xor    %edx,%edx
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x4(%rsp),%xmm0
add    $0x1,%ebp
cmp    $0x17,%ebp
movss  %xmm0,0x4(%rsp)
je     11ba <give_my_mantissa+0x9a>
mov    %r14d,%ebx
mov    %ebp,%ecx
shr    %cl,%ebx
and    $0x1,%ebx
mov    $0x2,%edi
mov    %r15d,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    %ebx,%eax
xor    %edx,%edx
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
add    $0xfffffffe,%r15d
add    $0x1,%ebp
movss  %xmm1,0x4(%rsp)
jmp    1140 <give_my_mantissa+0x20>
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"float_part = %f\0A\00"
define float @give_my_mantissa(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store float 0.000000e+00, float* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 23
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32, i32* %2
%11 = load i32, i32* %5
%12 = ashr i32 %10, %11
%13 = and i32 %12, 1
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = sub nsw i32 23, %15
%17 = call i32 @pow(i32 2, i32 %16)
%18 = sdiv i32 %14, %17
%19 = sitofp i32 %18 to float
%20 = load float, float* %3
%21 = fadd float %20, %19
store float %21, float* %3
br label %22
22: ; preds = %9
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %6
25: ; preds = %6
%26 = load float, float* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), float %26)
%28 = load float, float* %3
ret float %28
}

LLVM IR (-O2):
@.str = [17 x i8] c"float_part = %f\0A\00"
define float @give_my_mantissa(i32 %0) {
br label %4
2: ; preds = %4
%3 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), float %13)
ret float %13
4: ; preds = %16, %1
%5 = phi i32 [ 0, %1 ], [ %24, %16 ]
%6 = phi float [ 0.000000e+00, %1 ], [ %23, %16 ]
%7 = lshr i32 %0, %5
%8 = and i32 %7, 1
%9 = sub nuw nsw i32 23, %5
%10 = tail call i32 @pow(i32 2, i32 %9)
%11 = sdiv i32 %8, %10
%12 = sitofp i32 %11 to float
%13 = fadd float %6, %12
%14 = or i32 %5, 1
%15 = icmp eq i32 %14, 23
br i1 %15, label %2, label %16
16: ; preds = %4
%17 = lshr i32 %0, %14
%18 = and i32 %17, 1
%19 = sub nsw i32 22, %5
%20 = tail call i32 @pow(i32 2, i32 %19)
%21 = sdiv i32 %18, %20
%22 = sitofp i32 %21 to float
%23 = fadd float %13, %22
%24 = add nuw nsw i32 %5, 2
br label %4
}