#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 /*<<< orphan*/ EDOM;
scalar_t__ FP_INFINITE;
int /*<<< orphan*/ errno;
scalar_t__ fpclassify(double);
double pow(double x, double y) {
  if (x < 0 && !(fpclassify(x) != FP_INFINITE)) {
    errno = EDOM;
    return 0;
  }
  int times = (int)y;
  double res = 1;
  while (--times >= 0)
    res *= x;
  return res;
}


x86 assembly (clang, -O0):
<pow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1169 <pow+0x59>
movsd  -0x10(%rbp),%xmm0
call   1030 <fpclassify@plt>
mov    0x2ea7(%rip),%rcx
cmp    (%rcx),%rax
jne    1169 <pow+0x59>
mov    0x2e8f(%rip),%rax
mov    (%rax),%ecx
mov    0x2e76(%rip),%rax
mov    %ecx,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ae <pow+0x9e>
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jl     11a4 <pow+0x94>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    117e <pow+0x6e>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pow>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    116a <pow+0x5a>
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <fpclassify@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
jne    116a <pow+0x5a>
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    0x2e71(%rip),%rcx
mov    %eax,(%rcx)
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
ret
cvttsd2si %xmm1,%eax
test   %eax,%eax
jle    11a4 <pow+0x94>
lea    -0x1(%rax),%ecx
mov    %eax,%edx
and    $0x7,%edx
je     11b1 <pow+0xa1>
xor    %esi,%esi
movsd  0xe7a(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
mulsd  %xmm2,%xmm0
add    $0x1,%esi
cmp    %esi,%edx
jne    1190 <pow+0x80>
sub    %esi,%eax
cmp    $0x7,%ecx
jae    11be <pow+0xae>
jmp    11f8 <pow+0xe8>
movsd  0xe54(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0xe47(%rip),%xmm0
cmp    $0x7,%ecx
jb     11f8 <pow+0xe8>
add    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
add    $0xfffffff8,%eax
cmp    $0xfffffffe,%eax
jb     11d0 <pow+0xc0>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@FP_INFINITE = global i64 0
@EDOM = global i32 0
@errno = global i32 0
define double @pow(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load double, double* %4
%12 = call i64 @fpclassify(double %11)
%13 = load i64, i64* @FP_INFINITE
%14 = icmp ne i64 %12, %13
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = load i32, i32* @EDOM
store i32 %16, i32* @errno
store double 0.000000e+00, double* %3
br label %30
17: ; preds = %10, %2
%18 = load double, double* %5
%19 = fptosi double %18 to i32
store i32 %19, i32* %6
store double 1.000000e+00, double* %7
br label %20
20: ; preds = %24, %17
%21 = load i32, i32* %6
%22 = add nsw i32 %21, -1
store i32 %22, i32* %6
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load double, double* %4
%26 = load double, double* %7
%27 = fmul double %26, %25
store double %27, double* %7
br label %20
28: ; preds = %20
%29 = load double, double* %7
store double %29, double* %3
br label %30
30: ; preds = %28, %15
%31 = load double, double* %3
ret double %31
}

LLVM IR (-O2):
@FP_INFINITE = global i64 0
@EDOM = global i32 0
@errno = global i32 0
define double @pow(double %0, double %1) {
%3 = fcmp olt double %0, 0.000000e+00
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = tail call i64 @fpclassify(double %0)
%6 = load i64, i64* @FP_INFINITE
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = load i32, i32* @EDOM
store i32 %9, i32* @errno
br label %44
10: ; preds = %4, %2
%11 = fptosi double %1 to i32
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %44
13: ; preds = %10
%14 = add i32 %11, -1
%15 = and i32 %11, 7
%16 = icmp eq i32 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %13, %17
%18 = phi double [ %22, %17 ], [ 1.000000e+00, %13 ]
%19 = phi i32 [ %21, %17 ], [ %11, %13 ]
%20 = phi i32 [ %23, %17 ], [ 0, %13 ]
%21 = add nsw i32 %19, -1
%22 = fmul double %18, %0
%23 = add i32 %20, 1
%24 = icmp eq i32 %23, %15
br i1 %24, label %25, label %17
25: ; preds = %17, %13
%26 = phi double [ 1.000000e+00, %13 ], [ %22, %17 ]
%27 = phi i32 [ %11, %13 ], [ %21, %17 ]
%28 = phi double [ undef, %13 ], [ %22, %17 ]
%29 = icmp ult i32 %14, 7
br i1 %29, label %44, label %30
30: ; preds = %25, %30
%31 = phi double [ %41, %30 ], [ %26, %25 ]
%32 = phi i32 [ %40, %30 ], [ %27, %25 ]
%33 = fmul double %31, %0
%34 = fmul double %33, %0
%35 = fmul double %34, %0
%36 = fmul double %35, %0
%37 = fmul double %36, %0
%38 = fmul double %37, %0
%39 = fmul double %38, %0
%40 = add nsw i32 %32, -8
%41 = fmul double %39, %0
%42 = add i32 %32, -9
%43 = icmp ult i32 %42, -2
br i1 %43, label %30, label %44
44: ; preds = %25, %30, %10, %8
%45 = phi double [ 0.000000e+00, %8 ], [ 1.000000e+00, %10 ], [ %28, %25 ], [ %41, %30 ]
ret double %45
}