void approx2(int m, int a[], double p[], double pp[][20], double p3[][20][20],
             double p4[][20][20][20], double *rec, int *idet) {
  double pra, rec2;
  double cond2(int, int[], double[], double[][20], double[][20][20],
               double[][20][20][20], int *);
  int ii, a1, a2, a3, idt, m1, a4;
  a1 = a[1];
  a2 = a[2];
  a3 = a[3];
  a4 = a[4];
  m1 = 3;
  m1 = 4;
  rec2 = p4[a1][a2][a3][a4] + pp[a1][a2] * pp[a3][a4];
  *idet = 1;
  for (ii = 5; ii <= m; ii++) {
    pra = cond2(ii, a, p, pp, p3, p4, &idt);
    rec2 *= pra;
    if (idt == 0)
      *idet = 0;
  }
  *rec = rec2;
}


x86 assembly (clang, -O0):
<approx2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x5c(%rbp)
movl   $0x3,-0x58(%rbp)
movl   $0x4,-0x58(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x48(%rbp),%rcx
imul   $0xfa00,%rcx,%rcx
add    %rcx,%rax
movslq -0x4c(%rbp),%rcx
imul   $0xc80,%rcx,%rcx
add    %rcx,%rax
movslq -0x50(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x48(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x50(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x5,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1263 <approx2+0x153>
mov    -0x44(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    -0x54(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <cond2@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    1250 <approx2+0x140>
mov    0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    1255 <approx2+0x145>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11f8 <approx2+0xe8>
movsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approx2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r15
mov    %r8,0x18(%rsp)
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x68(%rsp),%r9
movslq 0x4(%rsi),%rax
movslq 0x8(%rsi),%rcx
movslq 0xc(%rsi),%rdx
movslq 0x10(%rsi),%r8
imul   $0xfa00,%rax,%rdi
add    %r15,%rdi
imul   $0xc80,%rcx,%rsi
add    %rdi,%rsi
shl    $0x5,%rdx
lea    (%rdx,%rdx,4),%rdx
add    %rdx,%rsi
lea    (%rax,%rax,4),%rax
shl    $0x5,%rax
add    %r13,%rax
movsd  (%rax,%rcx,8),%xmm0
add    %r13,%rdx
mulsd  (%rdx,%r8,8),%xmm0
addsd  (%rsi,%r8,8),%xmm0
movl   $0x1,(%r9)
cmp    $0x5,%ebp
jge    11a8 <approx2+0x98>
mov    0x60(%rsp),%rax
movsd  %xmm0,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
neg    %ebp
mov    $0x5,%r14d
jmp    11e3 <approx2+0xd3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    (%r14,%rbp,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
mov    %ecx,%r14d
cmp    $0x1,%eax
je     1190 <approx2+0x80>
movsd  %xmm0,0x20(%rsp)
lea    0x14(%rsp),%rax
mov    %rax,(%rsp)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    0x18(%rsp),%r8
mov    %r15,%r9
call   1030 <cond2@plt>
cmpl   $0x0,0x14(%rsp)
jne    11c0 <approx2+0xb0>
mov    0x68(%rsp),%rax
movl   $0x0,(%rax)
jmp    11c0 <approx2+0xb0>

LLVM IR (-O0):
define void @approx2(i32 %0, i32* %1, double* %2, [20 x double]* %3, [20 x [20 x double]]* %4, [20 x [20 x [20 x double]]]* %5, double* %6, i32* %7) {
%9 = alloca i32
%10 = alloca i32*
%11 = alloca double*
%12 = alloca [20 x double]*
%13 = alloca [20 x [20 x double]]*
%14 = alloca [20 x [20 x [20 x double]]]*
%15 = alloca double*
%16 = alloca i32*
%17 = alloca double
%18 = alloca double
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
store i32 %0, i32* %9
store i32* %1, i32** %10
store double* %2, double** %11
store [20 x double]* %3, [20 x double]** %12
store [20 x [20 x double]]* %4, [20 x [20 x double]]** %13
store [20 x [20 x [20 x double]]]* %5, [20 x [20 x [20 x double]]]** %14
store double* %6, double** %15
store i32* %7, i32** %16
%26 = load i32*, i32** %10
%27 = getelementptr inbounds i32, i32* %26, i64 1
%28 = load i32, i32* %27
store i32 %28, i32* %20
%29 = load i32*, i32** %10
%30 = getelementptr inbounds i32, i32* %29, i64 2
%31 = load i32, i32* %30
store i32 %31, i32* %21
%32 = load i32*, i32** %10
%33 = getelementptr inbounds i32, i32* %32, i64 3
%34 = load i32, i32* %33
store i32 %34, i32* %22
%35 = load i32*, i32** %10
%36 = getelementptr inbounds i32, i32* %35, i64 4
%37 = load i32, i32* %36
store i32 %37, i32* %25
store i32 3, i32* %24
store i32 4, i32* %24
%38 = load [20 x [20 x [20 x double]]]*, [20 x [20 x [20 x double]]]** %14
%39 = load i32, i32* %20
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [20 x [20 x [20 x double]]], [20 x [20 x [20 x double]]]* %38, i64 %40
%42 = load i32, i32* %21
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [20 x [20 x [20 x double]]], [20 x [20 x [20 x double]]]* %41, i64 0, i64 %43
%45 = load i32, i32* %22
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [20 x [20 x double]], [20 x [20 x double]]* %44, i64 0, i64 %46
%48 = load i32, i32* %25
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [20 x double], [20 x double]* %47, i64 0, i64 %49
%51 = load double, double* %50
%52 = load [20 x double]*, [20 x double]** %12
%53 = load i32, i32* %20
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [20 x double], [20 x double]* %52, i64 %54
%56 = load i32, i32* %21
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [20 x double], [20 x double]* %55, i64 0, i64 %57
%59 = load double, double* %58
%60 = load [20 x double]*, [20 x double]** %12
%61 = load i32, i32* %22
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [20 x double], [20 x double]* %60, i64 %62
%64 = load i32, i32* %25
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [20 x double], [20 x double]* %63, i64 0, i64 %65
%67 = load double, double* %66
%68 = call double @llvm.fmuladd.f64(double %59, double %67, double %51)
store double %68, double* %18
%69 = load i32*, i32** %16
store i32 1, i32* %69
store i32 5, i32* %19
br label %70
70: ; preds = %90, %8
%71 = load i32, i32* %19
%72 = load i32, i32* %9
%73 = icmp sle i32 %71, %72
br i1 %73, label %74, label %93
74: ; preds = %70
%75 = load i32, i32* %19
%76 = load i32*, i32** %10
%77 = load double*, double** %11
%78 = load [20 x double]*, [20 x double]** %12
%79 = load [20 x [20 x double]]*, [20 x [20 x double]]** %13
%80 = load [20 x [20 x [20 x double]]]*, [20 x [20 x [20 x double]]]** %14
%81 = call double @cond2(i32 %75, i32* %76, double* %77, [20 x double]* %78, [20 x [20 x double]]* %79, [20 x [20 x [20 x double]]]* %80, i32* %23)
store double %81, double* %17
%82 = load double, double* %17
%83 = load double, double* %18
%84 = fmul double %83, %82
store double %84, double* %18
%85 = load i32, i32* %23
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %74
%88 = load i32*, i32** %16
store i32 0, i32* %88
br label %89
89: ; preds = %87, %74
br label %90
90: ; preds = %89
%91 = load i32, i32* %19
%92 = add nsw i32 %91, 1
store i32 %92, i32* %19
br label %70
93: ; preds = %70
%94 = load double, double* %18
%95 = load double*, double** %15
store double %94, double* %95
ret void
}

LLVM IR (-O2):
define void @approx2(i32 %0, i32* %1, double* %2, [20 x double]* %3, [20 x [20 x double]]* %4, [20 x [20 x [20 x double]]]* %5, double* nocapture writeonly %6, i32* nocapture writeonly %7) {
%9 = alloca i32
%10 = bitcast i32* %9 to i8*
%11 = getelementptr inbounds i32, i32* %1, i64 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds i32, i32* %1, i64 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds i32, i32* %1, i64 3
%16 = load i32, i32* %15
%17 = getelementptr inbounds i32, i32* %1, i64 4
%18 = load i32, i32* %17
%19 = sext i32 %12 to i64
%20 = sext i32 %14 to i64
%21 = sext i32 %16 to i64
%22 = sext i32 %18 to i64
%23 = getelementptr inbounds [20 x [20 x [20 x double]]], [20 x [20 x [20 x double]]]* %5, i64 %19, i64 %20, i64 %21, i64 %22
%24 = load double, double* %23
%25 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 %19, i64 %20
%26 = load double, double* %25
%27 = getelementptr inbounds [20 x double], [20 x double]* %3, i64 %21, i64 %22
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %26, double %28, double %24)
store i32 1, i32* %7
%30 = icmp slt i32 %0, 5
br i1 %30, label %42, label %31
31: ; preds = %8, %39
%32 = phi double [ %35, %39 ], [ %29, %8 ]
%33 = phi i32 [ %40, %39 ], [ 5, %8 ]
%34 = call double @cond2(i32 %33, i32* %1, double* %2, [20 x double]* %3, [20 x [20 x double]]* %4, [20 x [20 x [20 x double]]]* %5, i32* %9)
%35 = fmul double %32, %34
%36 = load i32, i32* %9
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %31
store i32 0, i32* %7
br label %39
39: ; preds = %31, %38
%40 = add nuw i32 %33, 1
%41 = icmp eq i32 %33, %0
br i1 %41, label %42, label %31
42: ; preds = %39, %8
%43 = phi double [ %29, %8 ], [ %35, %39 ]
store double %43, double* %6
ret void
}