#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 log2(float);
int pow(int, int const);
void fill_icsi_log_table(const int n, float *lookup_table) {
  float numlog;
  int incr, i, p;
  int *const exp_ptr = ((int *)&numlog);
  int x = *exp_ptr;
  x = 0x3F800000;
  *exp_ptr = x;
  incr = 1 << (23 - n);
  p = pow(2, n);
  for (i = 0; i < p; i++) {
    lookup_table[i] = log2(numlog);
    x += incr;
    *exp_ptr = x;
  }
}


x86 assembly (clang, -O0):
<fill_icsi_log_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x3f800000,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x17,%ecx
sub    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11bc <fill_icsi_log_table+0x9c>
movss  -0x14(%rbp),%xmm0
call   1030 <log2@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <fill_icsi_log_table+0x59>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_icsi_log_table>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%esi
mov    $0x17,%cl
sub    %sil,%cl
mov    $0x1,%r15d
shl    %cl,%r15d
mov    $0x2,%edi
call   1040 <pow@plt>
test   %eax,%eax
jle    117b <fill_icsi_log_table+0x5b>
mov    %eax,%r12d
lea    0x3f800000(%r15),%ebp
movd   0xea5(%rip),%xmm0
xor    %ebx,%ebx
nopl   (%rax)
call   1030 <log2@plt>
movd   %xmm0,(%r14,%rbx,4)
movd   %ebp,%xmm0
add    $0x1,%rbx
add    %r15d,%ebp
cmp    %rbx,%r12
jne    1160 <fill_icsi_log_table+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fill_icsi_log_table(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32 %0, i32* %3
store float* %1, float** %4
%11 = bitcast float* %5 to i32*
store i32* %11, i32** %9
%12 = load i32*, i32** %9
%13 = load i32, i32* %12
store i32 %13, i32* %10
store i32 1065353216, i32* %10
%14 = load i32, i32* %10
%15 = load i32*, i32** %9
store i32 %14, i32* %15
%16 = load i32, i32* %3
%17 = sub nsw i32 23, %16
%18 = shl i32 1, %17
store i32 %18, i32* %6
%19 = load i32, i32* %3
%20 = call i32 @pow(i32 2, i32 %19)
store i32 %20, i32* %8
store i32 0, i32* %7
br label %21
21: ; preds = %37, %2
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %40
25: ; preds = %21
%26 = load float, float* %5
%27 = call float @log2(float %26)
%28 = load float*, float** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
store float %27, float* %31
%32 = load i32, i32* %6
%33 = load i32, i32* %10
%34 = add nsw i32 %33, %32
store i32 %34, i32* %10
%35 = load i32, i32* %10
%36 = load i32*, i32** %9
store i32 %35, i32* %36
br label %37
37: ; preds = %25
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %21
40: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @fill_icsi_log_table(i32 %0, float* nocapture writeonly %1) {
%3 = sub nsw i32 23, %0
%4 = shl nuw i32 1, %3
%5 = tail call i32 @pow(i32 2, i32 %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %2
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %17, %9 ]
%11 = phi i32 [ 1065353216, %7 ], [ %15, %9 ]
%12 = phi float [ 1.000000e+00, %7 ], [ %16, %9 ]
%13 = tail call float @log2(float %12)
%14 = getelementptr inbounds float, float* %1, i64 %10
store float %13, float* %14
%15 = add nsw i32 %11, %4
%16 = bitcast i32 %15 to float
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %19, label %9
19: ; preds = %9, %2
ret void
}