#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 /*<<< orphan*/ assert(int);
int exp(float);
scalar_t__ floor(int);
scalar_t__ log(float);
int pow(float, int);
int lookup1_values(int entries, int dim) {
  int r = (int)floor(exp((float)log((float)entries) / dim));
  if ((int)floor(pow((float)r + 1, dim)) <= entries)
    ++r;
  assert(pow((float)r + 1, dim) > entries);
  assert((int)floor(pow((float)r, dim)) <= entries);
  return r;
}


x86 assembly (clang, -O0):
<lookup1_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
call   1050 <log@plt>
cvtsi2ss %rax,%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
call   1040 <exp@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  0xe6e(%rip),%xmm1
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%edi
call   1060 <pow@plt>
mov    %eax,%edi
call   1070 <floor@plt>
cmp    -0x4(%rbp),%eax
jg     11b7 <lookup1_values+0x67>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  0xe3c(%rip),%xmm1
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%edi
call   1060 <pow@plt>
cmp    -0x4(%rbp),%eax
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cvtsi2ssl -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%edi
call   1060 <pow@plt>
mov    %eax,%edi
call   1070 <floor@plt>
cmp    -0x4(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup1_values>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
cvtsi2ss %edi,%xmm0
call   1050 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtsi2ss %r15d,%xmm1
divss  %xmm1,%xmm0
call   1040 <exp@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    %rax,%rbp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
addss  0xe6b(%rip),%xmm0
mov    %r15d,%edi
call   1060 <pow@plt>
mov    %eax,%edi
call   1070 <floor@plt>
xor    %ebx,%ebx
cmp    %r14d,%eax
setle  %bl
add    %ebp,%ebx
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0xe3d(%rip),%xmm0
addss  %xmm1,%xmm0
mov    %r15d,%edi
call   1060 <pow@plt>
xor    %edi,%edi
cmp    %r14d,%eax
setg   %dil
call   1030 <assert@plt>
movss  0x4(%rsp),%xmm0
mov    %r15d,%edi
call   1060 <pow@plt>
mov    %eax,%edi
call   1070 <floor@plt>
xor    %edi,%edi
cmp    %r14d,%eax
setle  %dil
call   1030 <assert@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lookup1_values(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = sitofp i32 %6 to float
%8 = call i64 @log(float %7)
%9 = sitofp i64 %8 to float
%10 = load i32, i32* %4
%11 = sitofp i32 %10 to float
%12 = fdiv float %9, %11
%13 = call i32 @exp(float %12)
%14 = call i64 @floor(i32 %13)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to float
%18 = fadd float %17, 1.000000e+00
%19 = load i32, i32* %4
%20 = call i32 @pow(float %18, i32 %19)
%21 = call i64 @floor(i32 %20)
%22 = trunc i64 %21 to i32
%23 = load i32, i32* %3
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %28
28: ; preds = %25, %2
%29 = load i32, i32* %5
%30 = sitofp i32 %29 to float
%31 = fadd float %30, 1.000000e+00
%32 = load i32, i32* %4
%33 = call i32 @pow(float %31, i32 %32)
%34 = load i32, i32* %3
%35 = icmp sgt i32 %33, %34
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %5
%39 = sitofp i32 %38 to float
%40 = load i32, i32* %4
%41 = call i32 @pow(float %39, i32 %40)
%42 = call i64 @floor(i32 %41)
%43 = trunc i64 %42 to i32
%44 = load i32, i32* %3
%45 = icmp sle i32 %43, %44
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i32, i32* %5
ret i32 %48
}

LLVM IR (-O2):
define i32 @lookup1_values(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to float
%4 = tail call i64 @log(float %3)
%5 = sitofp i64 %4 to float
%6 = sitofp i32 %1 to float
%7 = fdiv float %5, %6
%8 = tail call i32 @exp(float %7)
%9 = tail call i64 @floor(i32 %8)
%10 = trunc i64 %9 to i32
%11 = sitofp i32 %10 to float
%12 = fadd float %11, 1.000000e+00
%13 = tail call i32 @pow(float %12, i32 %1)
%14 = tail call i64 @floor(i32 %13)
%15 = trunc i64 %14 to i32
%16 = icmp sle i32 %15, %0
%17 = zext i1 %16 to i32
%18 = add nsw i32 %17, %10
%19 = sitofp i32 %18 to float
%20 = fadd float %19, 1.000000e+00
%21 = tail call i32 @pow(float %20, i32 %1)
%22 = icmp sgt i32 %21, %0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i32 @pow(float %19, i32 %1)
%26 = tail call i64 @floor(i32 %25)
%27 = trunc i64 %26 to i32
%28 = icmp sle i32 %27, %0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
ret i32 %18
}