#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*/ isnan(double);
double sqrt(double);
void rescalesigma_linear(int N, double *sig, double a, double b) {
  int i;
  for (i = 0; i < N; i++) {
    if (sig[i] > 0. && !isnan(sig[i]))
      sig[i] = sqrt(sig[i] * sig[i] * a + b);
  }
}


x86 assembly (clang, -O0):
<rescalesigma_linear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d2 <rescalesigma_linear+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11bf <rescalesigma_linear+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%eax
jne    11bf <rescalesigma_linear+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11c4 <rescalesigma_linear+0xa4>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1140 <rescalesigma_linear+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rescalesigma_linear>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
test   %edi,%edi
jle    11a3 <rescalesigma_linear+0x83>
mov    %rsi,%r15
mov    %edi,%r14d
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1169 <rescalesigma_linear+0x49>
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r15,%rbx,8)
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    %rbx,%r14
je     11a3 <rescalesigma_linear+0x83>
movsd  (%r15,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1160 <rescalesigma_linear+0x40>
call   1030 <isnan@plt>
xorpd  %xmm1,%xmm1
test   %eax,%eax
jne    1160 <rescalesigma_linear+0x40>
movsd  (%r15,%rbx,8),%xmm0
mulsd  %xmm0,%xmm0
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jb     1146 <rescalesigma_linear+0x26>
sqrtsd %xmm0,%xmm0
jmp    114f <rescalesigma_linear+0x2f>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rescalesigma_linear(i32 %0, double* %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double %2, double* %7
store double %3, double* %8
store i32 0, i32* %9
br label %10
10: ; preds = %50, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %53
14: ; preds = %10
%15 = load double*, double** %6
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = fcmp ogt double %19, 0.000000e+00
br i1 %20, label %21, label %49
21: ; preds = %14
%22 = load double*, double** %6
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = call i32 @isnan(double %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %49, label %29
29: ; preds = %21
%30 = load double*, double** %6
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = load double*, double** %6
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fmul double %34, %39
%41 = load double, double* %7
%42 = load double, double* %8
%43 = call double @llvm.fmuladd.f64(double %40, double %41, double %42)
%44 = call double @sqrt(double %43)
%45 = load double*, double** %6
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
store double %44, double* %48
br label %49
49: ; preds = %29, %21, %14
br label %50
50: ; preds = %49
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %10
53: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @rescalesigma_linear(i32 %0, double* nocapture %1, double %2, double %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %21
%9 = phi i64 [ 0, %6 ], [ %22, %21 ]
%10 = getelementptr inbounds double, double* %1, i64 %9
%11 = load double, double* %10
%12 = fcmp ogt double %11, 0.000000e+00
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = tail call i32 @isnan(double %11)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load double, double* %10
%18 = fmul double %17, %17
%19 = tail call double @llvm.fmuladd.f64(double %18, double %2, double %3)
%20 = tail call double @sqrt(double %19)
store double %20, double* %10
br label %21
21: ; preds = %8, %13, %16
%22 = add nuw nsw i64 %9, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %24, label %8
24: ; preds = %21, %4
ret void
}