#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 */
int fabs(double);
double powRecursion(double, int);
double myPow(double x, int n) {
  int nNegtive = 0;
  double result = 0.0;
  if (n < 0) {
    n = -n;
    nNegtive = 1;
  } else if (n == 0) {
    return 1;
  }
  if (fabs(1.0 - x) <= 1e-15) {
    return 1.0;
  } else if (fabs(-1.0 - x) <= 1e-15) {
    if (n & 1) {
      return -1;
    } else {
      return 1;
    }
  }
  result = powRecursion(x, n);
  if (nNegtive) {
    result = 1.0 / result;
  }
  return result;
}


x86 assembly (clang, -O0):
<myPow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    115d <myPow+0x3d>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    117e <myPow+0x5e>
cmpl   $0x0,-0x14(%rbp)
jne    1179 <myPow+0x59>
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1250 <myPow+0x130>
jmp    117e <myPow+0x5e>
movsd  0xe7a(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe6c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11b8 <myPow+0x98>
movsd  0xe52(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1250 <myPow+0x130>
movsd  0xe50(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe32(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1213 <myPow+0xf3>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1201 <myPow+0xe1>
movsd  0xe19(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1250 <myPow+0x130>
movsd  0xdf7(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1250 <myPow+0x130>
jmp    1218 <myPow+0xf8>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1040 <powRecursion@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1246 <myPow+0x126>
movsd  0xdc4(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myPow>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
movapd %xmm0,%xmm1
mov    %edi,%ebp
test   %edi,%edi
js     113b <myPow+0x1b>
jne    113d <myPow+0x1d>
movsd  0xec7(%rip),%xmm0
jmp    11ac <myPow+0x8c>
neg    %ebp
movsd  0xebb(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <fabs@plt>
movsd  0xea5(%rip),%xmm0
test   %eax,%eax
jle    11ac <myPow+0x8c>
movsd  0xea1(%rip),%xmm0
subsd  (%rsp),%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jle    1197 <myPow+0x77>
movsd  (%rsp),%xmm0
mov    %ebp,%edi
call   1040 <powRecursion@plt>
test   %ebx,%ebx
jns    11ac <myPow+0x8c>
movsd  0xe73(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    11ac <myPow+0x8c>
xor    %eax,%eax
test   $0x1,%bpl
sete   %al
lea    0xe69(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @myPow(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
store i32 0, i32* %6
store double 0.000000e+00, double* %7
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %5
%12 = sub nsw i32 0, %11
store i32 %12, i32* %5
store i32 1, i32* %6
br label %18
13: ; preds = %2
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store double 1.000000e+00, double* %3
br label %49
17: ; preds = %13
br label %18
18: ; preds = %17, %10
%19 = load double, double* %4
%20 = fsub double 1.000000e+00, %19
%21 = call i32 @fabs(double %20)
%22 = sitofp i32 %21 to double
%23 = fcmp ole double %22, 1.000000e-15
br i1 %23, label %24, label %25
24: ; preds = %18
store double 1.000000e+00, double* %3
br label %49
25: ; preds = %18
%26 = load double, double* %4
%27 = fsub double -1.000000e+00, %26
%28 = call i32 @fabs(double %27)
%29 = sitofp i32 %28 to double
%30 = fcmp ole double %29, 1.000000e-15
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = load i32, i32* %5
%33 = and i32 %32, 1
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
store double -1.000000e+00, double* %3
br label %49
36: ; preds = %31
store double 1.000000e+00, double* %3
br label %49
37: ; preds = %25
br label %38
38: ; preds = %37
%39 = load double, double* %4
%40 = load i32, i32* %5
%41 = call double @powRecursion(double %39, i32 %40)
store double %41, double* %7
%42 = load i32, i32* %6
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %38
%45 = load double, double* %7
%46 = fdiv double 1.000000e+00, %45
store double %46, double* %7
br label %47
47: ; preds = %44, %38
%48 = load double, double* %7
store double %48, double* %3
br label %49
49: ; preds = %47, %36, %35, %24, %16
%50 = load double, double* %3
ret double %50
}

LLVM IR (-O2):
define double @myPow(double %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = sub nsw i32 0, %1
br label %8
6: ; preds = %2
%7 = icmp eq i32 %1, 0
br i1 %7, label %25, label %8
8: ; preds = %6, %4
%9 = phi i32 [ %5, %4 ], [ %1, %6 ]
%10 = fsub double 1.000000e+00, %0
%11 = tail call i32 @fabs(double %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %25, label %13
13: ; preds = %8
%14 = fsub double -1.000000e+00, %0
%15 = tail call i32 @fabs(double %14)
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = and i32 %9, 1
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, double 1.000000e+00, double -1.000000e+00
br label %25
21: ; preds = %13
%22 = tail call double @powRecursion(double %0, i32 %9)
%23 = fdiv double 1.000000e+00, %22
%24 = select i1 %3, double %23, double %22
br label %25
25: ; preds = %17, %8, %6, %21
%26 = phi double [ %24, %21 ], [ 1.000000e+00, %6 ], [ 1.000000e+00, %8 ], [ %20, %17 ]
ret double %26
}