void compute_hilbert_transform(double coeffs[], int len) {
  double x;
  int i;
  int h;
  h = (len - 1) / 2;
  coeffs[h] = 0.0;
  for (i = 1; i <= h; i++) {
    if ((i & 1)) {
      x = 1.0 / (double)i;
      coeffs[h + i] = -x;
      coeffs[h - i] = x;
    }
  }
}


x86 assembly (clang, -O0):
<compute_hilbert_transform>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11bc <compute_hilbert_transform+0xbc>
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a9 <compute_hilbert_transform+0xa9>
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xea5(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11ae <compute_hilbert_transform+0xae>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <compute_hilbert_transform+0x33>
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_hilbert_transform>:
lea    -0x1(%rsi),%eax
shr    $0x1f,%eax
add    %esi,%eax
add    $0xffffffff,%eax
sar    %eax
cltq
movq   $0x0,(%rdi,%rax,8)
cmp    $0x3,%esi
jge    111d <compute_hilbert_transform+0x1d>
ret
cmp    $0x2,%eax
mov    $0x1,%esi
cmovge %eax,%esi
add    $0x1,%esi
lea    (%rdi,%rax,8),%rax
add    $0xfffffffffffffff8,%rax
mov    $0x1,%ecx
mov    $0x1,%edx
sub    %rsi,%rdx
movsd  0xeb8(%rip),%xmm0
movapd 0xec0(%rip),%xmm1
mov    %rax,%rsi
jmp    1176 <compute_hilbert_transform+0x76>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xfffffffffffffff8,%rsi
lea    (%rdx,%rcx,1),%rdi
add    $0x1,%rdi
add    $0x1,%rcx
cmp    $0x1,%rdi
je     111c <compute_hilbert_transform+0x1c>
test   $0x1,%cl
je     1160 <compute_hilbert_transform+0x60>
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
movapd %xmm0,%xmm3
divsd  %xmm2,%xmm3
movapd %xmm3,%xmm2
xorpd  %xmm1,%xmm2
movlpd %xmm2,0x8(%rax,%rcx,8)
movsd  %xmm3,(%rsi)
jmp    1160 <compute_hilbert_transform+0x60>

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

LLVM IR (-O2):
define void @compute_hilbert_transform(double* nocapture writeonly %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sdiv i32 %3, 2
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds double, double* %0, i64 %5
store double 0.000000e+00, double* %6
%7 = icmp slt i32 %1, 3
br i1 %7, label %28, label %8
8: ; preds = %2
%9 = call i32 @llvm.smax.i32(i32 %4, i32 1)
%10 = add nuw nsw i32 %9, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %8, %25
%13 = phi i64 [ 1, %8 ], [ %26, %25 ]
%14 = trunc i64 %13 to i32
%15 = and i32 %14, 1
%16 = icmp eq i32 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %12
%18 = sitofp i32 %14 to double
%19 = fdiv double 1.000000e+00, %18
%20 = fneg double %19
%21 = add nsw i64 %13, %5
%22 = getelementptr inbounds double, double* %0, i64 %21
store double %20, double* %22
%23 = sub nsw i64 %5, %13
%24 = getelementptr inbounds double, double* %0, i64 %23
store double %19, double* %24
br label %25
25: ; preds = %12, %17
%26 = add nuw nsw i64 %13, 1
%27 = icmp eq i64 %26, %11
br i1 %27, label %28, label %12
28: ; preds = %25, %2
ret void
}