#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 pr(double *, double, int, double);
double int_p2(double *pars, double d_max, int n_c, int nslice) {
  double sum = 0.0;
  double r;
  double value;
  int i;
  for (i = 0; i < nslice; i++) {
    r = d_max / (1.0 * nslice) * i;
    value = pr(pars, d_max, n_c, r);
    sum += value * value;
  }
  return sum / (1.0 * nslice) * d_max;
}


x86 assembly (clang, -O0):
<int_p2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11af <int_p2+0x9f>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm2
movsd  0xeac(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x34(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%esi
movsd  -0x28(%rbp),%xmm1
call   1030 <pr@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <int_p2+0x26>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm2
movsd  0xe3f(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_p2>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
cvtsi2sd %edx,%xmm1
test   %edx,%edx
movsd  %xmm1,0x10(%rsp)
jle    11a0 <int_p2+0x90>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%rbp
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rsp)
xorpd  %xmm2,%xmm2
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  0x18(%rsp),%xmm1
mulsd  %xmm2,%xmm1
mov    %rbp,%rdi
movsd  0x8(%rsp),%xmm0
mov    %r14d,%esi
call   1030 <pr@plt>
movsd  0x20(%rsp),%xmm2
movsd  0x28(%rsp),%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  0xe67(%rip),%xmm2
add    $0xffffffff,%ebx
jne    1150 <int_p2+0x40>
jmp    11a4 <int_p2+0x94>
xorpd  %xmm1,%xmm1
divsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @int_p2(double* %0, double %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store double* %0, double** %5
store double %1, double* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %9
store i32 0, i32* %12
br label %13
13: ; preds = %35, %4
%14 = load i32, i32* %12
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = load double, double* %6
%19 = load i32, i32* %8
%20 = sitofp i32 %19 to double
%21 = fmul double 1.000000e+00, %20
%22 = fdiv double %18, %21
%23 = load i32, i32* %12
%24 = sitofp i32 %23 to double
%25 = fmul double %22, %24
store double %25, double* %10
%26 = load double*, double** %5
%27 = load double, double* %6
%28 = load i32, i32* %7
%29 = load double, double* %10
%30 = call double @pr(double* %26, double %27, i32 %28, double %29)
store double %30, double* %11
%31 = load double, double* %11
%32 = load double, double* %11
%33 = load double, double* %9
%34 = call double @llvm.fmuladd.f64(double %31, double %32, double %33)
store double %34, double* %9
br label %35
35: ; preds = %17
%36 = load i32, i32* %12
%37 = add nsw i32 %36, 1
store i32 %37, i32* %12
br label %13
38: ; preds = %13
%39 = load double, double* %9
%40 = load i32, i32* %8
%41 = sitofp i32 %40 to double
%42 = fmul double 1.000000e+00, %41
%43 = fdiv double %39, %42
%44 = load double, double* %6
%45 = fmul double %43, %44
ret double %45
}

LLVM IR (-O2):
define double @int_p2(double* %0, double %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
%6 = sitofp i32 %3 to double
br i1 %5, label %7, label %18
7: ; preds = %4
%8 = fdiv double %1, %6
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ 0, %7 ], [ %16, %9 ]
%11 = phi double [ 0.000000e+00, %7 ], [ %15, %9 ]
%12 = sitofp i32 %10 to double
%13 = fmul double %8, %12
%14 = tail call double @pr(double* %0, double %1, i32 %2, double %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %11)
%16 = add nuw nsw i32 %10, 1
%17 = icmp eq i32 %16, %3
br i1 %17, label %18, label %9
18: ; preds = %9, %4
%19 = phi double [ 0.000000e+00, %4 ], [ %15, %9 ]
%20 = fdiv double %19, %6
%21 = fmul double %20, %1
ret double %21
}