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


x86 assembly (clang, -O0):
<dd_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    1172 <dd_abs+0x72>
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)
jmp    1194 <dd_abs+0x94>
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)
pop    %rbp
ret

x86 assembly (clang, -O2):
<dd_abs>:
movsd  (%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    112d <dd_abs+0x2d>
movapd 0xeea(%rip),%xmm1
xorpd  %xmm1,%xmm0
movlpd %xmm0,(%rsi)
movsd  0x8(%rdi),%xmm0
xorpd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsi)
ret
movsd  %xmm0,(%rsi)
movsd  0x8(%rdi),%xmm0
movsd  %xmm0,0x8(%rsi)
ret

LLVM IR (-O0):
define void @dd_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 %22
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
br label %33
22: ; preds = %2
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 0
store double %25, double* %27
%28 = load double*, double** %3
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 1
store double %30, double* %32
br label %33
33: ; preds = %22, %9
ret void
}

LLVM IR (-O2):
define void @dd_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 %10
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
br label %13
10: ; preds = %2
store double %3, double* %1
%11 = getelementptr inbounds double, double* %0, i64 1
%12 = load double, double* %11
br label %13
13: ; preds = %10, %5
%14 = phi double [ %9, %5 ], [ %12, %10 ]
%15 = getelementptr inbounds double, double* %1, i64 1
store double %14, double* %15
ret void
}