#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 pr;
double sqrt(int);
double exchmvn(int m, double *w, double *x, double rh, double eps) {
  double g(double), pr;
  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 + 1) * sizeof(double));
  ww = (double *)malloc((mm + 1) * sizeof(double));
  for (i = 1; i <= mm; i++) {
    ww[i] = w[i];
    xx[i] = x[i];
  }
  pr = romberg(g, -6., 6., eps);
  free(xx);
  free(ww);
  return (pr);
}


x86 assembly (clang, -O0):
<exchmvn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    -0x4(%rbp),%ecx
mov    0x2e91(%rip),%rax
mov    %ecx,(%rax)
cvttsd2si -0x20(%rbp),%edi
call   1060 <sqrt@plt>
mov    0x2e3e(%rip),%rax
movsd  %xmm0,(%rax)
movsd  0xe7a(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    0x2e55(%rip),%rax
movsd  %xmm0,(%rax)
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    0x2e06(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    0x2dd8(%rip),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2dfc(%rip),%rcx
cmp    (%rcx),%eax
jg     1252 <exchmvn+0x112>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x2da8(%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    0x2d90(%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    11f2 <exchmvn+0xb2>
movsd  -0x28(%rbp),%xmm2
mov    0x2d7a(%rip),%rdi
movsd  0xda2(%rip),%xmm0
movsd  0xda2(%rip),%xmm1
call   1040 <romberg@plt>
movsd  %xmm0,-0x30(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exchmvn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdx,%r14
mov    %rsi,%rbx
mov    0x2e91(%rip),%r13
mov    %edi,0x0(%r13)
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    0x2e3d(%rip),%rax
movsd  %xmm0,(%rax)
movsd  0xe79(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
mov    0x2e53(%rip),%rax
movsd  %xmm0,(%rax)
mov    0x0(%r13),%eax
lea    0x8(,%rax,8),%edi
call   1050 <malloc@plt>
mov    0x2e10(%rip),%rbp
mov    %rax,0x0(%rbp)
mov    0x0(%r13),%eax
lea    0x8(,%rax,8),%edi
call   1050 <malloc@plt>
mov    0x2ded(%rip),%r15
mov    %rax,(%r15)
mov    0x0(%r13),%r8d
test   %r8d,%r8d
jle    13df <exchmvn+0x29f>
mov    0x0(%rbp),%rcx
lea    0x1(%r8),%r10
mov    $0x1,%esi
cmp    $0x4,%r8
jae    126c <exchmvn+0x12c>
mov    %rsi,%rdx
not    %rdx
test   $0x1,%r10b
jne    121b <exchmvn+0xdb>
movsd  (%rbx,%rsi,8),%xmm0
movsd  %xmm0,(%rax,%rsi,8)
movsd  (%r14,%rsi,8),%xmm0
movsd  %xmm0,(%rcx,%rsi,8)
add    $0x1,%rsi
add    %r10,%rdx
je     13df <exchmvn+0x29f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rsi,8),%xmm0
movsd  %xmm0,(%rax,%rsi,8)
movsd  (%r14,%rsi,8),%xmm0
movsd  %xmm0,(%rcx,%rsi,8)
movsd  0x8(%rbx,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rax,%rsi,8)
movsd  0x8(%r14,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rcx,%rsi,8)
add    $0x2,%rsi
cmp    %rsi,%r10
jne    1230 <exchmvn+0xf0>
jmp    13df <exchmvn+0x29f>
lea    (%rax,%r10,8),%rbp
mov    %rax,%rdi
add    $0x8,%rdi
lea    0x8(%rcx),%rdx
lea    (%rcx,%r10,8),%r13
lea    0x8(%rbx),%r11
lea    (%rbx,%r10,8),%r9
lea    0x8(%r14),%r15
lea    (%r14,%r10,8),%r12
cmp    %r13,%rdi
setb   0x8(%rsp)
cmp    %rbp,%rdx
setb   0x7(%rsp)
cmp    %r9,%rdi
setb   0x6(%rsp)
cmp    %rbp,%r11
setb   0x5(%rsp)
cmp    %r12,%rdi
setb   %dil
cmp    %rbp,%r15
setb   %bpl
cmp    %r9,%rdx
setb   %r9b
cmp    %r13,%r11
setb   0x4(%rsp)
cmp    %r12,%rdx
setb   %r11b
cmp    %r13,%r15
setb   %r12b
mov    0x7(%rsp),%dl
test   %dl,0x8(%rsp)
jne    1447 <exchmvn+0x307>
mov    %ebp,%r13d
mov    0x5(%rsp),%dl
and    %dl,0x6(%rsp)
mov    0x2cce(%rip),%rbp
mov    0x2cbf(%rip),%r15
jne    11f6 <exchmvn+0xb6>
and    %r13b,%dil
jne    11f6 <exchmvn+0xb6>
and    0x4(%rsp),%r9b
jne    11f6 <exchmvn+0xb6>
and    %r12b,%r11b
jne    11f6 <exchmvn+0xb6>
mov    %r8d,%esi
and    $0xfffffffc,%esi
lea    -0x4(%rsi),%rdx
mov    %rdx,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rdx,%rdx
je     1436 <exchmvn+0x2f6>
mov    %r9,%rdx
and    $0xfffffffffffffffe,%rdx
mov    $0x1,%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 (%r14,%rdi,8),%xmm0
movups 0x10(%r14,%rdi,8),%xmm1
movups %xmm0,(%rcx,%rdi,8)
movups %xmm1,0x10(%rcx,%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(%r14,%rdi,8),%xmm0
movups 0x30(%r14,%rdi,8),%xmm1
movupd %xmm0,0x20(%rcx,%rdi,8)
movups %xmm1,0x30(%rcx,%rdi,8)
add    $0x8,%rdi
add    $0xfffffffffffffffe,%rdx
jne    1350 <exchmvn+0x210>
test   $0x1,%r9b
je     13da <exchmvn+0x29a>
movups (%rbx,%rdi,8),%xmm0
movups 0x10(%rbx,%rdi,8),%xmm1
movups %xmm0,(%rax,%rdi,8)
movups %xmm1,0x10(%rax,%rdi,8)
movupd (%r14,%rdi,8),%xmm0
movups 0x10(%r14,%rdi,8),%xmm1
movupd %xmm0,(%rcx,%rdi,8)
movups %xmm1,0x10(%rcx,%rdi,8)
cmp    %rsi,%r8
jne    142d <exchmvn+0x2ed>
mov    0x2bf2(%rip),%rdi
movsd  0xc1a(%rip),%xmm0
movsd  0xc1a(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <romberg@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x0(%rbp),%rdi
call   1030 <free@plt>
mov    (%r15),%rdi
call   1030 <free@plt>
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
or     $0x1,%rsi
jmp    11f6 <exchmvn+0xb6>
mov    $0x1,%edi
test   $0x1,%r9b
jne    13b2 <exchmvn+0x272>
jmp    13da <exchmvn+0x29a>
mov    0x2b7a(%rip),%rbp
mov    0x2b6b(%rip),%r15
jmp    11f6 <exchmvn+0xb6>

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

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