void remove_dc_component(double *data, int n, double meanvalue, double stdev) {
  int j;
  for (j = 0; j < n; j++) {
    data[j] = ((data[j] - meanvalue));
  }
}


x86 assembly (clang, -O0):
<remove_dc_component>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1155 <remove_dc_component+0x55>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111c <remove_dc_component+0x1c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_dc_component>:
test   %esi,%esi
jle    11e7 <remove_dc_component+0xe7>
mov    %esi,%eax
cmp    $0x4,%esi
jae    1116 <remove_dc_component+0x16>
xor    %ecx,%ecx
jmp    11d0 <remove_dc_component+0xd0>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rcx),%rdx
mov    %rdx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rdx,%rdx
je     11e8 <remove_dc_component+0xe8>
mov    %r8,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%rdi,%rdx,8),%xmm2
movupd 0x10(%rdi,%rdx,8),%xmm3
movupd 0x20(%rdi,%rdx,8),%xmm4
movupd 0x30(%rdi,%rdx,8),%xmm5
subpd  %xmm1,%xmm2
subpd  %xmm1,%xmm3
movupd %xmm2,(%rdi,%rdx,8)
movupd %xmm3,0x10(%rdi,%rdx,8)
subpd  %xmm1,%xmm4
subpd  %xmm1,%xmm5
movupd %xmm4,0x20(%rdi,%rdx,8)
movupd %xmm5,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rsi
jne    1150 <remove_dc_component+0x50>
test   $0x1,%r8b
je     11bc <remove_dc_component+0xbc>
movupd (%rdi,%rdx,8),%xmm2
movupd 0x10(%rdi,%rdx,8),%xmm3
subpd  %xmm1,%xmm2
subpd  %xmm1,%xmm3
movupd %xmm2,(%rdi,%rdx,8)
movupd %xmm3,0x10(%rdi,%rdx,8)
cmp    %rax,%rcx
je     11e7 <remove_dc_component+0xe7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rdi,%rcx,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11d0 <remove_dc_component+0xd0>
ret
xor    %edx,%edx
test   $0x1,%r8b
jne    119e <remove_dc_component+0x9e>
jmp    11bc <remove_dc_component+0xbc>

LLVM IR (-O0):
define void @remove_dc_component(double* %0, i32 %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store double %3, double* %8
store i32 0, i32* %9
br label %10
10: ; preds = %26, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
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 = fsub double %19, %20
%22 = load double*, double** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
store double %21, double* %25
br label %26
26: ; preds = %14
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %10
29: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @remove_dc_component(double* nocapture %0, i32 %1, double %2, double %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %74
6: ; preds = %4
%7 = zext i32 %1 to i64
%8 = icmp ult i32 %1, 4
br i1 %8, label %65, label %9
9: ; preds = %6
%10 = and i64 %7, 4294967292
%11 = insertelement <2 x double> poison, double %2, i64 0
%12 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> zeroinitializer
%13 = insertelement <2 x double> poison, double %2, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = add nsw i64 %10, -4
%16 = lshr exact i64 %15, 2
%17 = add nuw nsw i64 %16, 1
%18 = and i64 %17, 1
%19 = icmp eq i64 %15, 0
br i1 %19, label %49, label %20
20: ; preds = %9
%21 = and i64 %17, 9223372036854775806
br label %22
22: ; preds = %22, %20
%23 = phi i64 [ 0, %20 ], [ %46, %22 ]
%24 = phi i64 [ 0, %20 ], [ %47, %22 ]
%25 = getelementptr inbounds double, double* %0, i64 %23
%26 = bitcast double* %25 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = getelementptr inbounds double, double* %25, i64 2
%29 = bitcast double* %28 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = fsub <2 x double> %27, %12
%32 = fsub <2 x double> %30, %14
%33 = bitcast double* %25 to <2 x double>*
store <2 x double> %31, <2 x double>* %33
%34 = bitcast double* %28 to <2 x double>*
store <2 x double> %32, <2 x double>* %34
%35 = or i64 %23, 4
%36 = getelementptr inbounds double, double* %0, i64 %35
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = getelementptr inbounds double, double* %36, i64 2
%40 = bitcast double* %39 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = fsub <2 x double> %38, %12
%43 = fsub <2 x double> %41, %14
%44 = bitcast double* %36 to <2 x double>*
store <2 x double> %42, <2 x double>* %44
%45 = bitcast double* %39 to <2 x double>*
store <2 x double> %43, <2 x double>* %45
%46 = add nuw i64 %23, 8
%47 = add i64 %24, 2
%48 = icmp eq i64 %47, %21
br i1 %48, label %49, label %22
49: ; preds = %22, %9
%50 = phi i64 [ 0, %9 ], [ %46, %22 ]
%51 = icmp eq i64 %18, 0
br i1 %51, label %63, label %52
52: ; preds = %49
%53 = getelementptr inbounds double, double* %0, i64 %50
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %53, i64 2
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = fsub <2 x double> %55, %12
%60 = fsub <2 x double> %58, %14
%61 = bitcast double* %53 to <2 x double>*
store <2 x double> %59, <2 x double>* %61
%62 = bitcast double* %56 to <2 x double>*
store <2 x double> %60, <2 x double>* %62
br label %63
63: ; preds = %49, %52
%64 = icmp eq i64 %10, %7
br i1 %64, label %74, label %65
65: ; preds = %6, %63
%66 = phi i64 [ 0, %6 ], [ %10, %63 ]
br label %67
67: ; preds = %65, %67
%68 = phi i64 [ %72, %67 ], [ %66, %65 ]
%69 = getelementptr inbounds double, double* %0, i64 %68
%70 = load double, double* %69
%71 = fsub double %70, %2
store double %71, double* %69
%72 = add nuw nsw i64 %68, 1
%73 = icmp eq i64 %72, %7
br i1 %73, label %74, label %67
74: ; preds = %67, %63, %4
ret void
}