#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 */
scalar_t__ isOdd(long);
double myPow(double base, long exponent) {
  if (exponent == 0) {
    return 1;
  } else if (exponent > 0) {
    double result = 1;
    while (exponent > 0) {
      if (isOdd(exponent)) {
        result *= base;
      }
      exponent >>= 1;
      base *= base;
    }
    return result;
  } else {
    return 1.0 / myPow(base, -exponent);
  }
}


x86 assembly (clang, -O0):
<myPow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114e <myPow+0x2e>
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <myPow+0xc8>
cmpq   $0x0,-0x18(%rbp)
jle    11c2 <myPow+0xa2>
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    11b3 <myPow+0x93>
mov    -0x18(%rbp),%rdi
call   1030 <isOdd@plt>
cmp    $0x0,%rax
je     1193 <myPow+0x73>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1166 <myPow+0x46>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <myPow+0xc8>
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
mov    %eax,%edi
sub    -0x18(%rbp),%rdi
call   1040 <myPow@plt>
movaps %xmm0,%xmm1
movsd  0xe21(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myPow>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     118c <myPow+0x6c>
mov    %rdi,%rbx
jle    1196 <myPow+0x76>
movsd  0xec9(%rip),%xmm1
jmp    1160 <myPow+0x40>
nopl   0x0(%rax)
movsd  (%rsp),%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm2,%xmm1
mov    %rbx,%rax
shr    %rax
mulsd  %xmm0,%xmm0
cmp    $0x1,%rbx
mov    %rax,%rbx
jbe    11ad <myPow+0x8d>
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <isOdd@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xe7f(%rip),%xmm1
test   %rax,%rax
je     1140 <myPow+0x20>
movapd %xmm0,%xmm1
jmp    1140 <myPow+0x20>
movsd  0xe6c(%rip),%xmm1
jmp    11ad <myPow+0x8d>
neg    %rbx
mov    %rbx,%rdi
call   1040 <myPow@plt>
movsd  0xe57(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @myPow(double %0, i64 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i64
%6 = alloca double
store double %0, double* %4
store i64 %1, i64* %5
%7 = load i64, i64* %5
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store double 1.000000e+00, double* %3
br label %39
10: ; preds = %2
%11 = load i64, i64* %5
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %10
store double 1.000000e+00, double* %6
br label %14
14: ; preds = %25, %13
%15 = load i64, i64* %5
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = load i64, i64* %5
%19 = call i64 @isOdd(i64 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load double, double* %4
%23 = load double, double* %6
%24 = fmul double %23, %22
store double %24, double* %6
br label %25
25: ; preds = %21, %17
%26 = load i64, i64* %5
%27 = ashr i64 %26, 1
store i64 %27, i64* %5
%28 = load double, double* %4
%29 = load double, double* %4
%30 = fmul double %29, %28
store double %30, double* %4
br label %14
31: ; preds = %14
%32 = load double, double* %6
store double %32, double* %3
br label %39
33: ; preds = %10
%34 = load double, double* %4
%35 = load i64, i64* %5
%36 = sub nsw i64 0, %35
%37 = call double @myPow(double %34, i64 %36)
%38 = fdiv double 1.000000e+00, %37
store double %38, double* %3
br label %39
39: ; preds = %33, %31, %9
%40 = load double, double* %3
ret double %40
}

LLVM IR (-O2):
define double @myPow(double %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = icmp sgt i64 %1, 0
br i1 %5, label %6, label %19
6: ; preds = %4, %6
%7 = phi double [ %13, %6 ], [ 1.000000e+00, %4 ]
%8 = phi i64 [ %14, %6 ], [ %1, %4 ]
%9 = phi double [ %15, %6 ], [ %0, %4 ]
%10 = tail call i64 @isOdd(i64 %8)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, double 1.000000e+00, double %9
%13 = fmul double %7, %12
%14 = lshr i64 %8, 1
%15 = fmul double %9, %9
%16 = icmp ult i64 %8, 2
br i1 %16, label %17, label %6
17: ; preds = %6, %2, %19
%18 = phi double [ %22, %19 ], [ 1.000000e+00, %2 ], [ %13, %6 ]
ret double %18
19: ; preds = %4
%20 = sub nsw i64 0, %1
%21 = tail call double @myPow(double %0, i64 %20)
%22 = fdiv double 1.000000e+00, %21
br label %17
}