void test_builtin_carg(_Complex double d) {
  if (__builtin_carg(d) != __builtin_carg(d))
    link_failure_builtin_carg();
}


x86 assembly (clang, -O0):
<test_builtin_carg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <carg@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <carg@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    119a <test_builtin_carg+0x7a>
jp     119a <test_builtin_carg+0x7a>
jmp    11a1 <test_builtin_carg+0x81>
mov    $0x0,%al
call   1040 <link_failure_builtin_carg@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_builtin_carg>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
call   1030 <carg@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <carg@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1158 <test_builtin_carg+0x38>
jnp    1163 <test_builtin_carg+0x43>
xor    %eax,%eax
add    $0x18,%rsp
jmp    1040 <link_failure_builtin_carg@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @test_builtin_carg(double %0, double %1) {
%3 = alloca { double, double }
%4 = alloca { double, double }
%5 = alloca { double, double }
%6 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
store double %0, double* %6
%7 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
store double %1, double* %7
%8 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%9 = load double, double* %8
%10 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%11 = load double, double* %10
%12 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 0
%13 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 1
store double %9, double* %12
store double %11, double* %13
%14 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 0
%15 = load double, double* %14
%16 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 1
%17 = load double, double* %16
%18 = call double @carg(double %15, double %17)
%19 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%20 = load double, double* %19
%21 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%22 = load double, double* %21
%23 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0
%24 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1
store double %20, double* %23
store double %22, double* %24
%25 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0
%26 = load double, double* %25
%27 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1
%28 = load double, double* %27
%29 = call double @carg(double %26, double %28)
%30 = fcmp une double %18, %29
br i1 %30, label %31, label %33
31: ; preds = %2
%32 = call i32 (...) @link_failure_builtin_carg()
br label %33
33: ; preds = %31, %2
ret void
}

LLVM IR (-O2):
define void @test_builtin_carg(double %0, double %1) {
%3 = tail call double @carg(double %0, double %1)
%4 = tail call double @carg(double %0, double %1)
%5 = fcmp une double %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @link_failure_builtin_carg()
br label %8
8: ; preds = %6, %2
ret void
}