double exp(double __x) {
  register double __value, __exponent;
  __asm __volatile__(
      "fldl2e                    # e^x = 2^(x * log2(e))\n\t"
      "fmul      %%st(1)         # x * log2(e)\n\t"
      "fst       %%st(1)\n\t"
      "frndint                   # int(x * log2(e))\n\t"
      "fxch\n\t"
      "fsub      %%st(1)         # fract(x * log2(e))\n\t"
      "f2xm1                     # 2^(fract(x * log2(e))) - 1\n\t"
      : "=t"(__value), "=u"(__exponent)
      : "0"(__x));
  __value += 1.0;
  __asm __volatile__("fscale" : "=t"(__value) : "0"(__value), "u"(__exponent));
  return __value;
}


x86 assembly (clang, -O0):
<exp>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
fldl   -0x38(%rbp)
fldl2e
fmul   %st(1),%st
fst    %st(1)
frndint
fxch   %st(1)
fsub   %st(1),%st
f2xm1
fxch   %st(1)
fstpl  -0x48(%rbp)
fstpl  -0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb8(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
fldl   -0x20(%rbp)
fldl   -0x28(%rbp)
fxch   %st(1)
fscale
fstp   %st(1)
fstpl  -0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<exp>:
movsd  %xmm0,-0x8(%rsp)
fldl   -0x8(%rsp)
fldl2e
fmul   %st(1),%st
fst    %st(1)
frndint
fxch   %st(1)
fsub   %st(1),%st
f2xm1
fstpl  -0x10(%rsp)
movsd  -0x10(%rsp),%xmm0
addsd  0xed6(%rip),%xmm0
movsd  %xmm0,-0x18(%rsp)
fldl   -0x18(%rsp)
fscale
fstp   %st(1)
fstpl  -0x20(%rsp)
movsd  -0x20(%rsp),%xmm0
ret

LLVM IR (-O0):
define double @exp(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %2
%5 = load double, double* %2
%6 = call { double, double } asm sideeffect "fldl2e # e^x = 2^(x * log2(e))\0A\09fmul %st(1) # x * log2(e)\0A\09fst %st(1)\0A\09frndint # int(x * log2(e))\0A\09fxch\0A\09fsub %st(1) # fract(x * log2(e))\0A\09f2xm1 # 2^(fract(x * log2(e))) - 1\0A\09", "={st},={st(1)},0,~{dirflag},~{fpsr},~{flags}"(double %5)
%7 = extractvalue { double, double } %6, 0
%8 = extractvalue { double, double } %6, 1
store double %7, double* %3
store double %8, double* %4
%9 = load double, double* %3
%10 = fadd double %9, 1.000000e+00
store double %10, double* %3
%11 = load double, double* %3
%12 = load double, double* %4
%13 = call double asm sideeffect "fscale", "={st},0,{st(1)},~{dirflag},~{fpsr},~{flags}"(double %11, double %12)
store double %13, double* %3
%14 = load double, double* %3
ret double %14
}

LLVM IR (-O2):
define double @exp(double %0) {
%2 = tail call { double, double } asm sideeffect "fldl2e # e^x = 2^(x * log2(e))\0A\09fmul %st(1) # x * log2(e)\0A\09fst %st(1)\0A\09frndint # int(x * log2(e))\0A\09fxch\0A\09fsub %st(1) # fract(x * log2(e))\0A\09f2xm1 # 2^(fract(x * log2(e))) - 1\0A\09", "={st},={st(1)},0,~{dirflag},~{fpsr},~{flags}"(double %0)
%3 = extractvalue { double, double } %2, 0
%4 = extractvalue { double, double } %2, 1
%5 = fadd double %3, 1.000000e+00
%6 = tail call double asm sideeffect "fscale", "={st},0,{st(1)},~{dirflag},~{fpsr},~{flags}"(double %5, double %4)
ret double %6
}