#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 INT_MIN;
double fast_pow(double, int);
double my_pow(double x, int n) {
  if (n == INT_MIN) {
    double t = 1 / fast_pow(x, -(n / 2));
    return t * t;
  }
  return n < 0 ? 1 / fast_pow(x, -n) : fast_pow(x, n);
}


x86 assembly (clang, -O0):
<my_pow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2ebe(%rip),%rcx
cmp    (%rcx),%eax
jne    1173 <my_pow+0x63>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
xor    %edi,%edi
sub    %eax,%edi
call   1030 <fast_pow@plt>
movaps %xmm0,%xmm1
movsd  0xeaa(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c1 <my_pow+0xb1>
cmpl   $0x0,-0x14(%rbp)
jge    11a5 <my_pow+0x95>
movsd  -0x10(%rbp),%xmm0
xor    %edi,%edi
sub    -0x14(%rbp),%edi
call   1030 <fast_pow@plt>
movaps %xmm0,%xmm1
movsd  0xe69(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b7 <my_pow+0xa7>
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <fast_pow@plt>
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):
<my_pow>:
push   %rax
mov    0x2ed0(%rip),%rax
cmp    %edi,(%rax)
jne    1144 <my_pow+0x34>
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
neg    %eax
mov    %eax,%edi
call   1030 <fast_pow@plt>
movapd %xmm0,%xmm1
movsd  0xec6(%rip),%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
pop    %rax
ret
test   %edi,%edi
js     114e <my_pow+0x3e>
pop    %rax
jmp    1030 <fast_pow@plt>
neg    %edi
call   1030 <fast_pow@plt>
movapd %xmm0,%xmm1
movsd  0xe9f(%rip),%xmm0
divsd  %xmm1,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
@INT_MIN = global i32 0
define double @my_pow(double %0, i32 %1) {
%3 = load i32, i32* @INT_MIN
%4 = icmp eq i32 %3, %1
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = sdiv i32 %1, -2
%7 = tail call double @fast_pow(double %0, i32 %6)
%8 = fdiv double 1.000000e+00, %7
%9 = fmul double %8, %8
br label %18
10: ; preds = %2
%11 = icmp slt i32 %1, 0
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = sub nsw i32 0, %1
%14 = tail call double @fast_pow(double %0, i32 %13)
%15 = fdiv double 1.000000e+00, %14
br label %18
16: ; preds = %10
%17 = tail call double @fast_pow(double %0, i32 %1)
br label %18
18: ; preds = %12, %16, %5
%19 = phi double [ %9, %5 ], [ %15, %12 ], [ %17, %16 ]
ret double %19
}