#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 myPow(double, long);
double myPow0(double x, int n) {
  if (n == 0)
    return 1;
  long n0 = n;
  if (n < 0) {
    x = 1 / x;
    n0 *= -1;
  }
  return n0 % 2 == 0 ? myPow(x * x, n0 / 2) : myPow(x * x, n0 / 2) * x;
}


x86 assembly (clang, -O0):
<myPow0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    113c <myPow0+0x2c>
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11df <myPow0+0xcf>
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1169 <myPow0+0x59>
movsd  0xeaa(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
imul   $0xffffffffffffffff,-0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11ab <myPow0+0x9b>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <myPow@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    11d5 <myPow0+0xc5>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <myPow@plt>
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myPow0>:
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     115a <myPow0+0x4a>
movslq %edi,%rbx
jns    1131 <myPow0+0x21>
movsd  0xeda(%rip),%xmm1
divsd  %xmm0,%xmm1
neg    %rbx
movapd %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm0
mov    %rbx,%rdi
shr    $0x3f,%rdi
add    %rbx,%rdi
sar    %rdi
call   1030 <myPow@plt>
test   $0x1,%bl
je     1164 <myPow0+0x54>
movsd  0x8(%rsp),%xmm1
jmp    116c <myPow0+0x5c>
movsd  0xe9e(%rip),%xmm0
jmp    1170 <myPow0+0x60>
movsd  0xe94(%rip),%xmm1
mulsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

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

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