#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 exp(int /*<<< orphan*/);
double genunf(double, double);
scalar_t__ is_positive(double);
scalar_t__ log(double);
scalar_t__ my_fmin(double, double);
double qacc_rw(double, double, double, double, double, double);
int /*<<< orphan*/ snorm();
double sample_quad_rw(double xkl, double xkk, double xll, double ckl,
                      double clk, double ckk, double cll, double bk,
                      double bl) {
  double xlk, skl, slk, s2, s3, s, a1, a2, a3;
  double v, w;
  double q, U;
  xlk = xkl;
  skl = xkk + xkl;
  slk = xll + xlk;
  if (skl <= slk) {
    s2 = skl;
    s3 = slk;
    s = s3 / s2;
    a1 = ckl + clk - 1.0;
    a2 = ckk + bk - 1.0;
    a3 = cll + bl - 1.0;
  } else {
    s2 = slk;
    s3 = skl;
    s = s3 / s2;
    a1 = ckl + clk - 1.0;
    a2 = cll + bl - 1.0;
    a3 = ckk + bk - 1.0;
  }
  if (is_positive(s2 - xkl)) {
    v = xkl / (s2 - xkl);
    w = v * exp(snorm());
    if (is_positive(w)) {
      if (!is_positive(v)) {
        return s2 * w / (1.0 + w);
      } else {
        q = qacc_rw(w, v, s, a1, a2, a3);
        U = genunf(0.0, 1.0);
        if (log(U) < my_fmin(0.0, q)) {
          return s2 * w / (1.0 + w);
        }
      }
    }
  }
  return xkl;
}


x86 assembly (clang, -O0):
<sample_quad_rw>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  0x10(%rbp),%xmm8
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
movsd  %xmm7,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1264 <sample_quad_rw+0xf4>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xde6(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  0xdcb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
addsd  0x10(%rbp),%xmm0
movsd  0xdad(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    12de <sample_quad_rw+0x16e>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xd67(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  0x10(%rbp),%xmm0
movsd  0xd4c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  0xd2e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1080 <is_positive@plt>
cmp    $0x0,%rax
je     1460 <sample_quad_rw+0x2f0>
movsd  -0x10(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
mov    $0x0,%al
call   1030 <snorm@plt>
mov    %eax,%edi
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
call   1080 <is_positive@plt>
cmp    $0x0,%rax
je     145b <sample_quad_rw+0x2eb>
movsd  -0x98(%rbp),%xmm0
ff
call   1080 <is_positive@plt>
cmp    $0x0,%rax
jne    13a0 <sample_quad_rw+0x230>
movsd  -0x68(%rbp),%xmm0
mulsd  -0xa0(%rbp),%xmm0
ff
movsd  0xc76(%rip),%xmm1
addsd  -0xa0(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    146a <sample_quad_rw+0x2fa>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x78(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm3
movsd  -0x88(%rbp),%xmm4
ff
movsd  -0x90(%rbp),%xmm5
ff
call   1090 <qacc_rw@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  0xc1e(%rip),%xmm1
call   1070 <genunf@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
call   1060 <log@plt>
mov    %rax,-0xc0(%rbp)
movsd  -0xa8(%rbp),%xmm1
ff
xorps  %xmm0,%xmm0
call   1040 <my_fmin@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
cmp    %rcx,%rax
jge    1451 <sample_quad_rw+0x2e1>
movsd  -0x68(%rbp),%xmm0
mulsd  -0xa0(%rbp),%xmm0
ff
movsd  0xbc5(%rip),%xmm1
addsd  -0xa0(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    146a <sample_quad_rw+0x2fa>
jmp    1456 <sample_quad_rw+0x2e6>
jmp    145b <sample_quad_rw+0x2eb>
jmp    1460 <sample_quad_rw+0x2f0>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample_quad_rw>:
push   %rbx
sub    $0x50,%rsp
movapd %xmm0,%xmm8
movsd  0x60(%rsp),%xmm0
addsd  %xmm8,%xmm1
addsd  %xmm8,%xmm2
ucomisd %xmm1,%xmm2
movsd  %xmm3,0x48(%rsp)
movsd  %xmm4,0x40(%rsp)
jae    11c4 <sample_quad_rw+0x54>
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm6
movapd %xmm5,%xmm0
addsd  %xmm7,%xmm0
movsd  %xmm6,0x28(%rsp)
movsd  %xmm0,0x30(%rsp)
movsd  %xmm1,0x20(%rsp)
movapd %xmm2,%xmm1
jmp    11e2 <sample_quad_rw+0x72>
divsd  %xmm1,%xmm2
addsd  %xmm7,%xmm5
movsd  %xmm5,0x28(%rsp)
addsd  %xmm0,%xmm6
movsd  %xmm6,0x30(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x38(%rsp)
movapd %xmm1,%xmm0
subsd  %xmm8,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm8,0x10(%rsp)
call   1080 <is_positive@plt>
test   %rax,%rax
je     12ee <sample_quad_rw+0x17e>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <snorm@plt>
mov    %eax,%edi
call   1050 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1080 <is_positive@plt>
test   %rax,%rax
je     12ee <sample_quad_rw+0x17e>
movsd  0x8(%rsp),%xmm0
call   1080 <is_positive@plt>
test   %rax,%rax
je     12d0 <sample_quad_rw+0x160>
movsd  0xda2(%rip),%xmm0
movsd  0x30(%rsp),%xmm5
addsd  %xmm0,%xmm5
movsd  0x28(%rsp),%xmm4
addsd  %xmm0,%xmm4
movsd  0x48(%rsp),%xmm3
addsd  0x40(%rsp),%xmm3
addsd  %xmm0,%xmm3
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
call   1090 <qacc_rw@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd61(%rip),%xmm1
xorps  %xmm0,%xmm0
call   1070 <genunf@plt>
call   1060 <log@plt>
mov    %rax,%rbx
xorps  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <my_fmin@plt>
cmp    %rax,%rbx
movsd  0x10(%rsp),%xmm0
jge    12f4 <sample_quad_rw+0x184>
movsd  0x38(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xd20(%rip),%xmm1
divsd  %xmm1,%xmm0
jmp    12f4 <sample_quad_rw+0x184>
movsd  0x10(%rsp),%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @sample_quad_rw(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
store double %0, double* %11
store double %1, double* %12
store double %2, double* %13
store double %3, double* %14
store double %4, double* %15
store double %5, double* %16
store double %6, double* %17
store double %7, double* %18
store double %8, double* %19
%33 = load double, double* %11
store double %33, double* %20
%34 = load double, double* %12
%35 = load double, double* %11
%36 = fadd double %34, %35
store double %36, double* %21
%37 = load double, double* %13
%38 = load double, double* %20
%39 = fadd double %37, %38
store double %39, double* %22
%40 = load double, double* %21
%41 = load double, double* %22
%42 = fcmp ole double %40, %41
br i1 %42, label %43, label %61
43: ; preds = %9
%44 = load double, double* %21
store double %44, double* %23
%45 = load double, double* %22
store double %45, double* %24
%46 = load double, double* %24
%47 = load double, double* %23
%48 = fdiv double %46, %47
store double %48, double* %25
%49 = load double, double* %14
%50 = load double, double* %15
%51 = fadd double %49, %50
%52 = fsub double %51, 1.000000e+00
store double %52, double* %26
%53 = load double, double* %16
%54 = load double, double* %18
%55 = fadd double %53, %54
%56 = fsub double %55, 1.000000e+00
store double %56, double* %27
%57 = load double, double* %17
%58 = load double, double* %19
%59 = fadd double %57, %58
%60 = fsub double %59, 1.000000e+00
store double %60, double* %28
br label %79
61: ; preds = %9
%62 = load double, double* %22
store double %62, double* %23
%63 = load double, double* %21
store double %63, double* %24
%64 = load double, double* %24
%65 = load double, double* %23
%66 = fdiv double %64, %65
store double %66, double* %25
%67 = load double, double* %14
%68 = load double, double* %15
%69 = fadd double %67, %68
%70 = fsub double %69, 1.000000e+00
store double %70, double* %26
%71 = load double, double* %17
%72 = load double, double* %19
%73 = fadd double %71, %72
%74 = fsub double %73, 1.000000e+00
store double %74, double* %27
%75 = load double, double* %16
%76 = load double, double* %18
%77 = fadd double %75, %76
%78 = fsub double %77, 1.000000e+00
store double %78, double* %28
br label %79
79: ; preds = %61, %43
%80 = load double, double* %23
%81 = load double, double* %11
%82 = fsub double %80, %81
%83 = call i64 @is_positive(double %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %133
85: ; preds = %79
%86 = load double, double* %11
%87 = load double, double* %23
%88 = load double, double* %11
%89 = fsub double %87, %88
%90 = fdiv double %86, %89
store double %90, double* %29
%91 = load double, double* %29
%92 = call i32 (...) @snorm()
%93 = call double @exp(i32 %92)
%94 = fmul double %91, %93
store double %94, double* %30
%95 = load double, double* %30
%96 = call i64 @is_positive(double %95)
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %132
98: ; preds = %85
%99 = load double, double* %29
%100 = call i64 @is_positive(double %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %109, label %102
102: ; preds = %98
%103 = load double, double* %23
%104 = load double, double* %30
%105 = fmul double %103, %104
%106 = load double, double* %30
%107 = fadd double 1.000000e+00, %106
%108 = fdiv double %105, %107
store double %108, double* %10
br label %135
109: ; preds = %98
%110 = load double, double* %30
%111 = load double, double* %29
%112 = load double, double* %25
%113 = load double, double* %26
%114 = load double, double* %27
%115 = load double, double* %28
%116 = call double @qacc_rw(double %110, double %111, double %112, double %113, double %114, double %115)
store double %116, double* %31
%117 = call double @genunf(double 0.000000e+00, double 1.000000e+00)
store double %117, double* %32
%118 = load double, double* %32
%119 = call i64 @log(double %118)
%120 = load double, double* %31
%121 = call i64 @my_fmin(double 0.000000e+00, double %120)
%122 = icmp slt i64 %119, %121
br i1 %122, label %123, label %130
123: ; preds = %109
%124 = load double, double* %23
%125 = load double, double* %30
%126 = fmul double %124, %125
%127 = load double, double* %30
%128 = fadd double 1.000000e+00, %127
%129 = fdiv double %126, %128
store double %129, double* %10
br label %135
130: ; preds = %109
br label %131
131: ; preds = %130
br label %132
132: ; preds = %131, %85
br label %133
133: ; preds = %132, %79
%134 = load double, double* %11
store double %134, double* %10
br label %135
135: ; preds = %133, %123, %102
%136 = load double, double* %10
ret double %136
}

LLVM IR (-O2):
define double @sample_quad_rw(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = fadd double %0, %1
%11 = fadd double %0, %2
%12 = fcmp ugt double %10, %11
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = fdiv double %11, %10
%15 = fadd double %5, %7
%16 = fadd double %6, %8
br label %21
17: ; preds = %9
%18 = fdiv double %10, %11
%19 = fadd double %6, %8
%20 = fadd double %5, %7
br label %21
21: ; preds = %17, %13
%22 = phi double [ %15, %13 ], [ %19, %17 ]
%23 = phi double [ %16, %13 ], [ %20, %17 ]
%24 = phi double [ %14, %13 ], [ %18, %17 ]
%25 = phi double [ %10, %13 ], [ %11, %17 ]
%26 = fadd double %23, -1.000000e+00
%27 = fadd double %22, -1.000000e+00
%28 = fadd double %3, %4
%29 = fadd double %28, -1.000000e+00
%30 = fsub double %25, %0
%31 = tail call i64 @is_positive(double %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %57, label %33
33: ; preds = %21
%34 = fdiv double %0, %30
%35 = tail call i32 (...) @snorm()
%36 = tail call double @exp(i32 %35)
%37 = fmul double %34, %36
%38 = tail call i64 @is_positive(double %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %57, label %40
40: ; preds = %33
%41 = tail call i64 @is_positive(double %34)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = fmul double %25, %37
%45 = fadd double %37, 1.000000e+00
%46 = fdiv double %44, %45
br label %57
47: ; preds = %40
%48 = tail call double @qacc_rw(double %37, double %34, double %24, double %29, double %27, double %26)
%49 = tail call double @genunf(double 0.000000e+00, double 1.000000e+00)
%50 = tail call i64 @log(double %49)
%51 = tail call i64 @my_fmin(double 0.000000e+00, double %48)
%52 = icmp slt i64 %50, %51
br i1 %52, label %53, label %57
53: ; preds = %47
%54 = fmul double %25, %37
%55 = fadd double %37, 1.000000e+00
%56 = fdiv double %54, %55
br label %57
57: ; preds = %21, %47, %33, %53, %43
%58 = phi double [ %56, %53 ], [ %46, %43 ], [ %0, %33 ], [ %0, %47 ], [ %0, %21 ]
ret double %58
}