void test2(int c) {
  _Complex double X;
  X = bar(1);
  test(&X);
  takecomplex(X);
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <bar@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1050 <test@plt>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    $0x2,%al
call   1040 <takecomplex@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
sub    $0x18,%rsp
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <bar@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
xor    %eax,%eax
call   1050 <test@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x2,%al
call   1040 <takecomplex@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @test2(i32 %0) {
%2 = alloca i32
%3 = alloca { double, double }
%4 = alloca { double, double }
store i32 %0, i32* %2
%5 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 1)
%6 = sitofp i32 %5 to double
%7 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%8 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
store double %6, double* %7
store double 0.000000e+00, double* %8
%9 = call i32 ({ double, double }*, ...) bitcast (i32 (...)* @test to i32 ({ double, double }*, ...)*)({ double, double }* %3)
%10 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%11 = load double, double* %10
%12 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
%13 = load double, double* %12
%14 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 0
%15 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 1
store double %11, double* %14
store double %13, double* %15
%16 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 0
%17 = load double, double* %16
%18 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 1
%19 = load double, double* %18
%20 = call i32 (double, double, ...) bitcast (i32 (...)* @takecomplex to i32 (double, double, ...)*)(double %17, double %19)
ret void
}

LLVM IR (-O2):
define void @test2(i32 %0) {
%2 = alloca { double, double }
%3 = bitcast { double, double }* %2 to i8*
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 1)
%5 = sitofp i32 %4 to double
%6 = getelementptr inbounds { double, double }, { double, double }* %2, i64 0, i32 0
%7 = getelementptr inbounds { double, double }, { double, double }* %2, i64 0, i32 1
store double %5, double* %6
store double 0.000000e+00, double* %7
%8 = call i32 ({ double, double }*, ...) bitcast (i32 (...)* @test to i32 ({ double, double }*, ...)*)({ double, double }* %2)
%9 = load double, double* %6
%10 = load double, double* %7
%11 = call i32 (double, double, ...) bitcast (i32 (...)* @takecomplex to i32 (double, double, ...)*)(double %9, double %10)
ret void
}