#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 sqrt(double);
void transformGrid_FM06(int n, double *x, double *w, double zeta_P, double P) {
  double sigma = 1.0 / sqrt(zeta_P);
  double t = P - 7.0 * sigma;
  double rmin = (t > 0.0) ? t : 0.0;
  double rmax = P + 9.0 * sigma;
  double i1 = 0.5 * (rmax - rmin);
  double i2 = 0.5 * (rmax + rmin);
  int i;
  for (i = 0; i < n; i++) {
    x[i] = i1 * x[i] + i2;
    w[i] *= i1;
  }
}


x86 assembly (clang, -O0):
<transformGrid_FM06>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xec6(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xea3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    118b <transformGrid_FM06+0x7b>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1198 <transformGrid_FM06+0x88>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1198 <transformGrid_FM06+0x88>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xe64(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  0xe3d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xe22(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    125b <transformGrid_FM06+0x14b>
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11fe <transformGrid_FM06+0xee>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transformGrid_FM06>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jb     1137 <transformGrid_FM06+0x27>
sqrtsd %xmm0,%xmm0
test   %ebp,%ebp
jg     1154 <transformGrid_FM06+0x44>
jmp    1313 <transformGrid_FM06+0x203>
movsd  %xmm1,0x8(%rsp)
call   1030 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x8(%rsp),%xmm1
test   %ebp,%ebp
jle    1313 <transformGrid_FM06+0x203>
movsd  0xea4(%rip),%xmm5
divsd  %xmm0,%xmm5
movsd  0xea0(%rip),%xmm2
mulsd  %xmm5,%xmm2
addsd  %xmm1,%xmm2
maxsd  %xmm3,%xmm2
mulsd  0xe94(%rip),%xmm5
addsd  %xmm1,%xmm5
movapd %xmm5,%xmm0
subsd  %xmm2,%xmm0
movsd  0xe88(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm5
mulsd  %xmm3,%xmm5
mov    %ebp,%eax
cmp    $0x1,%ebp
je     11bd <transformGrid_FM06+0xad>
lea    (%r14,%rax,8),%rcx
cmp    %rbx,%rcx
jbe    1256 <transformGrid_FM06+0x146>
lea    (%rbx,%rax,8),%rcx
cmp    %r14,%rcx
jbe    1256 <transformGrid_FM06+0x146>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
test   $0x1,%al
je     11ef <transformGrid_FM06+0xdf>
movsd  (%rbx,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm5,%xmm2
movsd  %xmm2,(%rbx,%rcx,8)
movsd  (%r14,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%r14,%rcx,8)
or     $0x1,%rcx
add    %rax,%rdx
je     1313 <transformGrid_FM06+0x203>
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm5,%xmm2
movsd  %xmm2,(%rbx,%rcx,8)
movsd  (%r14,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%r14,%rcx,8)
movsd  0x8(%rbx,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm5,%xmm2
movsd  %xmm2,0x8(%rbx,%rcx,8)
movsd  0x8(%r14,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%r14,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%rax
jne    1200 <transformGrid_FM06+0xf0>
jmp    1313 <transformGrid_FM06+0x203>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
movapd %xmm5,%xmm3
unpcklpd %xmm5,%xmm3
lea    -0x2(%rcx),%rdx
mov    %rdx,%rsi
shr    %rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     131c <transformGrid_FM06+0x20c>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rdx,8),%xmm4
mulpd  %xmm2,%xmm4
addpd  %xmm3,%xmm4
movupd %xmm4,(%rbx,%rdx,8)
movupd (%r14,%rdx,8),%xmm4
mulpd  %xmm2,%xmm4
movupd %xmm4,(%r14,%rdx,8)
movupd 0x10(%rbx,%rdx,8),%xmm4
mulpd  %xmm2,%xmm4
addpd  %xmm3,%xmm4
movupd %xmm4,0x10(%rbx,%rdx,8)
movupd 0x10(%r14,%rdx,8),%xmm4
mulpd  %xmm2,%xmm4
movupd %xmm4,0x10(%r14,%rdx,8)
add    $0x4,%rdx
add    $0xfffffffffffffffe,%rdi
jne    1290 <transformGrid_FM06+0x180>
test   $0x1,%sil
je     130a <transformGrid_FM06+0x1fa>
movupd (%rbx,%rdx,8),%xmm4
mulpd  %xmm2,%xmm4
addpd  %xmm3,%xmm4
movupd %xmm4,(%rbx,%rdx,8)
movupd (%r14,%rdx,8),%xmm3
mulpd  %xmm2,%xmm3
movupd %xmm3,(%r14,%rdx,8)
cmp    %rax,%rcx
jne    11bf <transformGrid_FM06+0xaf>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edx,%edx
test   $0x1,%sil
jne    12e8 <transformGrid_FM06+0x1d8>
jmp    130a <transformGrid_FM06+0x1fa>

LLVM IR (-O0):
define void @transformGrid_FM06(i32 %0, double* %1, double* %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
store i32 %0, i32* %6
store double* %1, double** %7
store double* %2, double** %8
store double %3, double* %9
store double %4, double* %10
%18 = load double, double* %9
%19 = call double @sqrt(double %18)
%20 = fdiv double 1.000000e+00, %19
store double %20, double* %11
%21 = load double, double* %10
%22 = load double, double* %11
%23 = call double @llvm.fmuladd.f64(double -7.000000e+00, double %22, double %21)
store double %23, double* %12
%24 = load double, double* %12
%25 = fcmp ogt double %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %5
%27 = load double, double* %12
br label %29
28: ; preds = %5
br label %29
29: ; preds = %28, %26
%30 = phi double [ %27, %26 ], [ 0.000000e+00, %28 ]
store double %30, double* %13
%31 = load double, double* %10
%32 = load double, double* %11
%33 = call double @llvm.fmuladd.f64(double 9.000000e+00, double %32, double %31)
store double %33, double* %14
%34 = load double, double* %14
%35 = load double, double* %13
%36 = fsub double %34, %35
%37 = fmul double 5.000000e-01, %36
store double %37, double* %15
%38 = load double, double* %14
%39 = load double, double* %13
%40 = fadd double %38, %39
%41 = fmul double 5.000000e-01, %40
store double %41, double* %16
store i32 0, i32* %17
br label %42
42: ; preds = %66, %29
%43 = load i32, i32* %17
%44 = load i32, i32* %6
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %69
46: ; preds = %42
%47 = load double, double* %15
%48 = load double*, double** %7
%49 = load i32, i32* %17
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = load double, double* %16
%54 = call double @llvm.fmuladd.f64(double %47, double %52, double %53)
%55 = load double*, double** %7
%56 = load i32, i32* %17
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
store double %54, double* %58
%59 = load double, double* %15
%60 = load double*, double** %8
%61 = load i32, i32* %17
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = fmul double %64, %59
store double %65, double* %63
br label %66
66: ; preds = %46
%67 = load i32, i32* %17
%68 = add nsw i32 %67, 1
store i32 %68, i32* %17
br label %42
69: ; preds = %42
ret void
}

LLVM IR (-O2):
define void @transformGrid_FM06(i32 %0, double* nocapture %1, double* nocapture %2, double %3, double %4) {
%6 = tail call double @sqrt(double %3)
%7 = fdiv double 1.000000e+00, %6
%8 = tail call double @llvm.fmuladd.f64(double %7, double -7.000000e+00, double %4)
%9 = fcmp ogt double %8, 0.000000e+00
%10 = select i1 %9, double %8, double 0.000000e+00
%11 = tail call double @llvm.fmuladd.f64(double %7, double 9.000000e+00, double %4)
%12 = fsub double %11, %10
%13 = fmul double %12, 5.000000e-01
%14 = fadd double %11, %10
%15 = fmul double %14, 5.000000e-01
%16 = icmp sgt i32 %0, 0
br i1 %16, label %17, label %116
17: ; preds = %5
%18 = zext i32 %0 to i64
%19 = icmp eq i32 %0, 1
br i1 %19, label %82, label %20
20: ; preds = %17
%21 = getelementptr double, double* %1, i64 %18
%22 = getelementptr double, double* %2, i64 %18
%23 = icmp ugt double* %22, %1
%24 = icmp ugt double* %21, %2
%25 = and i1 %23, %24
br i1 %25, label %82, label %26
26: ; preds = %20
%27 = and i64 %18, 4294967294
%28 = insertelement <2 x double> poison, double %13, i64 0
%29 = shufflevector <2 x double> %28, <2 x double> poison, <2 x i32> zeroinitializer
%30 = insertelement <2 x double> poison, double %15, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = add nsw i64 %27, -2
%33 = lshr exact i64 %32, 1
%34 = add nuw i64 %33, 1
%35 = and i64 %34, 1
%36 = icmp eq i64 %32, 0
br i1 %36, label %66, label %37
37: ; preds = %26
%38 = and i64 %34, -2
br label %39
39: ; preds = %39, %37
%40 = phi i64 [ 0, %37 ], [ %63, %39 ]
%41 = phi i64 [ 0, %37 ], [ %64, %39 ]
%42 = getelementptr inbounds double, double* %1, i64 %40
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %44, <2 x double> %31)
%46 = bitcast double* %42 to <2 x double>*
store <2 x double> %45, <2 x double>* %46
%47 = getelementptr inbounds double, double* %2, i64 %40
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = fmul <2 x double> %29, %49
%51 = bitcast double* %47 to <2 x double>*
store <2 x double> %50, <2 x double>* %51
%52 = or i64 %40, 2
%53 = getelementptr inbounds double, double* %1, i64 %52
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %55, <2 x double> %31)
%57 = bitcast double* %53 to <2 x double>*
store <2 x double> %56, <2 x double>* %57
%58 = getelementptr inbounds double, double* %2, i64 %52
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = fmul <2 x double> %29, %60
%62 = bitcast double* %58 to <2 x double>*
store <2 x double> %61, <2 x double>* %62
%63 = add nuw i64 %40, 4
%64 = add nuw i64 %41, 2
%65 = icmp eq i64 %64, %38
br i1 %65, label %66, label %39
66: ; preds = %39, %26
%67 = phi i64 [ 0, %26 ], [ %63, %39 ]
%68 = icmp eq i64 %35, 0
br i1 %68, label %80, label %69
69: ; preds = %66
%70 = getelementptr inbounds double, double* %1, i64 %67
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %72, <2 x double> %31)
%74 = bitcast double* %70 to <2 x double>*
store <2 x double> %73, <2 x double>* %74
%75 = getelementptr inbounds double, double* %2, i64 %67
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = fmul <2 x double> %29, %77
%79 = bitcast double* %75 to <2 x double>*
store <2 x double> %78, <2 x double>* %79
br label %80
80: ; preds = %66, %69
%81 = icmp eq i64 %27, %18
br i1 %81, label %116, label %82
82: ; preds = %20, %17, %80
%83 = phi i64 [ 0, %20 ], [ 0, %17 ], [ %27, %80 ]
%84 = xor i64 %83, -1
%85 = and i64 %18, 1
%86 = icmp eq i64 %85, 0
br i1 %86, label %95, label %87
87: ; preds = %82
%88 = getelementptr inbounds double, double* %1, i64 %83
%89 = load double, double* %88
%90 = tail call double @llvm.fmuladd.f64(double %13, double %89, double %15)
store double %90, double* %88
%91 = getelementptr inbounds double, double* %2, i64 %83
%92 = load double, double* %91
%93 = fmul double %13, %92
store double %93, double* %91
%94 = or i64 %83, 1
br label %95
95: ; preds = %87, %82
%96 = phi i64 [ %83, %82 ], [ %94, %87 ]
%97 = sub nsw i64 0, %18
%98 = icmp eq i64 %84, %97
br i1 %98, label %116, label %99
99: ; preds = %95, %99
%100 = phi i64 [ %114, %99 ], [ %96, %95 ]
%101 = getelementptr inbounds double, double* %1, i64 %100
%102 = load double, double* %101
%103 = tail call double @llvm.fmuladd.f64(double %13, double %102, double %15)
store double %103, double* %101
%104 = getelementptr inbounds double, double* %2, i64 %100
%105 = load double, double* %104
%106 = fmul double %13, %105
store double %106, double* %104
%107 = add nuw nsw i64 %100, 1
%108 = getelementptr inbounds double, double* %1, i64 %107
%109 = load double, double* %108
%110 = tail call double @llvm.fmuladd.f64(double %13, double %109, double %15)
store double %110, double* %108
%111 = getelementptr inbounds double, double* %2, i64 %107
%112 = load double, double* %111
%113 = fmul double %13, %112
store double %113, double* %111
%114 = add nuw nsw i64 %100, 2
%115 = icmp eq i64 %114, %18
br i1 %115, label %116, label %99
116: ; preds = %95, %99, %80, %5
ret void
}