#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 */
double log10(double);
double pow(int, double);
void nicelog_new(double llimit, double ulimit, int max, double *val,
                 int *nret) {
  int i, j, nexp, imin, imax;
  imin = log10(llimit) - .5;
  imax = log10(ulimit) + .5;
  nexp = imax - imin + 1;
  if (nexp > max) {
    j = nexp - max;
    imin = imin + j;
    nexp = max;
  }
  for (i = 0; i < nexp; i++) {
    val[i] = pow(10., (double)(imin + i));
  }
  *nret = nexp;
}


x86 assembly (clang, -O0):
<nicelog_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <log10@plt>
movsd  0xeb1(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <log10@plt>
movsd  0xe94(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
sub    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11a7 <nicelog_new+0x87>
mov    -0x34(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x38(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11e9 <nicelog_new+0xc9>
mov    -0x38(%rbp),%eax
add    -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ae <nicelog_new+0x8e>
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nicelog_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%r12d
movsd  %xmm1,0x8(%rsp)
call   1040 <log10@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <log10@plt>
unpcklpd 0x10(%rsp),%xmm0
addpd  0xea0(%rip),%xmm0
cvttpd2dq %xmm0,%xmm0
movd   %xmm0,%ecx
pshufd $0x55,%xmm0,%xmm0
movd   %xmm0,%eax
sub    %eax,%ecx
lea    0x1(%rcx),%esi
mov    %esi,%edx
sub    %r12d,%edx
xor    %r13d,%r13d
cmp    %r12d,%ecx
cmovge %r12d,%esi
cmovge %edx,%r13d
mov    %esi,0x8(%rsp)
test   %esi,%esi
jle    1294 <nicelog_new+0x174>
mov    %r15,0x10(%rsp)
add    %eax,%r13d
mov    0x8(%rsp),%ebp
lea    -0x1(%rbp),%rax
mov    %ebp,%r12d
and    $0x3,%r12d
cmp    $0x3,%rax
jae    11ba <nicelog_new+0x9a>
xor    %r14d,%r14d
jmp    1255 <nicelog_new+0x135>
and    $0xfffffffc,%ebp
mov    %r13d,%r15d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r15,%r14,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movsd  %xmm0,(%rbx,%r14,8)
lea    (%r15,%r14,1),%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movsd  %xmm0,0x8(%rbx,%r14,8)
lea    (%r15,%r14,1),%eax
add    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movsd  %xmm0,0x10(%rbx,%r14,8)
lea    (%r15,%r14,1),%eax
add    $0x3,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movsd  %xmm0,0x18(%rbx,%r14,8)
add    $0x4,%r14
cmp    %r14,%rbp
jne    11d0 <nicelog_new+0xb0>
test   %r12,%r12
mov    0x10(%rsp),%r15
je     1294 <nicelog_new+0x174>
lea    (%rbx,%r14,8),%rbx
add    %r14d,%r13d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
lea    0x0(%r13,%rbp,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1270 <nicelog_new+0x150>
mov    0x8(%rsp),%eax
mov    %eax,(%r15)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @nicelog_new(double %0, double %1, i32 %2, double* %3, i32* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store double %0, double* %6
store double %1, double* %7
store i32 %2, i32* %8
store double* %3, double** %9
store i32* %4, i32** %10
%16 = load double, double* %6
%17 = call double @log10(double %16)
%18 = fsub double %17, 5.000000e-01
%19 = fptosi double %18 to i32
store i32 %19, i32* %14
%20 = load double, double* %7
%21 = call double @log10(double %20)
%22 = fadd double %21, 5.000000e-01
%23 = fptosi double %22 to i32
store i32 %23, i32* %15
%24 = load i32, i32* %15
%25 = load i32, i32* %14
%26 = sub nsw i32 %24, %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %13
%28 = load i32, i32* %13
%29 = load i32, i32* %8
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %5
%32 = load i32, i32* %13
%33 = load i32, i32* %8
%34 = sub nsw i32 %32, %33
store i32 %34, i32* %12
%35 = load i32, i32* %14
%36 = load i32, i32* %12
%37 = add nsw i32 %35, %36
store i32 %37, i32* %14
%38 = load i32, i32* %8
store i32 %38, i32* %13
br label %39
39: ; preds = %31, %5
store i32 0, i32* %11
br label %40
40: ; preds = %54, %39
%41 = load i32, i32* %11
%42 = load i32, i32* %13
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %57
44: ; preds = %40
%45 = load i32, i32* %14
%46 = load i32, i32* %11
%47 = add nsw i32 %45, %46
%48 = sitofp i32 %47 to double
%49 = call double @pow(i32 10, double %48)
%50 = load double*, double** %9
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
store double %49, double* %53
br label %54
54: ; preds = %44
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
br label %40
57: ; preds = %40
%58 = load i32, i32* %13
%59 = load i32*, i32** %10
store i32 %58, i32* %59
ret void
}

LLVM IR (-O2):
define void @nicelog_new(double %0, double %1, i32 %2, double* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = tail call double @log10(double %0)
%7 = tail call double @log10(double %1)
%8 = insertelement <2 x double> poison, double %7, i64 0
%9 = insertelement <2 x double> %8, double %6, i64 1
%10 = fadd <2 x double> %9, <double 5.000000e-01, double -5.000000e-01>
%11 = fptosi <2 x double> %10 to <2 x i32>
%12 = extractelement <2 x i32> %11, i64 0
%13 = extractelement <2 x i32> %11, i64 1
%14 = sub nsw i32 %12, %13
%15 = add nsw i32 %14, 1
%16 = icmp slt i32 %14, %2
%17 = sub nsw i32 %15, %2
%18 = select i1 %16, i32 %15, i32 %2
%19 = select i1 %16, i32 0, i32 %17
%20 = add nsw i32 %19, %13
%21 = icmp sgt i32 %18, 0
br i1 %21, label %22, label %72
22: ; preds = %5
%23 = zext i32 %18 to i64
%24 = add nsw i64 %23, -1
%25 = and i64 %23, 3
%26 = icmp ult i64 %24, 3
br i1 %26, label %58, label %27
27: ; preds = %22
%28 = and i64 %23, 4294967292
br label %29
29: ; preds = %29, %27
%30 = phi i64 [ 0, %27 ], [ %55, %29 ]
%31 = phi i64 [ 0, %27 ], [ %56, %29 ]
%32 = trunc i64 %30 to i32
%33 = add nsw i32 %20, %32
%34 = sitofp i32 %33 to double
%35 = tail call double @pow(i32 10, double %34)
%36 = getelementptr inbounds double, double* %3, i64 %30
store double %35, double* %36
%37 = or i64 %30, 1
%38 = trunc i64 %37 to i32
%39 = add nsw i32 %20, %38
%40 = sitofp i32 %39 to double
%41 = tail call double @pow(i32 10, double %40)
%42 = getelementptr inbounds double, double* %3, i64 %37
store double %41, double* %42
%43 = or i64 %30, 2
%44 = trunc i64 %43 to i32
%45 = add nsw i32 %20, %44
%46 = sitofp i32 %45 to double
%47 = tail call double @pow(i32 10, double %46)
%48 = getelementptr inbounds double, double* %3, i64 %43
store double %47, double* %48
%49 = or i64 %30, 3
%50 = trunc i64 %49 to i32
%51 = add nsw i32 %20, %50
%52 = sitofp i32 %51 to double
%53 = tail call double @pow(i32 10, double %52)
%54 = getelementptr inbounds double, double* %3, i64 %49
store double %53, double* %54
%55 = add nuw nsw i64 %30, 4
%56 = add i64 %31, 4
%57 = icmp eq i64 %56, %28
br i1 %57, label %58, label %29
58: ; preds = %29, %22
%59 = phi i64 [ 0, %22 ], [ %55, %29 ]
%60 = icmp eq i64 %25, 0
br i1 %60, label %72, label %61
61: ; preds = %58, %61
%62 = phi i64 [ %69, %61 ], [ %59, %58 ]
%63 = phi i64 [ %70, %61 ], [ 0, %58 ]
%64 = trunc i64 %62 to i32
%65 = add nsw i32 %20, %64
%66 = sitofp i32 %65 to double
%67 = tail call double @pow(i32 10, double %66)
%68 = getelementptr inbounds double, double* %3, i64 %62
store double %67, double* %68
%69 = add nuw nsw i64 %62, 1
%70 = add i64 %63, 1
%71 = icmp eq i64 %70, %25
br i1 %71, label %72, label %61
72: ; preds = %58, %61, %5
store i32 %18, i32* %4
ret void
}