void qd_abs(const double *a, double *b) {
  if (a[0] < 0.0) {
    b[0] = -a[0];
    b[1] = -a[1];
    b[2] = -a[2];
    b[3] = -a[3];
  } else {
    b[0] = a[0];
    b[1] = a[1];
    b[2] = a[2];
    b[3] = a[3];
  }
}


x86 assembly (clang, -O0):
<qd_abs>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    11c4 <qd_abs+0xc4>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
jmp    120a <qd_abs+0x10a>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<qd_abs>:
movsd  (%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1149 <qd_abs+0x49>
movapd 0xeea(%rip),%xmm1
xorpd  %xmm1,%xmm0
movlpd %xmm0,(%rsi)
movsd  0x8(%rdi),%xmm0
xorpd  %xmm1,%xmm0
movlpd %xmm0,0x8(%rsi)
movsd  0x10(%rdi),%xmm0
xorpd  %xmm1,%xmm0
movlpd %xmm0,0x10(%rsi)
movsd  0x18(%rdi),%xmm0
xorpd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsi)
ret
movsd  %xmm0,(%rsi)
movsd  0x8(%rdi),%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  0x10(%rdi),%xmm0
movsd  %xmm0,0x10(%rsi)
movsd  0x18(%rdi),%xmm0
movsd  %xmm0,0x18(%rsi)
ret

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

LLVM IR (-O2):
define void @qd_abs(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = fcmp olt double %3, 0.000000e+00
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = fneg double %3
store double %6, double* %1
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = fneg double %8
%10 = getelementptr inbounds double, double* %1, i64 1
store double %9, double* %10
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = fneg double %12
%14 = getelementptr inbounds double, double* %1, i64 2
store double %13, double* %14
%15 = getelementptr inbounds double, double* %0, i64 3
%16 = load double, double* %15
%17 = fneg double %16
br label %27
18: ; preds = %2
store double %3, double* %1
%19 = getelementptr inbounds double, double* %0, i64 1
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %1, i64 1
store double %20, double* %21
%22 = getelementptr inbounds double, double* %0, i64 2
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %1, i64 2
store double %23, double* %24
%25 = getelementptr inbounds double, double* %0, i64 3
%26 = load double, double* %25
br label %27
27: ; preds = %18, %5
%28 = phi double [ %17, %5 ], [ %26, %18 ]
%29 = getelementptr inbounds double, double* %1, i64 3
store double %28, double* %29
ret void
}