#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double exp(int);
double pow(double, int);
double agexp(double r, double x, double y) {
  double w;
  if (r == 0.0)
    return (exp(2 * x));
  else {
    x = 1 + r * x;
    y = r * y;
    w = x * x + y * y;
    if (r < 0.0)
      return (pow(1 / w, -1 / r));
    else
      return (pow(w, 1 / r));
  }
}


x86 assembly (clang, -O0):
<agexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116f <agexp+0x4f>
jp     116f <agexp+0x4f>
movsd  0xeb9(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1219 <agexp+0xf9>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe7b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11f9 <agexp+0xd9>
movsd  0xe2c(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xe27(%rip),%xmm1
divsd  -0x10(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1219 <agexp+0xf9>
movsd  -0x28(%rbp),%xmm0
movsd  0xdfa(%rip),%xmm1
divsd  -0x10(%rbp),%xmm1
cvttsd2si %xmm1,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<agexp>:
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jne    1139 <agexp+0x19>
jp     1139 <agexp+0x19>
addsd  %xmm1,%xmm1
cvttsd2si %xmm1,%edi
jmp    1030 <exp@plt>
mulsd  %xmm0,%xmm1
addsd  0xebb(%rip),%xmm1
mulsd  %xmm0,%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xea3(%rip),%xmm2
ucomisd %xmm0,%xmm3
jbe    1180 <agexp+0x60>
divsd  %xmm1,%xmm2
movsd  0xe99(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
movapd %xmm2,%xmm0
jmp    1040 <pow@plt>
divsd  %xmm0,%xmm2
cvttsd2si %xmm2,%edi
movapd %xmm1,%xmm0
jmp    1040 <pow@plt>

LLVM IR (-O0):
define double @agexp(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %5
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load double, double* %6
%13 = fmul double 2.000000e+00, %12
%14 = fptosi double %13 to i32
%15 = call double @exp(i32 %14)
store double %15, double* %4
br label %44
16: ; preds = %3
%17 = load double, double* %5
%18 = load double, double* %6
%19 = call double @llvm.fmuladd.f64(double %17, double %18, double 1.000000e+00)
store double %19, double* %6
%20 = load double, double* %5
%21 = load double, double* %7
%22 = fmul double %20, %21
store double %22, double* %7
%23 = load double, double* %6
%24 = load double, double* %6
%25 = load double, double* %7
%26 = load double, double* %7
%27 = fmul double %25, %26
%28 = call double @llvm.fmuladd.f64(double %23, double %24, double %27)
store double %28, double* %8
%29 = load double, double* %5
%30 = fcmp olt double %29, 0.000000e+00
br i1 %30, label %31, label %38
31: ; preds = %16
%32 = load double, double* %8
%33 = fdiv double 1.000000e+00, %32
%34 = load double, double* %5
%35 = fdiv double -1.000000e+00, %34
%36 = fptosi double %35 to i32
%37 = call double @pow(double %33, i32 %36)
store double %37, double* %4
br label %44
38: ; preds = %16
%39 = load double, double* %8
%40 = load double, double* %5
%41 = fdiv double 1.000000e+00, %40
%42 = fptosi double %41 to i32
%43 = call double @pow(double %39, i32 %42)
store double %43, double* %4
br label %44
44: ; preds = %38, %31, %11
%45 = load double, double* %4
ret double %45
}

LLVM IR (-O2):
define double @agexp(double %0, double %1, double %2) {
%4 = fcmp oeq double %0, 0.000000e+00
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = fmul double %1, 2.000000e+00
%7 = fptosi double %6 to i32
%8 = tail call double @exp(i32 %7)
br label %24
9: ; preds = %3
%10 = tail call double @llvm.fmuladd.f64(double %0, double %1, double 1.000000e+00)
%11 = fmul double %0, %2
%12 = fmul double %11, %11
%13 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %12)
%14 = fcmp olt double %0, 0.000000e+00
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = fdiv double 1.000000e+00, %13
%17 = fdiv double -1.000000e+00, %0
%18 = fptosi double %17 to i32
%19 = tail call double @pow(double %16, i32 %18)
br label %24
20: ; preds = %9
%21 = fdiv double 1.000000e+00, %0
%22 = fptosi double %21 to i32
%23 = tail call double @pow(double %13, i32 %22)
br label %24
24: ; preds = %20, %15, %5
%25 = phi double [ %8, %5 ], [ %19, %15 ], [ %23, %20 ]
ret double %25
}