#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*/ printf(char *, int);
void approx1(double w[], double x[], double r[][20], int m, int a[], double p[],
             double pp[][20], double *rec, int *idet) {
  double pra, rec2;
  double lb[8], ub[8], eps, bound, s[22];
  int ii, a1, a2, idt, ifault, m1, inf[8];
  void mulnor(double[], double[], double[], double, int, int[], double *,
              double *, int *);
  double cond1(int, int[], double[], double[][20], int *);
  a1 = a[1];
  a2 = a[2];
  m1 = 2;
  inf[0] = 2;
  inf[1] = 2;
  eps = 1.e-6;
  lb[0] = w[a1];
  lb[1] = w[a2];
  ub[0] = x[a1];
  ub[1] = x[a2];
  s[0] = r[a1][a2];
  mulnor(ub, lb, s, eps, m1, inf, &rec2, &bound, &ifault);
  if (ifault != 0)
    printf("error in mulnor %d\n", ifault);
  *idet = 1;
  for (ii = 3; ii <= m; ii++) {
    pra = cond1(ii, a, p, pp, &idt);
    rec2 *= pra;
    if (idt == 0)
      *idet = 0;
  }
  *rec = rec2;
}


x86 assembly (clang, -O0):
<approx1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x188(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x18c(%rbp)
movl   $0x2,-0x198(%rbp)
movl   $0x2,-0x1c0(%rbp)
movl   $0x2,-0x1bc(%rbp)
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x8(%rbp),%rax
movslq -0x188(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x188(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
mov    -0x10(%rbp),%rax
movslq -0x18c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x18(%rbp),%rax
movslq -0x188(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x18c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x180(%rbp)
ff
lea    -0xc0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x180(%rbp),%rdx
movsd  -0xc8(%rbp),%xmm0
ff
mov    -0x198(%rbp),%ecx
lea    -0x1c0(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0xd0(%rbp),%r10
lea    -0x194(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <mulnor@plt>
cmpl   $0x0,-0x194(%rbp)
je     128f <approx1+0x15f>
mov    -0x194(%rbp),%esi
lea    0xd7e(%rip),%rdi
call   1040 <printf@plt>
mov    0x20(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x3,-0x184(%rbp)
mov    -0x184(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1314 <approx1+0x1e4>
mov    -0x184(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    0x10(%rbp),%rcx
lea    -0x190(%rbp),%r8
call   1030 <cond1@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x0,-0x190(%rbp)
jne    12fb <approx1+0x1cb>
mov    0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    1300 <approx1+0x1d0>
mov    -0x184(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x184(%rbp)
jmp    12a3 <approx1+0x173>
movsd  -0x40(%rbp),%xmm0
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approx1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x178,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %ecx,%ebx
movslq 0x4(%r8),%rax
movslq 0x8(%r8),%rcx
movabs $0x200000002,%rbp
mov    %rbp,0x20(%rsp)
movsd  (%rdi,%rax,8),%xmm0
movsd  %xmm0,0x80(%rsp)
movsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x88(%rsp)
movsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x48(%rsp)
lea    (%rax,%rax,4),%rax
shl    $0x5,%rax
add    %rdx,%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,0xc0(%rsp)
lea    0x10(%rsp),%rax
lea    0x18(%rsp),%rbp
lea    0x40(%rsp),%rdi
lea    0x80(%rsp),%rsi
lea    0xc0(%rsp),%rdx
movsd  0xe2e(%rip),%xmm0
lea    0x20(%rsp),%r8
lea    0x8(%rsp),%r9
mov    $0x2,%ecx
push   %rax
push   %rbp
call   1050 <mulnor@plt>
add    $0x10,%rsp
mov    0x10(%rsp),%esi
test   %esi,%esi
je     1200 <approx1+0xd0>
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
mov    0x1c0(%rsp),%rax
movl   $0x1,(%rax)
cmp    $0x3,%ebx
jge    1237 <approx1+0x107>
movsd  0x8(%rsp),%xmm0
mov    0x1b8(%rsp),%rax
movsd  %xmm0,(%rax)
add    $0x178,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x1b0(%rsp),%r12
neg    %ebx
mov    $0x3,%ebp
lea    0x14(%rsp),%r13
jmp    1262 <approx1+0x132>
nopl   (%rax)
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     1219 <approx1+0xe9>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <cond1@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
cmpl   $0x0,0x14(%rsp)
jne    1250 <approx1+0x120>
mov    0x1c0(%rsp),%rax
movl   $0x0,(%rax)
jmp    1250 <approx1+0x120>

LLVM IR (-O0):
@.str = [20 x i8] c"error in mulnor %d\0A\00"
define void @approx1(double* %0, double* %1, [20 x double]* %2, i32 %3, i32* %4, double* %5, [20 x double]* %6, double* %7, i32* %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca [20 x double]*
%13 = alloca i32
%14 = alloca i32*
%15 = alloca double*
%16 = alloca [20 x double]*
%17 = alloca double*
%18 = alloca i32*
%19 = alloca double
%20 = alloca double
%21 = alloca [8 x double]
%22 = alloca [8 x double]
%23 = alloca double
%24 = alloca double
%25 = alloca [22 x double]
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca [8 x i32]
store double* %0, double** %10
store double* %1, double** %11
store [20 x double]* %2, [20 x double]** %12
store i32 %3, i32* %13
store i32* %4, i32** %14
store double* %5, double** %15
store [20 x double]* %6, [20 x double]** %16
store double* %7, double** %17
store i32* %8, i32** %18
%33 = load i32*, i32** %14
%34 = getelementptr inbounds i32, i32* %33, i64 1
%35 = load i32, i32* %34
store i32 %35, i32* %27
%36 = load i32*, i32** %14
%37 = getelementptr inbounds i32, i32* %36, i64 2
%38 = load i32, i32* %37
store i32 %38, i32* %28
store i32 2, i32* %31
%39 = getelementptr inbounds [8 x i32], [8 x i32]* %32, i64 0, i64 0
store i32 2, i32* %39
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %32, i64 0, i64 1
store i32 2, i32* %40
store double 0x3EB0C6F7A0B5ED8D, double* %23
%41 = load double*, double** %10
%42 = load i32, i32* %27
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 0
store double %45, double* %46
%47 = load double*, double** %10
%48 = load i32, i32* %28
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 1
store double %51, double* %52
%53 = load double*, double** %11
%54 = load i32, i32* %27
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = getelementptr inbounds [8 x double], [8 x double]* %22, i64 0, i64 0
store double %57, double* %58
%59 = load double*, double** %11
%60 = load i32, i32* %28
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
%63 = load double, double* %62
%64 = getelementptr inbounds [8 x double], [8 x double]* %22, i64 0, i64 1
store double %63, double* %64
%65 = load [20 x double]*, [20 x double]** %12
%66 = load i32, i32* %27
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [20 x double], [20 x double]* %65, i64 %67
%69 = load i32, i32* %28
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [20 x double], [20 x double]* %68, i64 0, i64 %70
%72 = load double, double* %71
%73 = getelementptr inbounds [22 x double], [22 x double]* %25, i64 0, i64 0
store double %72, double* %73
%74 = getelementptr inbounds [8 x double], [8 x double]* %22, i64 0, i64 0
%75 = getelementptr inbounds [8 x double], [8 x double]* %21, i64 0, i64 0
%76 = getelementptr inbounds [22 x double], [22 x double]* %25, i64 0, i64 0
%77 = load double, double* %23
%78 = load i32, i32* %31
%79 = getelementptr inbounds [8 x i32], [8 x i32]* %32, i64 0, i64 0
%80 = load i32, i32* %30
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %9
%83 = load i32, i32* %30
%84 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %83)
br label %85
85: ; preds = %82, %9
%86 = load i32*, i32** %18
store i32 1, i32* %86
store i32 3, i32* %26
br label %87
87: ; preds = %105, %85
%88 = load i32, i32* %26
%89 = load i32, i32* %13
%90 = icmp sle i32 %88, %89
br i1 %90, label %91, label %108
91: ; preds = %87
%92 = load i32, i32* %26
%93 = load i32*, i32** %14
%94 = load double*, double** %15
%95 = load [20 x double]*, [20 x double]** %16
%96 = call double @cond1(i32 %92, i32* %93, double* %94, [20 x double]* %95, i32* %29)
store double %96, double* %19
%97 = load double, double* %19
%98 = load double, double* %20
%99 = fmul double %98, %97
store double %99, double* %20
%100 = load i32, i32* %29
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %91
%103 = load i32*, i32** %18
store i32 0, i32* %103
br label %104
104: ; preds = %102, %91
br label %105
105: ; preds = %104
%106 = load i32, i32* %26
%107 = add nsw i32 %106, 1
store i32 %107, i32* %26
br label %87
108: ; preds = %87
%109 = load double, double* %20
%110 = load double*, double** %17
store double %109, double* %110
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"error in mulnor %d\0A\00"
define void @approx1(double* nocapture %0, double* nocapture %1, [20 x double]* nocapture %2, i32 %3, i32* %4, double* %5, [20 x double]* %6, double* nocapture writeonly %7, i32* nocapture writeonly %8) {
%10 = alloca double
%11 = alloca [8 x double]
%12 = alloca [8 x double]
%13 = alloca double
%14 = alloca [22 x double]
%15 = alloca i32
%16 = alloca i32
%17 = alloca [8 x i32]
%18 = bitcast double* %10 to i8*
%19 = bitcast [8 x double]* %11 to i8*
%20 = bitcast [8 x double]* %12 to i8*
%21 = bitcast double* %13 to i8*
%22 = bitcast [22 x double]* %14 to i8*
%23 = bitcast i32* %15 to i8*
%24 = bitcast i32* %16 to i8*
%25 = bitcast [8 x i32]* %17 to i8*
%26 = getelementptr inbounds i32, i32* %4, i64 1
%27 = load i32, i32* %26
%28 = getelementptr inbounds i32, i32* %4, i64 2
%29 = load i32, i32* %28
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %17, i64 0, i64 0
store i32 2, i32* %30
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %17, i64 0, i64 1
store i32 2, i32* %31
%32 = sext i32 %27 to i64
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = load double, double* %33
%35 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 0
store double %34, double* %35
%36 = sext i32 %29 to i64
%37 = getelementptr inbounds double, double* %0, i64 %36
%38 = load double, double* %37
%39 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 1
store double %38, double* %39
%40 = getelementptr inbounds double, double* %1, i64 %32
%41 = load double, double* %40
%42 = getelementptr inbounds [8 x double], [8 x double]* %12, i64 0, i64 0
store double %41, double* %42
%43 = getelementptr inbounds double, double* %1, i64 %36
%44 = load double, double* %43
%45 = getelementptr inbounds [8 x double], [8 x double]* %12, i64 0, i64 1
store double %44, double* %45
%46 = getelementptr inbounds [20 x double], [20 x double]* %2, i64 %32, i64 %36
%47 = load double, double* %46
%48 = getelementptr inbounds [22 x double], [22 x double]* %14, i64 0, i64 0
store double %47, double* %48
%49 = load i32, i32* %16
%50 = icmp eq i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %9
%52 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %49)
br label %53
53: ; preds = %51, %9
store i32 1, i32* %8
%54 = icmp slt i32 %3, 3
br i1 %54, label %55, label %57
55: ; preds = %53
%56 = load double, double* %10
br label %68
57: ; preds = %53, %65
%58 = phi i32 [ %66, %65 ], [ 3, %53 ]
%59 = call double @cond1(i32 %58, i32* %4, double* %5, [20 x double]* %6, i32* %15)
%60 = load double, double* %10
%61 = fmul double %59, %60
store double %61, double* %10
%62 = load i32, i32* %15
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %57
store i32 0, i32* %8
br label %65
65: ; preds = %57, %64
%66 = add nuw i32 %58, 1
%67 = icmp eq i32 %58, %3
br i1 %67, label %68, label %57
68: ; preds = %65, %55
%69 = phi double [ %56, %55 ], [ %61, %65 ]
store double %69, double* %7
ret void
}