#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 get_bit(int, int);
double pow(int, int);
double decode_fraction(int high, int low) {
  double result = 0.0;
  int i;
  high = (high << 2) | low;
  for (i = 0; i < 10; ++i)
    result += get_bit(high, i) * pow(2, i - 10);
  return result;
}


x86 assembly (clang, -O0):
<decode_fraction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    119b <decode_fraction+0x7b>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <get_bit@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%esi
sub    $0xa,%esi
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <decode_fraction+0x29>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_fraction>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
shl    $0x2,%ebx
or     %esi,%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,(%rsp)
mov    $0x2,%edi
mov    $0xfffffff6,%esi
call   1030 <pow@plt>
mulsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffff7,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffff8,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x3,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffff9,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x4,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffffa,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x5,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffffb,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x6,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffffc,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x7,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffffd,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x8,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xfffffffe,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
mov    $0x9,%esi
call   1040 <get_bit@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
mov    $0xffffffff,%esi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @decode_fraction(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
%7 = load i32, i32* %3
%8 = shl i32 %7, 2
%9 = load i32, i32* %4
%10 = or i32 %8, %9
store i32 %10, i32* %3
store i32 0, i32* %6
br label %11
11: ; preds = %23, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i32, i32* %6
%17 = call double @get_bit(i32 %15, i32 %16)
%18 = load i32, i32* %6
%19 = sub nsw i32 %18, 10
%20 = call double @pow(i32 2, i32 %19)
%21 = load double, double* %5
%22 = call double @llvm.fmuladd.f64(double %17, double %20, double %21)
store double %22, double* %5
br label %23
23: ; preds = %14
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %11
26: ; preds = %11
%27 = load double, double* %5
ret double %27
}

LLVM IR (-O2):
define double @decode_fraction(i32 %0, i32 %1) {
%3 = shl i32 %0, 2
%4 = or i32 %3, %1
%5 = tail call double @get_bit(i32 %4, i32 0)
%6 = tail call double @pow(i32 2, i32 -10)
%7 = tail call double @llvm.fmuladd.f64(double %5, double %6, double 0.000000e+00)
%8 = tail call double @get_bit(i32 %4, i32 1)
%9 = tail call double @pow(i32 2, i32 -9)
%10 = tail call double @llvm.fmuladd.f64(double %8, double %9, double %7)
%11 = tail call double @get_bit(i32 %4, i32 2)
%12 = tail call double @pow(i32 2, i32 -8)
%13 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %10)
%14 = tail call double @get_bit(i32 %4, i32 3)
%15 = tail call double @pow(i32 2, i32 -7)
%16 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %13)
%17 = tail call double @get_bit(i32 %4, i32 4)
%18 = tail call double @pow(i32 2, i32 -6)
%19 = tail call double @llvm.fmuladd.f64(double %17, double %18, double %16)
%20 = tail call double @get_bit(i32 %4, i32 5)
%21 = tail call double @pow(i32 2, i32 -5)
%22 = tail call double @llvm.fmuladd.f64(double %20, double %21, double %19)
%23 = tail call double @get_bit(i32 %4, i32 6)
%24 = tail call double @pow(i32 2, i32 -4)
%25 = tail call double @llvm.fmuladd.f64(double %23, double %24, double %22)
%26 = tail call double @get_bit(i32 %4, i32 7)
%27 = tail call double @pow(i32 2, i32 -3)
%28 = tail call double @llvm.fmuladd.f64(double %26, double %27, double %25)
%29 = tail call double @get_bit(i32 %4, i32 8)
%30 = tail call double @pow(i32 2, i32 -2)
%31 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %28)
%32 = tail call double @get_bit(i32 %4, i32 9)
%33 = tail call double @pow(i32 2, i32 -1)
%34 = tail call double @llvm.fmuladd.f64(double %32, double %33, double %31)
ret double %34
}