#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 DBL_MAX;
double log(double);
void DLog(double *vec, int n) {
  int x;
  for (x = 0; x < n; x++)
    if (vec[x] > 0.)
      vec[x] = log(vec[x]);
    else
      vec[x] = -DBL_MAX;
}


x86 assembly (clang, -O0):
<DLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b2 <DLog+0xa2>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1170 <DLog+0x60>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <log@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    119f <DLog+0x8f>
mov    0x2e69(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11a4 <DLog+0x94>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <DLog+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DLog>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1174 <DLog+0x64>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
mov    0x2eb1(%rip),%r12
jmp    115d <DLog+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r12),%xmm0
xorpd  0xeb2(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
je     1174 <DLog+0x64>
movsd  (%r15,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1140 <DLog+0x30>
call   1030 <log@plt>
xorpd  %xmm1,%xmm1
jmp    114e <DLog+0x3e>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
define void @DLog(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %36, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %39
10: ; preds = %6
%11 = load double*, double** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = load double, double* %14
%16 = fcmp ogt double %15, 0.000000e+00
br i1 %16, label %17, label %28
17: ; preds = %10
%18 = load double*, double** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = call double @log(double %22)
%24 = load double*, double** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
store double %23, double* %27
br label %35
28: ; preds = %10
%29 = load double, double* @DBL_MAX
%30 = fneg double %29
%31 = load double*, double** %3
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double %30, double* %34
br label %35
35: ; preds = %28, %17
br label %36
36: ; preds = %35
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %6
39: ; preds = %6
ret void
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
define void @DLog(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %16
%7 = phi i64 [ 0, %4 ], [ %18, %16 ]
%8 = getelementptr inbounds double, double* %0, i64 %7
%9 = load double, double* %8
%10 = fcmp ogt double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call double @log(double %9)
br label %16
13: ; preds = %6
%14 = load double, double* @DBL_MAX
%15 = fneg double %14
br label %16
16: ; preds = %11, %13
%17 = phi double [ %15, %13 ], [ %12, %11 ]
store double %17, double* %8
%18 = add nuw nsw i64 %7, 1
%19 = icmp eq i64 %18, %5
br i1 %19, label %20, label %6
20: ; preds = %16, %2
ret void
}