#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 exp(double const);
int logx2s(double crval, int nx, int sx, int slogc, const double x[],
           double logc[], int stat[]) {
  register int ix;
  register int *statp;
  register const double *xp;
  register double *logcp;
  if (crval <= 0.0) {
    return 2;
  }
  xp = x;
  logcp = logc;
  statp = stat;
  for (ix = 0; ix < nx; ix++, xp += sx, logcp += slogc) {
    *logcp = crval * exp((*xp) / crval);
    *(statp++) = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<logx2s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     114c <logx2s+0x3c>
movl   $0x2,-0x4(%rbp)
jmp    11fb <logx2s+0xeb>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f4 <logx2s+0xe4>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x50(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x48(%rbp)
movl   $0x0,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
jmp    116b <logx2s+0x5b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logx2s>:
movapd %xmm0,%xmm1
mov    $0x2,%eax
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    11b6 <logx2s+0xa6>
test   %edi,%edi
jle    11b7 <logx2s+0xa7>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r13
mov    %r8,%r15
mov    %rcx,%rbx
movslq %esi,%rbp
movslq %edx,%rax
shl    $0x3,%rax
mov    %rax,0x8(%rsp)
shl    $0x3,%rbp
mov    %edi,%r12d
xor    %r14d,%r14d
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rbx),%xmm0
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
movl   $0x0,0x0(%r13,%r14,4)
add    0x8(%rsp),%r15
add    %rbp,%rbx
add    $0x1,%r14
cmp    %r14d,%r12d
jne    1170 <logx2s+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @logx2s(double %0, i32 %1, i32 %2, i32 %3, double* %4, double* %5, i32* %6) {
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32*
%18 = alloca double*
%19 = alloca double*
store double %0, double* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store double* %4, double** %13
store double* %5, double** %14
store i32* %6, i32** %15
%20 = load double, double* %9
%21 = fcmp ole double %20, 0.000000e+00
br i1 %21, label %22, label %23
22: ; preds = %7
store i32 2, i32* %8
br label %54
23: ; preds = %7
%24 = load double*, double** %13
store double* %24, double** %18
%25 = load double*, double** %14
store double* %25, double** %19
%26 = load i32*, i32** %15
store i32* %26, i32** %17
store i32 0, i32* %16
br label %27
27: ; preds = %42, %23
%28 = load i32, i32* %16
%29 = load i32, i32* %10
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %53
31: ; preds = %27
%32 = load double, double* %9
%33 = load double*, double** %18
%34 = load double, double* %33
%35 = load double, double* %9
%36 = fdiv double %34, %35
%37 = call double @exp(double %36)
%38 = fmul double %32, %37
%39 = load double*, double** %19
store double %38, double* %39
%40 = load i32*, i32** %17
%41 = getelementptr inbounds i32, i32* %40, i32 1
store i32* %41, i32** %17
store i32 0, i32* %40
br label %42
42: ; preds = %31
%43 = load i32, i32* %16
%44 = add nsw i32 %43, 1
store i32 %44, i32* %16
%45 = load i32, i32* %11
%46 = load double*, double** %18
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds double, double* %46, i64 %47
store double* %48, double** %18
%49 = load i32, i32* %12
%50 = load double*, double** %19
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds double, double* %50, i64 %51
store double* %52, double** %19
br label %27
53: ; preds = %27
store i32 0, i32* %8
br label %54
54: ; preds = %53, %22
%55 = load i32, i32* %8
ret i32 %55
}

LLVM IR (-O2):
define i32 @logx2s(double %0, i32 %1, i32 %2, i32 %3, double* nocapture %4, double* nocapture writeonly %5, i32* nocapture writeonly %6) {
%8 = fcmp ugt double %0, 0.000000e+00
br i1 %8, label %9, label %28
9: ; preds = %7
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %28
11: ; preds = %9
%12 = sext i32 %2 to i64
%13 = sext i32 %3 to i64
br label %14
14: ; preds = %11, %14
%15 = phi double* [ %5, %11 ], [ %26, %14 ]
%16 = phi double* [ %4, %11 ], [ %25, %14 ]
%17 = phi i32* [ %6, %11 ], [ %23, %14 ]
%18 = phi i32 [ 0, %11 ], [ %24, %14 ]
%19 = load double, double* %16
%20 = fdiv double %19, %0
%21 = tail call double @exp(double %20)
%22 = fmul double %21, %0
store double %22, double* %15
%23 = getelementptr inbounds i32, i32* %17, i64 1
store i32 0, i32* %17
%24 = add nuw nsw i32 %18, 1
%25 = getelementptr inbounds double, double* %16, i64 %12
%26 = getelementptr inbounds double, double* %15, i64 %13
%27 = icmp eq i32 %24, %1
br i1 %27, label %28, label %14
28: ; preds = %14, %9, %7
%29 = phi i32 [ 2, %7 ], [ 0, %9 ], [ 0, %14 ]
ret i32 %29
}