#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__ isfinite(double);
double pow(double, double);
void dpow(unsigned int xlength, double *x, int xskip, double y,
          double non_finite_alt) {
  int xi;
  double z;
  for (xi = 0; xi < xlength; xi += xskip) {
    z = pow(x[xi], y);
    x[xi] = isfinite(z) ? z : non_finite_alt;
  }
}


x86 assembly (clang, -O0):
<dpow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11b8 <dpow+0x98>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <isfinite@plt>
cmp    $0x0,%rax
je     118e <dpow+0x6e>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1198 <dpow+0x78>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1143 <dpow+0x23>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dpow>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
test   %edi,%edi
je     118c <dpow+0x6c>
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%r15d
movslq %edx,%r12
shl    $0x3,%r12
xor    %ebp,%ebp
jmp    115f <dpow+0x3f>
movsd  %xmm0,(%rbx)
add    %r12,%rbx
add    %r14d,%ebp
cmp    %r15d,%ebp
jae    118c <dpow+0x6c>
movsd  (%rbx),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,0x18(%rsp)
call   1030 <isfinite@plt>
movsd  0x10(%rsp),%xmm0
test   %rax,%rax
je     1150 <dpow+0x30>
movsd  0x18(%rsp),%xmm0
jmp    1150 <dpow+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @dpow(i32 %0, double* %1, i32 %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
store i32 %0, i32* %6
store double* %1, double** %7
store i32 %2, i32* %8
store double %3, double* %9
store double %4, double* %10
store i32 0, i32* %11
br label %13
13: ; preds = %38, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %6
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %42
17: ; preds = %13
%18 = load double*, double** %7
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double, double* %9
%24 = call double @pow(double %22, double %23)
store double %24, double* %12
%25 = load double, double* %12
%26 = call i64 @isfinite(double %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %17
%29 = load double, double* %12
br label %32
30: ; preds = %17
%31 = load double, double* %10
br label %32
32: ; preds = %30, %28
%33 = phi double [ %29, %28 ], [ %31, %30 ]
%34 = load double*, double** %7
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %38
38: ; preds = %32
%39 = load i32, i32* %8
%40 = load i32, i32* %11
%41 = add nsw i32 %40, %39
store i32 %41, i32* %11
br label %13
42: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @dpow(i32 %0, double* nocapture %1, i32 %2, double %3, double %4) {
%6 = icmp eq i32 %0, 0
br i1 %6, label %20, label %7
7: ; preds = %5
%8 = sext i32 %2 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %17, %9 ]
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = load double, double* %11
%13 = tail call double @pow(double %12, double %3)
%14 = tail call i64 @isfinite(double %13)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, double %4, double %13
store double %16, double* %11
%17 = add i64 %10, %8
%18 = trunc i64 %17 to i32
%19 = icmp ult i32 %18, %0
br i1 %19, label %9, label %20
20: ; preds = %9, %5
ret void
}