#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 od_rsqrt_table(double const);
double od_custom_rsqrt_dynamic_table(const double *table, const int table_size,
                                     const double start, const int i) {
  if (i < table_size)
    return table[i];
  else
    return od_rsqrt_table(start + 2 * i + 1);
}


x86 assembly (clang, -O0):
<od_custom_rsqrt_dynamic_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    114a <od_custom_rsqrt_dynamic_table+0x3a>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1173 <od_custom_rsqrt_dynamic_table+0x63>
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe9b(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <od_rsqrt_table@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<od_custom_rsqrt_dynamic_table>:
cmp    %esi,%edx
jge    111d <od_custom_rsqrt_dynamic_table+0xd>
movslq %edx,%rax
movsd  (%rdi,%rax,8),%xmm0
ret
add    %edx,%edx
cvtsi2sd %edx,%xmm1
addsd  %xmm0,%xmm1
addsd  0xed1(%rip),%xmm1
movapd %xmm1,%xmm0
jmp    1030 <od_rsqrt_table@plt>

LLVM IR (-O0):
define double @od_custom_rsqrt_dynamic_table(double* %0, i32 %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store double %2, double* %8
store i32 %3, i32* %9
%10 = load i32, i32* %9
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %4
%14 = load double*, double** %6
%15 = load i32, i32* %9
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
store double %18, double* %5
br label %27
19: ; preds = %4
%20 = load double, double* %8
%21 = load i32, i32* %9
%22 = mul nsw i32 2, %21
%23 = sitofp i32 %22 to double
%24 = fadd double %20, %23
%25 = fadd double %24, 1.000000e+00
%26 = call double @od_rsqrt_table(double %25)
store double %26, double* %5
br label %27
27: ; preds = %19, %13
%28 = load double, double* %5
ret double %28
}

LLVM IR (-O2):
define double @od_custom_rsqrt_dynamic_table(double* nocapture %0, i32 %1, double %2, i32 %3) {
%5 = icmp slt i32 %3, %1
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds double, double* %0, i64 %7
%9 = load double, double* %8
br label %16
10: ; preds = %4
%11 = shl nsw i32 %3, 1
%12 = sitofp i32 %11 to double
%13 = fadd double %12, %2
%14 = fadd double %13, 1.000000e+00
%15 = tail call double @od_rsqrt_table(double %14)
br label %16
16: ; preds = %10, %6
%17 = phi double [ %9, %6 ], [ %15, %10 ]
ret double %17
}