#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 GetBinaryFraction(int);
float logf(float);
scalar_t__ malloc(int);
scalar_t__ powf(float, int);
float *GenerateLogLUT() {
  int i;
  float matissa = 1.0f;
  int size = (int)(powf(2.0f, 8));
  float *LogLUT = (float *)malloc(sizeof(float) * size);
  for (i = 0; i < size; i++) {
    int M = (int)i << (23 - 8);
    matissa = GetBinaryFraction(M) + 1.0f;
    LogLUT[i] = logf(matissa);
  }
  return LogLUT;
}


x86 assembly (clang, -O0):
<GenerateLogLUT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xea3(%rip),%xmm0
mov    $0x8,%edi
call   1050 <powf@plt>
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d7 <GenerateLogLUT+0x97>
mov    -0x4(%rbp),%eax
shl    $0xf,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <GetBinaryFraction@plt>
movss  0xe5b(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <logf@plt>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1184 <GenerateLogLUT+0x44>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenerateLogLUT>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movss  0xeb0(%rip),%xmm0
mov    $0x8,%edi
call   1050 <powf@plt>
mov    %rax,%rbx
lea    0x0(,%rax,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    11aa <GenerateLogLUT+0x6a>
mov    %ebx,%r15d
shl    $0xf,%r15
xor    %ebx,%ebx
mov    %r14,%r12
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <GetBinaryFraction@plt>
addss  0xe75(%rip),%xmm0
call   1040 <logf@plt>
movss  %xmm0,(%r12)
add    $0x8000,%rbx
add    $0x4,%r12
cmp    %rbx,%r15
jne    1180 <GenerateLogLUT+0x40>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define float* @GenerateLogLUT() {
%1 = tail call i64 @powf(float 2.000000e+00, i32 8)
%2 = trunc i64 %1 to i32
%3 = shl i32 %2, 2
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to float*
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %19
7: ; preds = %0
%8 = and i64 %1, 4294967295
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %17, %9 ]
%11 = trunc i64 %10 to i32
%12 = shl i32 %11, 15
%13 = tail call float @GetBinaryFraction(i32 %12)
%14 = fadd float %13, 1.000000e+00
%15 = tail call float @logf(float %14)
%16 = getelementptr inbounds float, float* %5, i64 %10
store float %15, float* %16
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %19, label %9
19: ; preds = %9, %0
ret float* %5
}