#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 */
float logf(float);
void fill_icsi_log_table2(const unsigned precision, float *const pTable) {
  float oneToTwo = 1.0f + (1.0f / (float)(1 << (precision + 1)));
  int i;
  for (i = 0; i < (1 << precision); ++i) {
    pTable[i] = logf(oneToTwo) / 0.69314718055995f;
    oneToTwo += 1.0f / (float)(1 << precision);
  }
}


x86 assembly (clang, -O0):
<fill_icsi_log_table2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2ss %eax,%xmm0
movss  0xec8(%rip),%xmm1
divss  %xmm0,%xmm1
movss  0xebc(%rip),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jge    11c0 <fill_icsi_log_table2+0xb0>
movss  -0x14(%rbp),%xmm0
call   1030 <logf@plt>
movss  0xe87(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2ss %eax,%xmm1
movss  0xe5c(%rip),%xmm0
divss  %xmm1,%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <fill_icsi_log_table2+0x44>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_icsi_log_table2>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ecx
mov    $0x1,%r15d
mov    $0x1,%eax
shl    %cl,%eax
cmp    $0x1f,%edi
je     11a1 <fill_icsi_log_table2+0x91>
mov    %rsi,%r14
add    $0x1,%cl
mov    $0x1,%edx
shl    %cl,%edx
cvtsi2ss %edx,%xmm0
movss  0xeba(%rip),%xmm2
movaps %xmm2,%xmm3
cvtsi2ss %eax,%xmm1
divss  %xmm0,%xmm3
addss  %xmm2,%xmm3
divss  %xmm1,%xmm2
movss  %xmm2,0x8(%rsp)
cmp    $0x2,%eax
cmovge %eax,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movss  %xmm3,0xc(%rsp)
movaps %xmm3,%xmm0
call   1030 <logf@plt>
movss  0xc(%rsp),%xmm3
divss  0xe78(%rip),%xmm0
movss  %xmm0,(%r14,%rbx,4)
addss  0x8(%rsp),%xmm3
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <fill_icsi_log_table2+0x60>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @fill_icsi_log_table2(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca float
%6 = alloca i32
store i32 %0, i32* %3
store float* %1, float** %4
%7 = load i32, i32* %3
%8 = add i32 %7, 1
%9 = shl i32 1, %8
%10 = sitofp i32 %9 to float
%11 = fdiv float 1.000000e+00, %10
%12 = fadd float 1.000000e+00, %11
store float %12, float* %5
store i32 0, i32* %6
br label %13
13: ; preds = %32, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = shl i32 1, %15
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %35
18: ; preds = %13
%19 = load float, float* %5
%20 = call float @logf(float %19)
%21 = fdiv float %20, 0x3FE62E4300000000
%22 = load float*, float** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %22, i64 %24
store float %21, float* %25
%26 = load i32, i32* %3
%27 = shl i32 1, %26
%28 = sitofp i32 %27 to float
%29 = fdiv float 1.000000e+00, %28
%30 = load float, float* %5
%31 = fadd float %30, %29
store float %31, float* %5
br label %32
32: ; preds = %18
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %13
35: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @fill_icsi_log_table2(i32 %0, float* nocapture writeonly %1) {
%3 = shl nuw i32 1, %0
%4 = icmp eq i32 %0, 31
br i1 %4, label %24, label %5
5: ; preds = %2
%6 = add i32 %0, 1
%7 = shl nuw i32 1, %6
%8 = sitofp i32 %7 to float
%9 = fdiv float 1.000000e+00, %8
%10 = fadd float %9, 1.000000e+00
%11 = sitofp i32 %3 to float
%12 = fdiv float 1.000000e+00, %11
%13 = call i32 @llvm.smax.i32(i32 %3, i32 1)
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %5, %15
%16 = phi i64 [ 0, %5 ], [ %22, %15 ]
%17 = phi float [ %10, %5 ], [ %21, %15 ]
%18 = tail call float @logf(float %17)
%19 = fdiv float %18, 0x3FE62E4300000000
%20 = getelementptr inbounds float, float* %1, i64 %16
store float %19, float* %20
%21 = fadd float %12, %17
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, %14
br i1 %23, label %24, label %15
24: ; preds = %15, %2
ret void
}