#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*/ free(double *);
scalar_t__ malloc(int);
double sqrt(int);
void r_exchmvn(int *m, double *w, double *x, double *rh, double *eps,
               double *pr) {
  double r_g(double);
  double romberg(double (*)(double), double, double, double);
  int i;
  extern int mm;
  extern double *ww, *xx, rs, r1;
  mm = *m;
  rs = sqrt(*rh);
  r1 = sqrt(1. - (*rh));
  xx = (double *)malloc(mm * sizeof(double));
  ww = (double *)malloc(mm * sizeof(double));
  for (i = 0; i < mm; i++) {
    ww[i] = w[i];
    xx[i] = x[i];
  }
  *pr = romberg(r_g, -6., 6., *eps);
  free(xx);
  free(ww);
}


x86 assembly (clang, -O0):
<r_exchmvn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    0x2e8b(%rip),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cvttsd2si (%rax),%edi
call   1060 <sqrt@plt>
mov    0x2e35(%rip),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe6d(%rip),%xmm0
subsd  (%rax),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    0x2e49(%rip),%rax
movsd  %xmm0,(%rax)
mov    0x2e46(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    0x2dfe(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e24(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    0x2dd4(%rip),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2df8(%rip),%rcx
cmp    (%rcx),%eax
jge    1256 <r_exchmvn+0x116>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x2da4(%rip),%rax
mov    (%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x2d8c(%rip),%rax
mov    (%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11f6 <r_exchmvn+0xb6>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm2
mov    0x2d73(%rip),%rdi
movsd  0xd9b(%rip),%xmm0
movsd  0xd9b(%rip),%xmm1
call   1040 <romberg@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x2d3f(%rip),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r_exchmvn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%rbx
mov    (%rdi),%eax
mov    0x2e92(%rip),%rbp
mov    %eax,0x0(%rbp)
cvttsd2si (%rcx),%edi
call   1060 <sqrt@plt>
mov    0x2e3f(%rip),%rax
movsd  %xmm0,(%rax)
movsd  0xe7b(%rip),%xmm0
subsd  0x0(%r13),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    0x2e55(%rip),%rax
movsd  %xmm0,(%rax)
mov    0x0(%rbp),%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    0x2e17(%rip),%r13
mov    %rax,0x0(%r13)
mov    0x0(%rbp),%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    0x2df9(%rip),%rcx
mov    %rax,(%rcx)
mov    0x0(%rbp),%ecx
test   %ecx,%ecx
jle    13d7 <r_exchmvn+0x297>
mov    0x0(%r13),%rdx
cmp    $0x4,%ecx
jae    11e5 <r_exchmvn+0xa5>
xor    %esi,%esi
jmp    136d <r_exchmvn+0x22d>
mov    %r15,0x10(%rsp)
mov    %r14,0x8(%rsp)
lea    (%rax,%rcx,8),%rsi
lea    (%rdx,%rcx,8),%rbp
lea    (%rbx,%rcx,8),%rdi
lea    (%r12,%rcx,8),%r10
cmp    %rbp,%rax
setb   0x7(%rsp)
cmp    %rsi,%rdx
setb   %r15b
cmp    %rdi,%rax
setb   %r13b
cmp    %rbx,%rsi
seta   %r11b
cmp    %r10,%rax
setb   %r8b
cmp    %r12,%rsi
seta   %r14b
cmp    %rdi,%rdx
setb   %r9b
cmp    %rbx,%rbp
seta   %dil
cmp    %r10,%rdx
setb   %r10b
cmp    %r12,%rbp
seta   %bpl
xor    %esi,%esi
test   %r15b,0x7(%rsp)
jne    1355 <r_exchmvn+0x215>
and    %r11b,%r13b
mov    0x10(%rsp),%r15
jne    1361 <r_exchmvn+0x221>
and    %r14b,%r8b
mov    0x2d5d(%rip),%r13
jne    134e <r_exchmvn+0x20e>
and    %dil,%r9b
mov    0x8(%rsp),%r14
jne    136d <r_exchmvn+0x22d>
and    %bpl,%r10b
jne    136d <r_exchmvn+0x22d>
mov    %ecx,%esi
and    $0xfffffffc,%esi
lea    -0x4(%rsi),%rdi
mov    %rdi,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rdi,%rdi
je     1344 <r_exchmvn+0x204>
mov    %r8,%rbp
and    $0xfffffffffffffffe,%rbp
xor    %edi,%edi
xchg   %ax,%ax
movups (%rbx,%rdi,8),%xmm0
movups 0x10(%rbx,%rdi,8),%xmm1
movups %xmm0,(%rax,%rdi,8)
movups %xmm1,0x10(%rax,%rdi,8)
movups (%r12,%rdi,8),%xmm0
movups 0x10(%r12,%rdi,8),%xmm1
movups %xmm0,(%rdx,%rdi,8)
movups %xmm1,0x10(%rdx,%rdi,8)
movups 0x20(%rbx,%rdi,8),%xmm0
movups 0x30(%rbx,%rdi,8),%xmm1
movups %xmm0,0x20(%rax,%rdi,8)
movups %xmm1,0x30(%rax,%rdi,8)
movupd 0x20(%r12,%rdi,8),%xmm0
movups 0x30(%r12,%rdi,8),%xmm1
movupd %xmm0,0x20(%rdx,%rdi,8)
movups %xmm1,0x30(%rdx,%rdi,8)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rbp
jne    12b0 <r_exchmvn+0x170>
test   $0x1,%r8b
je     133a <r_exchmvn+0x1fa>
movups (%rbx,%rdi,8),%xmm0
movups 0x10(%rbx,%rdi,8),%xmm1
movups %xmm0,(%rax,%rdi,8)
movups %xmm1,0x10(%rax,%rdi,8)
movupd (%r12,%rdi,8),%xmm0
movups 0x10(%r12,%rdi,8),%xmm1
movupd %xmm0,(%rdx,%rdi,8)
movups %xmm1,0x10(%rdx,%rdi,8)
cmp    %rcx,%rsi
jne    136d <r_exchmvn+0x22d>
jmp    13d7 <r_exchmvn+0x297>
xor    %edi,%edi
test   $0x1,%r8b
jne    1312 <r_exchmvn+0x1d2>
jmp    133a <r_exchmvn+0x1fa>
mov    0x8(%rsp),%r14
jmp    136d <r_exchmvn+0x22d>
mov    0x8(%rsp),%r14
mov    0x10(%rsp),%r15
jmp    1366 <r_exchmvn+0x226>
mov    0x8(%rsp),%r14
mov    0x2c5b(%rip),%r13
mov    %rsi,%rdi
not    %rdi
test   $0x1,%cl
je     1391 <r_exchmvn+0x251>
movsd  (%rbx,%rsi,8),%xmm0
movsd  %xmm0,(%rax,%rsi,8)
movsd  (%r12,%rsi,8),%xmm0
movsd  %xmm0,(%rdx,%rsi,8)
or     $0x1,%rsi
add    %rcx,%rdi
je     13d7 <r_exchmvn+0x297>
cs nopw 0x0(%rax,%rax,1)
movsd  (%rbx,%rsi,8),%xmm0
movsd  %xmm0,(%rax,%rsi,8)
movsd  (%r12,%rsi,8),%xmm0
movsd  %xmm0,(%rdx,%rsi,8)
movsd  0x8(%rbx,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rax,%rsi,8)
movsd  0x8(%r12,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rdx,%rsi,8)
add    $0x2,%rsi
cmp    %rsi,%rcx
jne    13a0 <r_exchmvn+0x260>
movsd  (%r15),%xmm2
mov    0x2bf5(%rip),%rdi
movsd  0xc1d(%rip),%xmm0
movsd  0xc1d(%rip),%xmm1
call   1040 <romberg@plt>
movsd  %xmm0,(%r14)
mov    0x0(%r13),%rdi
call   1030 <free@plt>
mov    0x2bb3(%rip),%rax
mov    (%rax),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@mm = external global i32
@rs = external global double
@r1 = external global double
@xx = external global double*
@ww = external global double*
define void @r_exchmvn(i32* %0, double* %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca i32*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
store i32* %0, i32** %7
store double* %1, double** %8
store double* %2, double** %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
store i32 %15, i32* @mm
%16 = load double*, double** %10
%17 = load double, double* %16
%18 = fptosi double %17 to i32
%19 = call double @sqrt(i32 %18)
store double %19, double* @rs
%20 = load double*, double** %10
%21 = load double, double* %20
%22 = fsub double 1.000000e+00, %21
%23 = fptosi double %22 to i32
%24 = call double @sqrt(i32 %23)
store double %24, double* @r1
%25 = load i32, i32* @mm
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 8
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to double*
store double* %30, double** @xx
%31 = load i32, i32* @mm
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 8
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to double*
store double* %36, double** @ww
store i32 0, i32* %13
br label %37
37: ; preds = %60, %6
%38 = load i32, i32* %13
%39 = load i32, i32* @mm
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %63
41: ; preds = %37
%42 = load double*, double** %8
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = load double*, double** @ww
%48 = load i32, i32* %13
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
store double %46, double* %50
%51 = load double*, double** %9
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load double*, double** @xx
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %55, double* %59
br label %60
60: ; preds = %41
%61 = load i32, i32* %13
%62 = add nsw i32 %61, 1
store i32 %62, i32* %13
br label %37
63: ; preds = %37
%64 = load double*, double** %11
%65 = load double, double* %64
%66 = call double @romberg(double (double)* @r_g, double -6.000000e+00, double 6.000000e+00, double %65)
%67 = load double*, double** %12
store double %66, double* %67
%68 = load double*, double** @xx
%69 = call i32 @free(double* %68)
%70 = load double*, double** @ww
%71 = call i32 @free(double* %70)
ret void
}

LLVM IR (-O2):
@mm = external global i32
@rs = external global double
@r1 = external global double
@xx = external global double*
@ww = external global double*
define void @r_exchmvn(i32* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture writeonly %5) {
%7 = load i32, i32* %0
store i32 %7, i32* @mm
%8 = load double, double* %3
%9 = fptosi double %8 to i32
%10 = tail call double @sqrt(i32 %9)
store double %10, double* @rs
%11 = load double, double* %3
%12 = fsub double 1.000000e+00, %11
%13 = fptosi double %12 to i32
%14 = tail call double @sqrt(i32 %13)
store double %14, double* @r1
%15 = load i32, i32* @mm
%16 = shl i32 %15, 3
%17 = tail call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to double*
store double* %18, double** @xx
%19 = load i32, i32* @mm
%20 = shl i32 %19, 3
%21 = tail call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to double*
%23 = inttoptr i64 %21 to i8*
store double* %22, double** @ww
%24 = load i32, i32* @mm
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %173
26: ; preds = %6
%27 = load double*, double** @xx
%28 = zext i32 %24 to i64
%29 = icmp ult i32 %24, 4
br i1 %29, label %139, label %30
30: ; preds = %26
%31 = getelementptr double, double* %22, i64 %28
%32 = getelementptr double, double* %27, i64 %28
%33 = bitcast double* %32 to i8*
%34 = getelementptr double, double* %1, i64 %28
%35 = bitcast double* %34 to i8*
%36 = getelementptr double, double* %2, i64 %28
%37 = bitcast double* %36 to i8*
%38 = icmp ult i8* %23, %33
%39 = icmp ult double* %27, %31
%40 = and i1 %38, %39
%41 = icmp ult i8* %23, %35
%42 = icmp ugt double* %31, %1
%43 = and i1 %41, %42
%44 = or i1 %40, %43
%45 = icmp ult i8* %23, %37
%46 = icmp ugt double* %31, %2
%47 = and i1 %45, %46
%48 = or i1 %44, %47
%49 = icmp ult double* %27, %34
%50 = icmp ugt double* %32, %1
%51 = and i1 %49, %50
%52 = or i1 %48, %51
%53 = icmp ult double* %27, %36
%54 = icmp ugt double* %32, %2
%55 = and i1 %53, %54
%56 = or i1 %52, %55
br i1 %56, label %139, label %57
57: ; preds = %30
%58 = and i64 %28, 4294967292
%59 = add nsw i64 %58, -4
%60 = lshr exact i64 %59, 2
%61 = add nuw nsw i64 %60, 1
%62 = and i64 %61, 1
%63 = icmp eq i64 %59, 0
br i1 %63, label %113, label %64
64: ; preds = %57
%65 = and i64 %61, 9223372036854775806
br label %66
66: ; preds = %66, %64
%67 = phi i64 [ 0, %64 ], [ %110, %66 ]
%68 = phi i64 [ 0, %64 ], [ %111, %66 ]
%69 = getelementptr inbounds double, double* %1, i64 %67
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %69, i64 2
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = getelementptr inbounds double, double* %22, i64 %67
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %71, <2 x double>* %76
%77 = getelementptr inbounds double, double* %75, i64 2
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %74, <2 x double>* %78
%79 = getelementptr inbounds double, double* %2, i64 %67
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %79, i64 2
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %27, i64 %67
%86 = bitcast double* %85 to <2 x double>*
store <2 x double> %81, <2 x double>* %86
%87 = getelementptr inbounds double, double* %85, i64 2
%88 = bitcast double* %87 to <2 x double>*
store <2 x double> %84, <2 x double>* %88
%89 = or i64 %67, 4
%90 = getelementptr inbounds double, double* %1, i64 %89
%91 = bitcast double* %90 to <2 x double>*
%92 = load <2 x double>, <2 x double>* %91
%93 = getelementptr inbounds double, double* %90, i64 2
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = getelementptr inbounds double, double* %22, i64 %89
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %92, <2 x double>* %97
%98 = getelementptr inbounds double, double* %96, i64 2
%99 = bitcast double* %98 to <2 x double>*
store <2 x double> %95, <2 x double>* %99
%100 = getelementptr inbounds double, double* %2, i64 %89
%101 = bitcast double* %100 to <2 x double>*
%102 = load <2 x double>, <2 x double>* %101
%103 = getelementptr inbounds double, double* %100, i64 2
%104 = bitcast double* %103 to <2 x double>*
%105 = load <2 x double>, <2 x double>* %104
%106 = getelementptr inbounds double, double* %27, i64 %89
%107 = bitcast double* %106 to <2 x double>*
store <2 x double> %102, <2 x double>* %107
%108 = getelementptr inbounds double, double* %106, i64 2
%109 = bitcast double* %108 to <2 x double>*
store <2 x double> %105, <2 x double>* %109
%110 = add nuw i64 %67, 8
%111 = add i64 %68, 2
%112 = icmp eq i64 %111, %65
br i1 %112, label %113, label %66
113: ; preds = %66, %57
%114 = phi i64 [ 0, %57 ], [ %110, %66 ]
%115 = icmp eq i64 %62, 0
br i1 %115, label %137, label %116
116: ; preds = %113
%117 = getelementptr inbounds double, double* %1, i64 %114
%118 = bitcast double* %117 to <2 x double>*
%119 = load <2 x double>, <2 x double>* %118
%120 = getelementptr inbounds double, double* %117, i64 2
%121 = bitcast double* %120 to <2 x double>*
%122 = load <2 x double>, <2 x double>* %121
%123 = getelementptr inbounds double, double* %22, i64 %114
%124 = bitcast double* %123 to <2 x double>*
store <2 x double> %119, <2 x double>* %124
%125 = getelementptr inbounds double, double* %123, i64 2
%126 = bitcast double* %125 to <2 x double>*
store <2 x double> %122, <2 x double>* %126
%127 = getelementptr inbounds double, double* %2, i64 %114
%128 = bitcast double* %127 to <2 x double>*
%129 = load <2 x double>, <2 x double>* %128
%130 = getelementptr inbounds double, double* %127, i64 2
%131 = bitcast double* %130 to <2 x double>*
%132 = load <2 x double>, <2 x double>* %131
%133 = getelementptr inbounds double, double* %27, i64 %114
%134 = bitcast double* %133 to <2 x double>*
store <2 x double> %129, <2 x double>* %134
%135 = getelementptr inbounds double, double* %133, i64 2
%136 = bitcast double* %135 to <2 x double>*
store <2 x double> %132, <2 x double>* %136
br label %137
137: ; preds = %113, %116
%138 = icmp eq i64 %58, %28
br i1 %138, label %173, label %139
139: ; preds = %30, %26, %137
%140 = phi i64 [ 0, %30 ], [ 0, %26 ], [ %58, %137 ]
%141 = xor i64 %140, -1
%142 = and i64 %28, 1
%143 = icmp eq i64 %142, 0
br i1 %143, label %152, label %144
144: ; preds = %139
%145 = getelementptr inbounds double, double* %1, i64 %140
%146 = load double, double* %145
%147 = getelementptr inbounds double, double* %22, i64 %140
store double %146, double* %147
%148 = getelementptr inbounds double, double* %2, i64 %140
%149 = load double, double* %148
%150 = getelementptr inbounds double, double* %27, i64 %140
store double %149, double* %150
%151 = or i64 %140, 1
br label %152
152: ; preds = %144, %139
%153 = phi i64 [ %140, %139 ], [ %151, %144 ]
%154 = sub nsw i64 0, %28
%155 = icmp eq i64 %141, %154
br i1 %155, label %173, label %156
156: ; preds = %152, %156
%157 = phi i64 [ %171, %156 ], [ %153, %152 ]
%158 = getelementptr inbounds double, double* %1, i64 %157
%159 = load double, double* %158
%160 = getelementptr inbounds double, double* %22, i64 %157
store double %159, double* %160
%161 = getelementptr inbounds double, double* %2, i64 %157
%162 = load double, double* %161
%163 = getelementptr inbounds double, double* %27, i64 %157
store double %162, double* %163
%164 = add nuw nsw i64 %157, 1
%165 = getelementptr inbounds double, double* %1, i64 %164
%166 = load double, double* %165
%167 = getelementptr inbounds double, double* %22, i64 %164
store double %166, double* %167
%168 = getelementptr inbounds double, double* %2, i64 %164
%169 = load double, double* %168
%170 = getelementptr inbounds double, double* %27, i64 %164
store double %169, double* %170
%171 = add nuw nsw i64 %157, 2
%172 = icmp eq i64 %171, %28
br i1 %172, label %173, label %156
173: ; preds = %152, %156, %137, %6
%174 = load double, double* %4
%175 = tail call double @romberg(double (double)* @r_g, double -6.000000e+00, double 6.000000e+00, double %174)
store double %175, double* %5
%176 = load double*, double** @xx
%177 = tail call i32 @free(double* %176)
%178 = load double*, double** @ww
%179 = tail call i32 @free(double* %178)
ret void
}