void test_complex_double(_Complex double x) {
  (void)abs(x);
  (void)labs(x);
  (void)llabs(x);
  (void)fabsf(x);
  (void)fabs(x);
  (void)fabsl(x);
  (void)cabsf(x);
  (void)cabs(x);
  (void)cabsl(x);
  (void)__builtin_abs(x);
  (void)__builtin_labs(x);
  (void)__builtin_llabs(x);
  (void)__builtin_fabsf(x);
  (void)__builtin_fabs(x);
  (void)__builtin_fabsl(x);
  (void)__builtin_cabsf(x);
  (void)__builtin_cabs(x);
  (void)__builtin_cabsl(x);
}


x86 assembly (clang, -O0):
<test_complex_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x8(%rbp)
cvttsd2si -0x10(%rbp),%edi
call   1030 <abs@plt>
cvttsd2si -0x10(%rbp),%rdi
call   1040 <labs@plt>
cvttsd2si -0x10(%rbp),%rdi
call   1080 <llabs@plt>
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm1,-0x18(%rbp)
movss  %xmm0,-0x14(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <cabsf@plt>
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1050 <cabs@plt>
fldl   -0x10(%rbp)
fldl   -0x8(%rbp)
fxch   %st(1)
fstpt  -0x50(%rbp)
fstpt  -0x40(%rbp)
movaps -0x50(%rbp),%xmm0
movaps -0x40(%rbp),%xmm1
mov    %rsp,%rax
movaps %xmm1,0x10(%rax)
movaps %xmm0,(%rax)
call   1060 <cabsl@plt>
fstp   %st(0)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm1,-0x58(%rbp)
movss  %xmm0,-0x54(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1070 <cabsf@plt>
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  %xmm1,-0x68(%rbp)
movsd  %xmm0,-0x60(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
call   1050 <cabs@plt>
fldl   -0x10(%rbp)
fldl   -0x8(%rbp)
fxch   %st(1)
fstpt  -0x90(%rbp)
fstpt  -0x80(%rbp)
lea    -0x90(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,(%rsp)
mov    0x8(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    0x10(%rax),%rcx
mov    %rcx,0x10(%rsp)
mov    0x18(%rax),%rax
mov    %rax,0x18(%rsp)
call   1060 <cabsl@plt>
fstp   %st(0)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_complex_double>:
sub    $0xc8,%rsp
movapd %xmm1,0x30(%rsp)
movapd %xmm0,0x60(%rsp)
movsd  %xmm0,0x48(%rsp)
fldl   0x48(%rsp)
fstpt  0x24(%rsp)
movapd %xmm0,%xmm2
unpcklpd %xmm1,%xmm2
cvtpd2ps %xmm2,%xmm0
movapd %xmm0,0x70(%rsp)
call   1050 <cabsf@plt>
movaps 0x60(%rsp),%xmm0
movaps 0x30(%rsp),%xmm1
call   1030 <cabs@plt>
movaps 0x30(%rsp),%xmm0
movsd  %xmm0,0x40(%rsp)
fldl   0x40(%rsp)
fld    %st(0)
fstpt  0x54(%rsp)
fldt   0x24(%rsp)
fstpt  0xa0(%rsp)
fstpt  0xb0(%rsp)
movaps 0xa0(%rsp),%xmm0
movaps 0xb0(%rsp),%xmm1
movaps %xmm1,0x10(%rsp)
movaps %xmm0,(%rsp)
call   1040 <cabsl@plt>
fstp   %st(0)
movaps 0x70(%rsp),%xmm0
call   1050 <cabsf@plt>
movaps 0x60(%rsp),%xmm0
movaps 0x30(%rsp),%xmm1
call   1030 <cabs@plt>
fldt   0x24(%rsp)
fstpt  0x80(%rsp)
fldt   0x54(%rsp)
fstpt  0x90(%rsp)
movaps 0x80(%rsp),%xmm0
movaps 0x90(%rsp),%xmm1
movaps %xmm1,0x10(%rsp)
movaps %xmm0,(%rsp)
call   1040 <cabsl@plt>
fstp   %st(0)
add    $0xc8,%rsp
ret

LLVM IR (-O0):
define void @test_complex_double(double %0, double %1) {
%3 = alloca { double, double }
%4 = alloca { float, float }
%5 = alloca { double, double }
%6 = alloca { x86_fp80, x86_fp80 }
%7 = alloca { float, float }
%8 = alloca { double, double }
%9 = alloca { x86_fp80, x86_fp80 }
%10 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
store double %0, double* %10
%11 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
store double %1, double* %11
%12 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%13 = load double, double* %12
%14 = fptosi double %13 to i32
%15 = call i32 @abs(i32 %14)
%16 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%17 = load double, double* %16
%18 = fptosi double %17 to i64
%19 = call i64 @labs(i64 %18)
%20 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%21 = load double, double* %20
%22 = fptosi double %21 to i64
%23 = call i64 @llabs(i64 %22)
%24 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%25 = load double, double* %24
%26 = fptrunc double %25 to float
%27 = call float @llvm.fabs.f32(float %26)
%28 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%29 = load double, double* %28
%30 = call double @llvm.fabs.f64(double %29)
%31 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%32 = load double, double* %31
%33 = fpext double %32 to x86_fp80
%34 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %33)
%35 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%36 = load double, double* %35
%37 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%38 = load double, double* %37
%39 = fptrunc double %36 to float
%40 = fptrunc double %38 to float
%41 = getelementptr inbounds { float, float }, { float, float }* %4, i32 0, i32 0
%42 = getelementptr inbounds { float, float }, { float, float }* %4, i32 0, i32 1
store float %39, float* %41
store float %40, float* %42
%43 = bitcast { float, float }* %4 to <2 x float>*
%44 = load <2 x float>, <2 x float>* %43
%45 = call float @cabsf(<2 x float> %44)
%46 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%47 = load double, double* %46
%48 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%49 = load double, double* %48
%50 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0
%51 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1
store double %47, double* %50
store double %49, double* %51
%52 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0
%53 = load double, double* %52
%54 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1
%55 = load double, double* %54
%56 = call double @cabs(double %53, double %55)
%57 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%58 = load double, double* %57
%59 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%60 = load double, double* %59
%61 = fpext double %58 to x86_fp80
%62 = fpext double %60 to x86_fp80
%63 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %6, i32 0, i32 0
%64 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %6, i32 0, i32 1
store x86_fp80 %61, x86_fp80* %63
store x86_fp80 %62, x86_fp80* %64
%65 = call x86_fp80 @cabsl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16 %6)
%66 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%67 = load double, double* %66
%68 = fptosi double %67 to i32
%69 = sub nsw i32 0, %68
%70 = icmp slt i32 %68, 0
%71 = select i1 %70, i32 %69, i32 %68
%72 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%73 = load double, double* %72
%74 = fptosi double %73 to i64
%75 = sub nsw i64 0, %74
%76 = icmp slt i64 %74, 0
%77 = select i1 %76, i64 %75, i64 %74
%78 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%79 = load double, double* %78
%80 = fptosi double %79 to i64
%81 = sub nsw i64 0, %80
%82 = icmp slt i64 %80, 0
%83 = select i1 %82, i64 %81, i64 %80
%84 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%85 = load double, double* %84
%86 = fptrunc double %85 to float
%87 = call float @llvm.fabs.f32(float %86)
%88 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%89 = load double, double* %88
%90 = call double @llvm.fabs.f64(double %89)
%91 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%92 = load double, double* %91
%93 = fpext double %92 to x86_fp80
%94 = call x86_fp80 @llvm.fabs.f80(x86_fp80 %93)
%95 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%96 = load double, double* %95
%97 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%98 = load double, double* %97
%99 = fptrunc double %96 to float
%100 = fptrunc double %98 to float
%101 = getelementptr inbounds { float, float }, { float, float }* %7, i32 0, i32 0
%102 = getelementptr inbounds { float, float }, { float, float }* %7, i32 0, i32 1
store float %99, float* %101
store float %100, float* %102
%103 = bitcast { float, float }* %7 to <2 x float>*
%104 = load <2 x float>, <2 x float>* %103
%105 = call float @cabsf(<2 x float> %104)
%106 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%107 = load double, double* %106
%108 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%109 = load double, double* %108
%110 = getelementptr inbounds { double, double }, { double, double }* %8, i32 0, i32 0
%111 = getelementptr inbounds { double, double }, { double, double }* %8, i32 0, i32 1
store double %107, double* %110
store double %109, double* %111
%112 = getelementptr inbounds { double, double }, { double, double }* %8, i32 0, i32 0
%113 = load double, double* %112
%114 = getelementptr inbounds { double, double }, { double, double }* %8, i32 0, i32 1
%115 = load double, double* %114
%116 = call double @cabs(double %113, double %115)
%117 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%118 = load double, double* %117
%119 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%120 = load double, double* %119
%121 = fpext double %118 to x86_fp80
%122 = fpext double %120 to x86_fp80
%123 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %9, i32 0, i32 0
%124 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %9, i32 0, i32 1
store x86_fp80 %121, x86_fp80* %123
store x86_fp80 %122, x86_fp80* %124
%125 = call x86_fp80 @cabsl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16 %9)
ret void
}

LLVM IR (-O2):
define void @test_complex_double(double %0, double %1) {
%3 = alloca { x86_fp80, x86_fp80 }
%4 = alloca { x86_fp80, x86_fp80 }
%5 = fpext double %0 to x86_fp80
%6 = insertelement <2 x double> poison, double %0, i64 0
%7 = insertelement <2 x double> %6, double %1, i64 1
%8 = fptrunc <2 x double> %7 to <2 x float>
%9 = tail call float @cabsf(<2 x float> %8)
%10 = tail call double @cabs(double %0, double %1)
%11 = fpext double %1 to x86_fp80
%12 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %3, i64 0, i32 0
%13 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %3, i64 0, i32 1
store x86_fp80 %5, x86_fp80* %12
store x86_fp80 %11, x86_fp80* %13
%14 = tail call x86_fp80 @cabsl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16 %3)
%15 = tail call float @cabsf(<2 x float> %8)
%16 = tail call double @cabs(double %0, double %1)
%17 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %4, i64 0, i32 0
%18 = getelementptr inbounds { x86_fp80, x86_fp80 }, { x86_fp80, x86_fp80 }* %4, i64 0, i32 1
store x86_fp80 %5, x86_fp80* %17
store x86_fp80 %11, x86_fp80* %18
%19 = tail call x86_fp80 @cabsl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16 %4)
ret void
}