#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 */
typedef unsigned int uint32_t;

/* Variables and functions */
scalar_t__ M_LN10;
float expf(float);
unsigned int lrintf(float);
void gen_logscale_mapping(uint32_t *lin2log, unsigned int n4,
                          unsigned int stepsize) {
  float step = expf((float)M_LN10 * (1.0f / (float)stepsize));
  float idx = step;
  uint32_t i = 0;
  for (i = 1; i < n4; i++) {
    lin2log[i] = lrintf(idx);
    idx *= step;
  }
}


x86 assembly (clang, -O0):
<gen_logscale_mapping>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0x2ea7(%rip),%rax
cvtsi2ssq (%rax),%xmm0
mov    -0x10(%rbp),%eax
cvtsi2ss %rax,%xmm2
movss  0xeb2(%rip),%xmm1
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
call   1040 <expf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b7 <gen_logscale_mapping+0x97>
movss  -0x18(%rbp),%xmm0
call   1030 <lrintf@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
movss  -0x14(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1178 <gen_logscale_mapping+0x58>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_logscale_mapping>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2eb1(%rip),%rax
cvtsi2ssq (%rax),%xmm1
mov    %edx,%eax
cvtsi2ss %rax,%xmm2
mov    %esi,%ebp
mov    %rdi,%r14
movss  0xeb8(%rip),%xmm0
divss  %xmm2,%xmm0
mulss  %xmm1,%xmm0
call   1040 <expf@plt>
movss  %xmm0,0x8(%rsp)
cmp    $0x2,%ebp
jb     119a <gen_logscale_mapping+0x7a>
mov    %ebp,%ebp
mov    $0x1,%ebx
movss  0x8(%rsp),%xmm0
nopl   (%rax)
movss  %xmm0,0xc(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <lrintf@plt>
movss  0xc(%rsp),%xmm0
mov    %eax,(%r14,%rbx,4)
mulss  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <gen_logscale_mapping+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@M_LN10 = global i64 0
define void @gen_logscale_mapping(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = load i64, i64* @M_LN10
%5 = sitofp i64 %4 to float
%6 = uitofp i32 %2 to float
%7 = fdiv float 1.000000e+00, %6
%8 = fmul float %7, %5
%9 = tail call float @expf(float %8)
%10 = icmp ugt i32 %1, 1
br i1 %10, label %11, label %21
11: ; preds = %3
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 1, %11 ], [ %19, %13 ]
%15 = phi float [ %9, %11 ], [ %18, %13 ]
%16 = tail call i32 @lrintf(float %15)
%17 = getelementptr inbounds i32, i32* %0, i64 %14
store i32 %16, i32* %17
%18 = fmul float %9, %15
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %12
br i1 %20, label %21, label %13
21: ; preds = %13, %3
ret void
}