__complex__ double cexp(__complex__ double z) {
  __complex__ double ret;
  double r_exponent = exp(__real__ z);
  __real__ ret = r_exponent * cos(__imag__ z);
  __imag__ ret = r_exponent * sin(__imag__ z);
  return ret;
}


x86 assembly (clang, -O0):
<cexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cexp>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
call   1040 <exp@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define { double, double } @cexp(double %0, double %1) {
%3 = alloca { double, double }
%4 = alloca { double, double }
%5 = alloca { double, double }
%6 = alloca double
%7 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 0
store double %0, double* %7
%8 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 1
store double %1, double* %8
%9 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 0
%10 = load double, double* %9
%11 = call double @exp(double %10)
store double %11, double* %6
%12 = load double, double* %6
%13 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 1
%14 = load double, double* %13
%15 = call double @cos(double %14)
%16 = fmul double %12, %15
%17 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0
store double %16, double* %17
%18 = load double, double* %6
%19 = getelementptr inbounds { double, double }, { double, double }* %4, i32 0, i32 1
%20 = load double, double* %19
%21 = call double @sin(double %20)
%22 = fmul double %18, %21
%23 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1
store double %22, double* %23
%24 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 0
%25 = load double, double* %24
%26 = getelementptr inbounds { double, double }, { double, double }* %5, i32 0, i32 1
%27 = load double, double* %26
%28 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 0
%29 = getelementptr inbounds { double, double }, { double, double }* %3, i32 0, i32 1
store double %25, double* %28
store double %27, double* %29
%30 = load { double, double }, { double, double }* %3
ret { double, double } %30
}

LLVM IR (-O2):
define { double, double } @cexp(double %0, double %1) {
%3 = tail call double @exp(double %0)
%4 = tail call double @cos(double %1)
%5 = fmul double %3, %4
%6 = tail call double @sin(double %1)
%7 = fmul double %3, %6
%8 = insertvalue { double, double } poison, double %5, 0
%9 = insertvalue { double, double } %8, double %7, 1
ret { double, double } %9
}