#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 */
int M_LN2;
int log(double);
int init_bit_table_const(unsigned long int max_size, int *n_bit, int *base,
                         int *bit_row_size) {
  int bit_pos;
  int block_mask;
  bit_pos = (int)(log((double)max_size) / M_LN2);
  (*n_bit) = 5 > (bit_pos >> 1) ? 5 : (bit_pos >> 1);
  (*bit_row_size) = 0;
  (bit_row_size[(*n_bit) >> 5] |= (1 << ((*n_bit) & 31)));
  (*bit_row_size)--;
  (*bit_row_size) = ((*bit_row_size) >> 5) + 1;
  block_mask = (int)(log((double)(*bit_row_size)) / M_LN2);
  (*base) = ((*bit_row_size) << 5) - 1;
  return block_mask;
}


x86 assembly (clang, -O0):
<init_bit_table_const>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movaps 0xed1(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xed0(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <log@plt>
mov    0x2e85(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
sar    $0x1,%ecx
mov    $0x5,%eax
cmp    %ecx,%eax
jle    1181 <init_bit_table_const+0x71>
mov    $0x5,%eax
mov    %eax,-0x2c(%rbp)
jmp    118a <init_bit_table_const+0x7a>
mov    -0x24(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
and    $0x1f,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sar    $0x5,%ecx
movslq %ecx,%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
sar    $0x5,%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
call   1030 <log@plt>
mov    0x2dec(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
shl    $0x5,%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_bit_table_const>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
movq   %rdi,%xmm1
punpckldq 0xed2(%rip),%xmm1
subpd  0xeda(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
call   1030 <log@plt>
mov    0x2e92(%rip),%r12
cltd
idivl  (%r12)
sar    %eax
cmp    $0x6,%eax
mov    $0x5,%ecx
cmovge %eax,%ecx
mov    %ecx,(%r15)
movl   $0x0,(%rbx)
mov    (%r15),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sar    $0x5,%ecx
movslq %ecx,%rcx
or     %eax,(%rbx,%rcx,4)
mov    (%rbx),%eax
add    $0xffffffff,%eax
sar    $0x5,%eax
add    $0x1,%eax
mov    %eax,(%rbx)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1030 <log@plt>
cltd
idivl  (%r12)
mov    (%rbx),%ecx
shl    $0x5,%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_LN2 = global i32 0
define i32 @init_bit_table_const(i64 %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i64 %0, i64* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%11 = load i64, i64* %5
%12 = uitofp i64 %11 to double
%13 = call i32 @log(double %12)
%14 = load i32, i32* @M_LN2
%15 = sdiv i32 %13, %14
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = ashr i32 %16, 1
%18 = icmp sgt i32 5, %17
br i1 %18, label %19, label %20
19: ; preds = %4
br label %23
20: ; preds = %4
%21 = load i32, i32* %9
%22 = ashr i32 %21, 1
br label %23
23: ; preds = %20, %19
%24 = phi i32 [ 5, %19 ], [ %22, %20 ]
%25 = load i32*, i32** %6
store i32 %24, i32* %25
%26 = load i32*, i32** %8
store i32 0, i32* %26
%27 = load i32*, i32** %6
%28 = load i32, i32* %27
%29 = and i32 %28, 31
%30 = shl i32 1, %29
%31 = load i32*, i32** %8
%32 = load i32*, i32** %6
%33 = load i32, i32* %32
%34 = ashr i32 %33, 5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %31, i64 %35
%37 = load i32, i32* %36
%38 = or i32 %37, %30
store i32 %38, i32* %36
%39 = load i32*, i32** %8
%40 = load i32, i32* %39
%41 = add nsw i32 %40, -1
store i32 %41, i32* %39
%42 = load i32*, i32** %8
%43 = load i32, i32* %42
%44 = ashr i32 %43, 5
%45 = add nsw i32 %44, 1
%46 = load i32*, i32** %8
store i32 %45, i32* %46
%47 = load i32*, i32** %8
%48 = load i32, i32* %47
%49 = sitofp i32 %48 to double
%50 = call i32 @log(double %49)
%51 = load i32, i32* @M_LN2
%52 = sdiv i32 %50, %51
store i32 %52, i32* %10
%53 = load i32*, i32** %8
%54 = load i32, i32* %53
%55 = shl i32 %54, 5
%56 = sub nsw i32 %55, 1
%57 = load i32*, i32** %7
store i32 %56, i32* %57
%58 = load i32, i32* %10
ret i32 %58
}

LLVM IR (-O2):
@M_LN2 = global i32 0
define i32 @init_bit_table_const(i64 %0, i32* nocapture %1, i32* nocapture writeonly %2, i32* nocapture %3) {
%5 = uitofp i64 %0 to double
%6 = tail call i32 @log(double %5)
%7 = load i32, i32* @M_LN2
%8 = sdiv i32 %6, %7
%9 = ashr i32 %8, 1
%10 = icmp sgt i32 %9, 5
%11 = select i1 %10, i32 %9, i32 5
store i32 %11, i32* %1
store i32 0, i32* %3
%12 = load i32, i32* %1
%13 = and i32 %12, 31
%14 = shl nuw i32 1, %13
%15 = ashr i32 %12, 5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %3, i64 %16
%18 = load i32, i32* %17
%19 = or i32 %14, %18
store i32 %19, i32* %17
%20 = load i32, i32* %3
%21 = add nsw i32 %20, -1
%22 = ashr i32 %21, 5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
%24 = sitofp i32 %23 to double
%25 = tail call i32 @log(double %24)
%26 = load i32, i32* @M_LN2
%27 = sdiv i32 %25, %26
%28 = load i32, i32* %3
%29 = shl i32 %28, 5
%30 = add nsw i32 %29, -1
store i32 %30, i32* %2
ret i32 %27
}