#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*/ CSPL_Array_scale(double *, int /*<<< orphan*/,
                                    int /*<<< orphan*/, long const);
int /*<<< orphan*/ log10(double const);
double pow(int, double);
void CSPL_Array_logscale(double *inval, const double min, const double max,
                         const long n) {
  long i;
  CSPL_Array_scale(inval, log10(min), log10(max), n);
  for (i = 0; i < n; i++)
    inval[i] = pow(10, inval[i]);
}


x86 assembly (clang, -O0):
<CSPL_Array_logscale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <log10@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <log10@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
call   1030 <CSPL_Array_scale@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11c6 <CSPL_Array_logscale+0x96>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1183 <CSPL_Array_logscale+0x53>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CSPL_Array_logscale>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movsd  %xmm1,(%rsp)
mov    %rdi,%rbx
call   1050 <log10@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
call   1050 <log10@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
mov    %r14,%rcx
call   1030 <CSPL_Array_scale@plt>
test   %r14,%r14
jle    121d <CSPL_Array_logscale+0xed>
lea    -0x1(%r14),%rax
mov    %r14d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
jae    1180 <CSPL_Array_logscale+0x50>
xor    %ebp,%ebp
jmp    11ef <CSPL_Array_logscale+0xbf>
and    $0xfffffffffffffffc,%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsd  (%rbx,%rbp,8),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rbx,%rbp,8)
movsd  0x8(%rbx,%rbp,8),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rbx,%rbp,8)
movsd  0x10(%rbx,%rbp,8),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x10(%rbx,%rbp,8)
movsd  0x18(%rbx,%rbp,8),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x18(%rbx,%rbp,8)
add    $0x4,%rbp
cmp    %rbp,%r14
jne    1190 <CSPL_Array_logscale+0x60>
test   %r15,%r15
je     121d <CSPL_Array_logscale+0xed>
lea    (%rbx,%rbp,8),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rbp,8),%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1200 <CSPL_Array_logscale+0xd0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @CSPL_Array_logscale(double* %0, double %1, double %2, i64 %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca i64
%9 = alloca i64
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store i64 %3, i64* %8
%10 = load double*, double** %5
%11 = load double, double* %6
%12 = call i32 @log10(double %11)
%13 = load double, double* %7
%14 = call i32 @log10(double %13)
%15 = load i64, i64* %8
%16 = call i32 @CSPL_Array_scale(double* %10, i32 %12, i32 %14, i64 %15)
store i64 0, i64* %9
br label %17
17: ; preds = %30, %4
%18 = load i64, i64* %9
%19 = load i64, i64* %8
%20 = icmp slt i64 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load double*, double** %5
%23 = load i64, i64* %9
%24 = getelementptr inbounds double, double* %22, i64 %23
%25 = load double, double* %24
%26 = call double @pow(i32 10, double %25)
%27 = load double*, double** %5
%28 = load i64, i64* %9
%29 = getelementptr inbounds double, double* %27, i64 %28
store double %26, double* %29
br label %30
30: ; preds = %21
%31 = load i64, i64* %9
%32 = add nsw i64 %31, 1
store i64 %32, i64* %9
br label %17
33: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @CSPL_Array_logscale(double* %0, double %1, double %2, i64 %3) {
%5 = tail call i32 @log10(double %1)
%6 = tail call i32 @log10(double %2)
%7 = tail call i32 @CSPL_Array_scale(double* %0, i32 %5, i32 %6, i64 %3)
%8 = icmp sgt i64 %3, 0
br i1 %8, label %9, label %48
9: ; preds = %4
%10 = add i64 %3, -1
%11 = and i64 %3, 3
%12 = icmp ult i64 %10, 3
br i1 %12, label %36, label %13
13: ; preds = %9
%14 = and i64 %3, -4
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %33, %15 ]
%17 = phi i64 [ 0, %13 ], [ %34, %15 ]
%18 = getelementptr inbounds double, double* %0, i64 %16
%19 = load double, double* %18
%20 = tail call double @pow(i32 10, double %19)
store double %20, double* %18
%21 = or i64 %16, 1
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = tail call double @pow(i32 10, double %23)
store double %24, double* %22
%25 = or i64 %16, 2
%26 = getelementptr inbounds double, double* %0, i64 %25
%27 = load double, double* %26
%28 = tail call double @pow(i32 10, double %27)
store double %28, double* %26
%29 = or i64 %16, 3
%30 = getelementptr inbounds double, double* %0, i64 %29
%31 = load double, double* %30
%32 = tail call double @pow(i32 10, double %31)
store double %32, double* %30
%33 = add nuw nsw i64 %16, 4
%34 = add i64 %17, 4
%35 = icmp eq i64 %34, %14
br i1 %35, label %36, label %15
36: ; preds = %15, %9
%37 = phi i64 [ 0, %9 ], [ %33, %15 ]
%38 = icmp eq i64 %11, 0
br i1 %38, label %48, label %39
39: ; preds = %36, %39
%40 = phi i64 [ %45, %39 ], [ %37, %36 ]
%41 = phi i64 [ %46, %39 ], [ 0, %36 ]
%42 = getelementptr inbounds double, double* %0, i64 %40
%43 = load double, double* %42
%44 = tail call double @pow(i32 10, double %43)
store double %44, double* %42
%45 = add nuw nsw i64 %40, 1
%46 = add i64 %41, 1
%47 = icmp eq i64 %46, %11
br i1 %47, label %48, label %39
48: ; preds = %36, %39, %4
ret void
}