#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 */
double pow(int, int);
double number(int bits, int sign, int exp) {
  double res, frac, y;
  double i;
  frac = 0.0;
  for (i = 1.0; i <= bits - 1; i++) {
    y = pow(2, -i);
    frac = frac + y;
  }
  res = pow(-1.0, sign) * (1.0 + frac) * pow(2, exp - 1);
  return res;
}


x86 assembly (clang, -O0):
<number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xecf(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
ucomisd %xmm1,%xmm0
jb     11a4 <number+0x94>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvttsd2si %xmm0,%esi
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe6b(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1136 <number+0x26>
mov    -0x8(%rbp),%esi
mov    $0xffffffff,%edi
call   1030 <pow@plt>
movsd  0xe47(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
cmp    $0x2,%edi
jge    112c <number+0x1c>
movsd  0xed9(%rip),%xmm0
jmp    11bc <number+0xac>
add    $0xffffffff,%edi
cvtsi2sd %edi,%xmm0
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
movsd  0xebb(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movapd %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
xorpd  0xea8(%rip),%xmm0
cvttsd2si %xmm0,%esi
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
addsd  0xe66(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0x20(%rsp),%xmm1
ucomisd 0x10(%rsp),%xmm1
movapd 0x10(%rsp),%xmm1
jae    1150 <number+0x40>
addsd  0xe44(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xffffffff,%edi
mov    %ebp,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0xffffffff,%ebx
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
mulsd  0x10(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @number(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %8
store double 1.000000e+00, double* %10
br label %11
11: ; preds = %25, %3
%12 = load double, double* %10
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = sitofp i32 %14 to double
%16 = fcmp ole double %12, %15
br i1 %16, label %17, label %28
17: ; preds = %11
%18 = load double, double* %10
%19 = fneg double %18
%20 = fptosi double %19 to i32
%21 = call double @pow(i32 2, i32 %20)
store double %21, double* %9
%22 = load double, double* %8
%23 = load double, double* %9
%24 = fadd double %22, %23
store double %24, double* %8
br label %25
25: ; preds = %17
%26 = load double, double* %10
%27 = fadd double %26, 1.000000e+00
store double %27, double* %10
br label %11
28: ; preds = %11
%29 = load i32, i32* %5
%30 = call double @pow(i32 -1, i32 %29)
%31 = load double, double* %8
%32 = fadd double 1.000000e+00, %31
%33 = fmul double %30, %32
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, 1
%36 = call double @pow(i32 2, i32 %35)
%37 = fmul double %33, %36
store double %37, double* %7
%38 = load double, double* %7
ret double %38
}

LLVM IR (-O2):
define double @number(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %0, -1
%5 = sitofp i32 %4 to double
%6 = icmp slt i32 %0, 2
br i1 %6, label %18, label %7
7: ; preds = %3, %7
%8 = phi double [ %14, %7 ], [ 1.000000e+00, %3 ]
%9 = phi double [ %13, %7 ], [ 0.000000e+00, %3 ]
%10 = fneg double %8
%11 = fptosi double %10 to i32
%12 = tail call double @pow(i32 2, i32 %11)
%13 = fadd double %9, %12
%14 = fadd double %8, 1.000000e+00
%15 = fcmp ugt double %14, %5
br i1 %15, label %16, label %7
16: ; preds = %7
%17 = fadd double %13, 1.000000e+00
br label %18
18: ; preds = %16, %3
%19 = phi double [ 1.000000e+00, %3 ], [ %17, %16 ]
%20 = tail call double @pow(i32 -1, i32 %1)
%21 = fmul double %19, %20
%22 = add nsw i32 %2, -1
%23 = tail call double @pow(i32 2, i32 %22)
%24 = fmul double %21, %23
ret double %24
}