void zero_crossings(double *ZC, double *X, const int N) {
  int k;
  int zc = 0;
  double neg;
  if (X[0] < 0.0) {
    neg = 1;
  } else {
    neg = 0;
  }
  for (k = 1; k < N - 1; k++) {
    if (neg && (X[k] > 0.0)) {
      zc++;
      neg = 0;
    } else if (!neg && (X[k] < 0.0)) {
      zc++;
      neg = 1;
    }
  }
}


x86 assembly (clang, -O0):
<zero_crossings>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1139 <zero_crossings+0x39>
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1141 <zero_crossings+0x41>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1202 <zero_crossings+0x102>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1176 <zero_crossings+0x76>
jp     1176 <zero_crossings+0x76>
jmp    11a6 <zero_crossings+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a6 <zero_crossings+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11ef <zero_crossings+0xef>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ea <zero_crossings+0xea>
jp     11ea <zero_crossings+0xea>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    11ea <zero_crossings+0xea>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsd  0xe1b(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11ef <zero_crossings+0xef>
jmp    11f4 <zero_crossings+0xf4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <zero_crossings+0x48>
pop    %rbp
ret

x86 assembly (clang, -O2):
<zero_crossings>:
ret

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

LLVM IR (-O2):
define void @zero_crossings(double* nocapture %0, double* nocapture %1, i32 %2) {
ret void
}