#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 binary(double, double);
double myPow(double x, int n) {
  double x_bak = x < 0 ? -x : x;
  double n_bak = n < 0 ? -n : n;
  double res;
  if (x == 0)
    return 0;
  res = binary(x_bak, n_bak);
  if (x < 0 && (n & 1) == 1)
    res *= -1;
  if (n < 0)
    res = 1 / res;
  return res;
}


x86 assembly (clang, -O0):
<myPow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1154 <myPow+0x44>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    115e <myPow+0x4e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    117f <myPow+0x6f>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1185 <myPow+0x75>
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b6 <myPow+0xa6>
jp     11b6 <myPow+0xa6>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121f <myPow+0x10f>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <binary@plt>
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11f9 <myPow+0xe9>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    11f9 <myPow+0xe9>
movsd  0xe11(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1215 <myPow+0x105>
movsd  0xdfd(%rip),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myPow>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1121 <myPow+0x11>
jp     1121 <myPow+0x11>
movapd %xmm1,%xmm0
ret
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movapd %xmm0,%xmm3
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm0,%xmm2
xorpd  0xeba(%rip),%xmm2
xorpd  %xmm4,%xmm4
cmpltsd %xmm4,%xmm0
andpd  %xmm0,%xmm2
movapd %xmm3,(%rsp)
andnpd %xmm3,%xmm0
orpd   %xmm2,%xmm0
call   1030 <binary@plt>
test   $0x1,%bl
jne    1170 <myPow+0x60>
movapd %xmm0,%xmm1
jmp    117c <myPow+0x6c>
movapd 0xe88(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
ucomisd (%rsp),%xmm2
ja     118b <myPow+0x7b>
movapd %xmm0,%xmm1
test   %ebx,%ebx
jns    119f <myPow+0x8f>
movsd  0xe79(%rip),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
add    $0x10,%rsp
pop    %rbx
movapd %xmm1,%xmm0
ret

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

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