double pw(x, y)
double x, y;
{
  double res;
  int neg;
  if (x < 0) {
    neg = 1;
  } else {
    neg = 0;
  }
  if (x == 0.0) {
    x = 0.000000000001;
  }
  res = exp(y * log(fabs(x)));
  if (neg) {
    return (-res);
  } else {
    return (res);
  }
}


x86 assembly (clang, -O0):
<pw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    114c <pw+0x2c>
movl   $0x1,-0x24(%rbp)
jmp    1153 <pw+0x33>
movl   $0x0,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1178 <pw+0x58>
jp     1178 <pw+0x58>
movsd  0xe8d(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe82(%rip),%xmm1
pand   %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11dd <pw+0xbd>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e7 <pw+0xc7>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pw>:
sub    $0x28,%rsp
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm2
movapd %xmm0,0x10(%rsp)
xorpd  %xmm1,%xmm1
cmpeqsd %xmm1,%xmm0
movsd  0xebb(%rip),%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
andpd  0xeb7(%rip),%xmm0
call   1040 <log@plt>
mulsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
movapd 0xeaf(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd 0x10(%rsp),%xmm3
cmpltsd 0xe84(%rip),%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @pw(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %7
br label %12
11: ; preds = %2
store i32 0, i32* %7
br label %12
12: ; preds = %11, %10
%13 = load double, double* %4
%14 = fcmp oeq double %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %12
store double 0x3D719799812DEA11, double* %4
br label %16
16: ; preds = %15, %12
%17 = load double, double* %5
%18 = load double, double* %4
%19 = call double @llvm.fabs.f64(double %18)
%20 = call double @log(double %19)
%21 = fmul double %17, %20
%22 = call double @exp(double %21)
store double %22, double* %6
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %16
%26 = load double, double* %6
%27 = fneg double %26
store double %27, double* %3
br label %30
28: ; preds = %16
%29 = load double, double* %6
store double %29, double* %3
br label %30
30: ; preds = %28, %25
%31 = load double, double* %3
ret double %31
}

LLVM IR (-O2):
define double @pw(double %0, double %1) {
%3 = fcmp olt double %0, 0.000000e+00
%4 = fcmp oeq double %0, 0.000000e+00
%5 = select i1 %4, double 0x3D719799812DEA11, double %0
%6 = tail call double @llvm.fabs.f64(double %5)
%7 = tail call double @log(double %6)
%8 = fmul double %7, %1
%9 = tail call double @exp(double %8)
%10 = fneg double %9
%11 = select i1 %3, double %10, double %9
ret double %11
}