#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 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;
  if (pow((float)r + 1, dim) <= entries)
    return -1;
  if ((int)floor(pow((float)r, dim)) > entries)
    return -1;
  return r;
}


x86 assembly (clang, -O0):
<lookup1_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
call   1040 <log@plt>
cvtsi2ss %rax,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
call   1030 <exp@plt>
mov    %eax,%edi
call   1060 <floor@plt>
mov    %eax,-0x10(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
movss  0xe7e(%rip),%xmm1
addss  %xmm1,%xmm0
mov    -0xc(%rbp),%edi
call   1050 <pow@plt>
mov    %eax,%edi
call   1060 <floor@plt>
cmp    -0x8(%rbp),%eax
jg     11a7 <lookup1_values+0x67>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
movss  0xe4c(%rip),%xmm1
addss  %xmm1,%xmm0
mov    -0xc(%rbp),%edi
call   1050 <pow@plt>
cmp    -0x8(%rbp),%eax
jg     11d5 <lookup1_values+0x95>
movl   $0xffffffff,-0x4(%rbp)
jmp    1204 <lookup1_values+0xc4>
cvtsi2ssl -0x10(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1050 <pow@plt>
mov    %eax,%edi
call   1060 <floor@plt>
cmp    -0x8(%rbp),%eax
jle    11fe <lookup1_values+0xbe>
movl   $0xffffffff,-0x4(%rbp)
jmp    1204 <lookup1_values+0xc4>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%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   1040 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtsi2ss %r15d,%xmm1
divss  %xmm1,%xmm0
call   1030 <exp@plt>
mov    %eax,%edi
call   1060 <floor@plt>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
addss  0xe7b(%rip),%xmm0
mov    %r15d,%edi
call   1050 <pow@plt>
mov    %eax,%edi
call   1060 <floor@plt>
xor    %ebp,%ebp
cmp    %r14d,%eax
setle  %bpl
add    %ebx,%ebp
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
movss  0xe52(%rip),%xmm0
movss  %xmm1,0x4(%rsp)
addss  %xmm1,%xmm0
mov    %r15d,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %r14d,%ecx
jle    11ee <lookup1_values+0xae>
movss  0x4(%rsp),%xmm0
mov    %r15d,%edi
call   1050 <pow@plt>
mov    %eax,%edi
call   1060 <floor@plt>
cmp    %r14d,%eax
mov    $0xffffffff,%eax
cmovg  %eax,%ebp
mov    %ebp,%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
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = sitofp i32 %7 to float
%9 = call i64 @log(float %8)
%10 = sitofp i64 %9 to float
%11 = load i32, i32* %5
%12 = sitofp i32 %11 to float
%13 = fdiv float %10, %12
%14 = call i32 @exp(float %13)
%15 = call i64 @floor(i32 %14)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = sitofp i32 %17 to float
%19 = fadd float %18, 1.000000e+00
%20 = load i32, i32* %5
%21 = call i32 @pow(float %19, i32 %20)
%22 = call i64 @floor(i32 %21)
%23 = trunc i64 %22 to i32
%24 = load i32, i32* %4
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %29
29: ; preds = %26, %2
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to float
%32 = fadd float %31, 1.000000e+00
%33 = load i32, i32* %5
%34 = call i32 @pow(float %32, i32 %33)
%35 = load i32, i32* %4
%36 = icmp sle i32 %34, %35
br i1 %36, label %37, label %38
37: ; preds = %29
store i32 -1, i32* %3
br label %50
38: ; preds = %29
%39 = load i32, i32* %6
%40 = sitofp i32 %39 to float
%41 = load i32, i32* %5
%42 = call i32 @pow(float %40, i32 %41)
%43 = call i64 @floor(i32 %42)
%44 = trunc i64 %43 to i32
%45 = load i32, i32* %4
%46 = icmp sgt i32 %44, %45
br i1 %46, label %47, label %48
47: ; preds = %38
store i32 -1, i32* %3
br label %50
48: ; preds = %38
%49 = load i32, i32* %6
store i32 %49, i32* %3
br label %50
50: ; preds = %48, %47, %37
%51 = load i32, i32* %3
ret i32 %51
}

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
br i1 %22, label %23, label %29
23: ; preds = %2
%24 = tail call i32 @pow(float %19, i32 %1)
%25 = tail call i64 @floor(i32 %24)
%26 = trunc i64 %25 to i32
%27 = icmp sgt i32 %26, %0
%28 = select i1 %27, i32 -1, i32 %18
br label %29
29: ; preds = %23, %2
%30 = phi i32 [ -1, %2 ], [ %28, %23 ]
ret i32 %30
}