int ptm_pnm_filter_by_ath(double *ptm, double *pnm, double *psd_ath,
                          int psd_len) {
  int k;
  for (k = 0; k < psd_len; k++) {
    if (ptm[k] < psd_ath[k])
      ptm[k] = 0.;
    if (pnm[k] < psd_ath[k])
      pnm[k] = 0.;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ptm_pnm_filter_by_ath>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a1 <ptm_pnm_filter_by_ath+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    115a <ptm_pnm_filter_by_ath+0x5a>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    118e <ptm_pnm_filter_by_ath+0x8e>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1193 <ptm_pnm_filter_by_ath+0x93>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <ptm_pnm_filter_by_ath+0x1a>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptm_pnm_filter_by_ath>:
test   %ecx,%ecx
jle    1143 <ptm_pnm_filter_by_ath+0x43>
mov    %ecx,%eax
xor    %ecx,%ecx
jmp    1119 <ptm_pnm_filter_by_ath+0x19>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rcx,%rax
je     1143 <ptm_pnm_filter_by_ath+0x43>
movsd  (%rdx,%rcx,8),%xmm0
ucomisd (%rdi,%rcx,8),%xmm0
jbe    1132 <ptm_pnm_filter_by_ath+0x32>
movq   $0x0,(%rdi,%rcx,8)
movsd  (%rdx,%rcx,8),%xmm0
ucomisd (%rsi,%rcx,8),%xmm0
jbe    1110 <ptm_pnm_filter_by_ath+0x10>
movq   $0x0,(%rsi,%rcx,8)
jmp    1110 <ptm_pnm_filter_by_ath+0x10>
xor    %eax,%eax
ret

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

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