int speclog(dummy, nspec, sspec, sloge, spec, loge, stat)
double dummy;
int nspec, sspec, sloge;
const double spec[];
double loge[];
int stat[];
{
  int status = 0;
  register int ispec, *statp;
  register const double *specp;
  register double *logep;
  specp = spec;
  logep = loge;
  statp = stat;
  for (ispec = 0; ispec < nspec; ispec++) {
    if (*specp > 0.0) {
      *logep = log(*specp);
      *(statp++) = 0;
    } else {
      *(statp++) = 1;
      status = 4;
    }
    specp += sspec;
    logep += sloge;
  }
  return status;
}


x86 assembly (clang, -O0):
<speclog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fc <speclog+0xec>
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a8 <speclog+0x98>
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <log@plt>
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x40(%rbp)
movl   $0x0,(%rax)
jmp    11c4 <speclog+0xb4>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x40(%rbp)
movl   $0x1,(%rax)
movl   $0x4,-0x34(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1158 <speclog+0x48>
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speclog>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    11a2 <speclog+0x92>
mov    %r9,%r13
mov    %r8,%r15
mov    %rcx,%rbx
movslq %esi,%rbp
movslq %edx,%rdx
shl    $0x3,%rdx
shl    $0x3,%rbp
mov    %edi,%r12d
xor    %r14d,%r14d
xorpd  %xmm1,%xmm1
movl   $0x0,0xc(%rsp)
mov    %rdx,0x10(%rsp)
jmp    1189 <speclog+0x79>
cs nopw 0x0(%rax,%rax,1)
call   1030 <log@plt>
xorpd  %xmm1,%xmm1
mov    0x10(%rsp),%rdx
movsd  %xmm0,(%r15)
xor    %eax,%eax
mov    %eax,0x0(%r13,%r14,4)
add    %rdx,%r15
add    %rbp,%rbx
add    $0x1,%r14
cmp    %r14d,%r12d
je     11aa <speclog+0x9a>
movsd  (%rbx),%xmm0
ucomisd %xmm1,%xmm0
ja     1160 <speclog+0x50>
movl   $0x4,0xc(%rsp)
mov    $0x1,%eax
jmp    1175 <speclog+0x65>
movl   $0x0,0xc(%rsp)
mov    0xc(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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