#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_pr(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;
  }
  return sum / (1.0 * nslice) * d_max;
}


x86 assembly (clang, -O0):
<int_pr>:
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    11a2 <int_pr+0x92>
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
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <int_pr+0x26>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm2
movsd  0xe4c(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_pr>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
cvtsi2sd %edx,%xmm1
test   %edx,%edx
movsd  %xmm1,0x10(%rsp)
jle    119c <int_pr+0x8c>
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
addsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  0xe6b(%rip),%xmm2
add    $0xffffffff,%ebx
jne    1150 <int_pr+0x40>
jmp    11a0 <int_pr+0x90>
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_pr(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 = %34, %4
%14 = load i32, i32* %12
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %37
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* %9
%33 = fadd double %32, %31
store double %33, double* %9
br label %34
34: ; preds = %17
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
br label %13
37: ; preds = %13
%38 = load double, double* %9
%39 = load i32, i32* %8
%40 = sitofp i32 %39 to double
%41 = fmul double 1.000000e+00, %40
%42 = fdiv double %38, %41
%43 = load double, double* %6
%44 = fmul double %42, %43
ret double %44
}

LLVM IR (-O2):
define double @int_pr(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 = fadd double %11, %14
%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
}