// File: redpony[P]cpyp/crp_test.cc
// Function: test_mh2()
void test_mh2() {
  cpyp::MT19937 eng;
  cpyp::crp<int> a(0.5, 1.0);
  cpyp::crp<int> b(0.5, 1.0);
  vector<int> hist_a(16, 0);
  vector<int> hist_b(16, 0);
  vector<double> ref_a = {3.70004e-06, 0.0144611, 0.0614236, 0.138702, 0.211308, 0.231733, 0.183865, 0.103685, 0.0409419, 0.0114253, 0.00214592, 0.000281003, 2.33002e-05, 7.00007e-07, 2.12303e-07, 0};
  vector<double> ref_b = {2.90003e-06, 0.00876079, 0.0471061, 0.115841, 0.187615, 0.221488, 0.196102, 0.130352, 0.063905, 0.0224984, 0.00542085, 0.000828908, 7.53008e-05, 4.90005e-06, 1.00001e-07, 0};
  double ref_t0b = 1.53498;

  vector<bool> z(15);
  double c = 0;
  double ac = 0;
  double tmh = 0;
  double zz = 0;
  double t0b = 0;
  for (int s = 0; s < 200000; ++s) {
    for (int i = 0; i < 15; ++i) {
      const unsigned int y_i = i % 3;
      const bool old_z = z[i];
      cpyp::crp<int> old_a = a;
      cpyp::crp<int> old_b = b;
      double lp_old = llh(a, p0_a) + llh(b, p0_b);

      double lq_old = 0;
      double lq_new = 0;
      if (s > 0) (z[i] ? b : a).decrement(y_i, eng, &lq_old);

      double aa = 0.5;  // these can be better estimates
      double bb = 0.5;
      z[i] = cpyp::sample_bernoulli(aa, bb, eng);
      (z[i] ? b : a).increment_no_base(y_i, eng, &lq_new);
      lq_new += log((z[i] ? bb : aa) / (aa + bb));
      lq_old += log((old_z ? bb : aa) / (aa + bb));

      if (s > 0) { 
        double lp_new = llh(a, p0_a) + llh(b, p0_b);
        double acc = exp(lp_new - lp_old + lq_old - lq_new);
        ++tmh;
        if (acc >= 1.0 || cpyp::sample_uniform01<double>(eng) < acc) { // mh accept
          ++ac;
        } else { // mh reject
          std::swap(a, old_a);
          std::swap(b, old_b);
          z[i] = old_z;
        }
      }
    }
    // record sample
    if (s> 200 && s % 10 == 9) {
      assert(a.num_tables() < hist_a.size());
      assert(b.num_tables() < hist_b.size());
      hist_a[a.num_tables()]++; hist_b[b.num_tables()]++; ++c;
      for (int i = 0; i < 15; ++i) {
        unsigned int y_i = i % 3;
        if (!z[i]) { t0b += y_i; ++zz; }
      }
    }
  }
  ac /= tmh;
  cerr << "ACCEPTANCE: " << ac << endl;
  int j =0;
  double te = 0;
  double me = 0;
  for (int i = 0; i < 15; ++i) {
    double a = hist_a[i];
    double b = hist_b[i];
    double err_a = (a / c - ref_a[j]);
    double err_b = (b / c - ref_b[j++]);
    cerr << err_a << "\t" << err_b << endl;
    te += fabs(err_a) + fabs(err_b);
    if (fabs(err_a) > me) { me = fabs(err_a); }
    if (fabs(err_b) > me) { me = fabs(err_b); }
  }
  te /= 30;
  cerr << "t0b = " << (t0b / zz) << endl;
  double ee = fabs((t0b / zz) - ref_t0b);
  cerr << "err t0b = " << ee;
  if (ee > 0.01) { cerr << "  ** TOO HIGH **"; }
  cerr << endl;
  cerr << "Average error: " << te;
  if (te > 0.01) { cerr << "  ** TOO HIGH **"; }
  cerr << endl << "    Max error: " << me;
  if (me > 0.01) { cerr << "  ** TOO HIGH **"; }
  cerr << endl;
}

// Assembly:
subq $0x1a28, %rsp           # imm = 0x1A28
leaq 0x6a0(%rsp), %rdi
callq 0x5e30
leaq 0x628(%rsp), %rdi
movsd 0x119e4(%rip), %xmm0    # 0x15008
movsd %xmm0, 0x180(%rsp)
movsd 0x119db(%rip), %xmm1    # 0x15010
movsd %xmm1, 0x188(%rsp)
callq 0x5f10
movsd 0x180(%rsp), %xmm0
movsd 0x188(%rsp), %xmm1
leaq 0x5b0(%rsp), %rdi
callq 0x5f10
jmp 0x3664
movl $0x0, 0x584(%rsp)
leaq 0x583(%rsp), %rdi
movq %rdi, 0x178(%rsp)
callq 0x5fd0
movq 0x178(%rsp), %rcx
leaq 0x588(%rsp), %rdi
movl $0x10, %esi
leaq 0x584(%rsp), %rdx
callq 0x5fe0
jmp 0x36a8
leaq 0x583(%rsp), %rdi
callq 0x6060
movl $0x0, 0x564(%rsp)
leaq 0x563(%rsp), %rdi
movq %rdi, 0x170(%rsp)
callq 0x5fd0
movq 0x170(%rsp), %rcx
leaq 0x568(%rsp), %rdi
movl $0x10, %esi
leaq 0x564(%rsp), %rdx
callq 0x5fe0
jmp 0x36f9
leaq 0x563(%rsp), %rdi
callq 0x6060
movups 0x11b63(%rip), %xmm0    # 0x15270
movaps %xmm0, 0x520(%rsp)
movups 0x11b44(%rip), %xmm0    # 0x15260
movaps %xmm0, 0x510(%rsp)
movups 0x11b25(%rip), %xmm0    # 0x15250
movaps %xmm0, 0x500(%rsp)
movups 0x11b06(%rip), %xmm0    # 0x15240
movaps %xmm0, 0x4f0(%rsp)
movups 0x11ae7(%rip), %xmm0    # 0x15230
movaps %xmm0, 0x4e0(%rsp)
movups 0x11ac8(%rip), %xmm0    # 0x15220
movaps %xmm0, 0x4d0(%rsp)
movups 0x11aa9(%rip), %xmm0    # 0x15210
movaps %xmm0, 0x4c0(%rsp)
movups 0x11a8a(%rip), %xmm0    # 0x15200
movaps %xmm0, 0x4b0(%rsp)
leaq 0x4b0(%rsp), %rax
movq %rax, 0x538(%rsp)
movq $0x10, 0x540(%rsp)
leaq 0x4af(%rsp), %rdi
movq %rdi, 0x168(%rsp)
callq 0x5e60
movq 0x168(%rsp), %rcx
movq 0x538(%rsp), %rsi
movq 0x540(%rsp), %rdx
leaq 0x548(%rsp), %rdi
callq 0x5e70
jmp 0x37d6
leaq 0x4af(%rsp), %rdi
callq 0x5f00
movups 0x11b06(%rip), %xmm0    # 0x152f0
movaps %xmm0, 0x470(%rsp)
movups 0x11ae7(%rip), %xmm0    # 0x152e0
movaps %xmm0, 0x460(%rsp)
movups 0x11ac8(%rip), %xmm0    # 0x152d0
movaps %xmm0, 0x450(%rsp)
movups 0x11aa9(%rip), %xmm0    # 0x152c0
movaps %xmm0, 0x440(%rsp)
movups 0x11a8a(%rip), %xmm0    # 0x152b0
movaps %xmm0, 0x430(%rsp)
movups 0x11a6b(%rip), %xmm0    # 0x152a0
movaps %xmm0, 0x420(%rsp)
movups 0x11a4c(%rip), %xmm0    # 0x15290
movaps %xmm0, 0x410(%rsp)
movups 0x11a2d(%rip), %xmm0    # 0x15280
movaps %xmm0, 0x400(%rsp)
leaq 0x400(%rsp), %rax
movq %rax, 0x480(%rsp)
movq $0x10, 0x488(%rsp)
leaq 0x3ff(%rsp), %rdi
movq %rdi, 0x160(%rsp)
callq 0x5e60
movq 0x160(%rsp), %rcx
movq 0x480(%rsp), %rsi
movq 0x488(%rsp), %rdx
leaq 0x490(%rsp), %rdi
callq 0x5e70
jmp 0x38b3
leaq 0x3ff(%rsp), %rdi
callq 0x5f00
movabsq $0x3ff88f47304039ac, %rax # imm = 0x3FF88F47304039AC
movq %rax, 0x3f0(%rsp)
leaq 0x3c7(%rsp), %rdi
movq %rdi, 0x158(%rsp)
callq 0x69f0
movq 0x158(%rsp), %rdx
leaq 0x3c8(%rsp), %rdi
movl $0xf, %esi
callq 0x6a00
jmp 0x3903
leaq 0x3c7(%rsp), %rdi
callq 0x6a40
xorps %xmm0, %xmm0
movsd %xmm0, 0x3b8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3b0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3a8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3a0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x398(%rsp)
movl $0x0, 0x394(%rsp)
cmpl $0x30d40, 0x394(%rsp) # imm = 0x30D40
jge 0x4388
movl $0x0, 0x390(%rsp)
cmpl $0xf, 0x390(%rsp)
jge 0x411f
movslq 0x390(%rsp), %rcx
movl %ecx, %eax
imulq $0x55555556, %rcx, %rdx # imm = 0x55555556
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
movl %eax, 0x38c(%rsp)
movslq 0x390(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
callq 0x6a50
movq %rdx, 0x148(%rsp)
movq %rax, 0x150(%rsp)
jmp 0x39d4
movq 0x148(%rsp), %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x378(%rsp)
movq %rax, 0x380(%rsp)
leaq 0x378(%rsp), %rdi
callq 0x6ab0
movb %al, 0x38b(%rsp)
leaq 0x300(%rsp), %rdi
leaq 0x628(%rsp), %rsi
callq 0x6070
jmp 0x3a1f
leaq 0x288(%rsp), %rdi
leaq 0x5b0(%rsp), %rsi
callq 0x6070
jmp 0x3a36
leaq 0x118c3(%rip), %rsi     # 0x15300
leaq 0x628(%rsp), %rdi
callq 0x2410
movsd %xmm0, 0x140(%rsp)
jmp 0x3a55
leaq 0x118c4(%rip), %rsi     # 0x15320
leaq 0x5b0(%rsp), %rdi
callq 0x2410
movsd %xmm0, 0x138(%rsp)
jmp 0x3a74
movsd 0x138(%rsp), %xmm1
movsd 0x140(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x280(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x278(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x270(%rsp)
cmpl $0x0, 0x394(%rsp)
jle 0x3ca0
movslq 0x390(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
callq 0x6a50
movq %rdx, 0x128(%rsp)
movq %rax, 0x130(%rsp)
jmp 0x3ae0
movq 0x128(%rsp), %rax
movq 0x130(%rsp), %rcx
movq %rcx, 0x260(%rsp)
movq %rax, 0x268(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x6ab0
testb $0x1, %al
jne 0x3b13
jmp 0x3b25
leaq 0x5b0(%rsp), %rax
movq %rax, 0x120(%rsp)
jmp 0x3b37
leaq 0x628(%rsp), %rax
movq %rax, 0x120(%rsp)
jmp 0x3b37
movq 0x120(%rsp), %rdi
movl 0x38c(%rsp), %eax
movl %eax, 0x25c(%rsp)
leaq 0x25c(%rsp), %rsi
leaq 0x6a0(%rsp), %rdx
leaq 0x278(%rsp), %rcx
callq 0x60d0
jmp 0x3b6c
jmp 0x3ca0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x48e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x583(%rsp), %rdi
callq 0x6060
jmp 0x48dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x563(%rsp), %rdi
callq 0x6060
jmp 0x48cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x4af(%rsp), %rdi
callq 0x5f00
jmp 0x48c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x3ff(%rsp), %rdi
callq 0x5f00
jmp 0x48b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x3c7(%rsp), %rdi
callq 0x6a40
jmp 0x48a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x489b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
jmp 0x410d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x5a8(%rsp)
movl %eax, 0x5a4(%rsp)
leaq 0x288(%rsp), %rdi
callq 0x65a0
jmp 0x410d
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, 0x250(%rsp)
movq %rax, 0x248(%rsp)
movsd 0x250(%rsp), %xmm0
movsd 0x248(%rsp), %xmm1
leaq 0x6a0(%rsp), %rdi
callq 0x6ae0
movl %eax, 0x11c(%rsp)
jmp 0x3ce2
movl 0x11c(%rsp), %eax
testl %eax, %eax
setne %al
movb %al, 0x107(%rsp)
movslq 0x390(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
callq 0x6a50
movq %rdx, 0x108(%rsp)
movq %rax, 0x110(%rsp)
jmp 0x3d1c
movb 0x107(%rsp), %al
movq 0x108(%rsp), %rcx
movq 0x110(%rsp), %rdx
movq %rdx, 0x238(%rsp)
movq %rcx, 0x240(%rsp)
movzbl %al, %esi
andl $0x1, %esi
leaq 0x238(%rsp), %rdi
callq 0x6b30
movslq 0x390(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
callq 0x6a50
movq %rdx, 0xf0(%rsp)
movq %rax, 0xf8(%rsp)
jmp 0x3d7d
movq 0xf0(%rsp), %rax
movq 0xf8(%rsp), %rcx
movq %rcx, 0x228(%rsp)
movq %rax, 0x230(%rsp)
leaq 0x228(%rsp), %rdi
callq 0x6ab0
testb $0x1, %al
jne 0x3db0
jmp 0x3dc2
leaq 0x5b0(%rsp), %rax
movq %rax, 0xe8(%rsp)
jmp 0x3dd4
leaq 0x628(%rsp), %rax
movq %rax, 0xe8(%rsp)
jmp 0x3dd4
movq 0xe8(%rsp), %rdi
movl 0x38c(%rsp), %eax
movl %eax, 0x224(%rsp)
leaq 0x224(%rsp), %rsi
leaq 0x6a0(%rsp), %rdx
leaq 0x270(%rsp), %rcx
callq 0x67a0
jmp 0x3e09
movslq 0x390(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
callq 0x6a50
movq %rdx, 0xd8(%rsp)
movq %rax, 0xe0(%rsp)
jmp 0x3e30
movq 0xd8(%rsp), %rax
movq 0xe0(%rsp), %rcx
movq %rcx, 0x210(%rsp)
movq %rax, 0x218(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x6ab0
testb $0x1, %al
jne 0x3e63
jmp 0x3e77
movsd 0x248(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x3e89
movsd 0x250(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0xd0(%rsp), %xmm0
movsd 0x250(%rsp), %xmm1
addsd 0x248(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0x2130
addsd 0x270(%rsp), %xmm0
movsd %xmm0, 0x270(%rsp)
testb $0x1, 0x38b(%rsp)
je 0x3edd
movsd 0x248(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
jmp 0x3eef
movsd 0x250(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0xc8(%rsp), %xmm0
movsd 0x250(%rsp), %xmm1
addsd 0x248(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0x2130
addsd 0x278(%rsp), %xmm0
movsd %xmm0, 0x278(%rsp)
cmpl $0x0, 0x394(%rsp)
jle 0x40dd
leaq 0x113c6(%rip), %rsi     # 0x15300
leaq 0x628(%rsp), %rdi
callq 0x2410
movsd %xmm0, 0xc0(%rsp)
jmp 0x3f52
leaq 0x113c7(%rip), %rsi     # 0x15320
leaq 0x5b0(%rsp), %rdi
callq 0x2410
movsd %xmm0, 0xb8(%rsp)
jmp 0x3f71
movsd 0xb8(%rsp), %xmm1
movsd 0xc0(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x208(%rsp)
movsd 0x208(%rsp), %xmm0
subsd 0x280(%rsp), %xmm0
addsd 0x278(%rsp), %xmm0
subsd 0x270(%rsp), %xmm0
callq 0x2270
movsd %xmm0, 0x200(%rsp)
movsd 0x11046(%rip), %xmm0    # 0x15010
addsd 0x3a8(%rsp), %xmm0
movsd %xmm0, 0x3a8(%rsp)
movsd 0x200(%rsp), %xmm0
movsd 0x11023(%rip), %xmm1    # 0x15010
ucomisd %xmm1, %xmm0
jae 0x4023
leaq 0x6a0(%rsp), %rdi
callq 0x6510
movsd %xmm0, 0xb0(%rsp)
jmp 0x400b
movsd 0xb0(%rsp), %xmm1
movsd 0x200(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x4042
movsd 0x10fe5(%rip), %xmm0    # 0x15010
addsd 0x3b0(%rsp), %xmm0
movsd %xmm0, 0x3b0(%rsp)
jmp 0x40db
leaq 0x628(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x6540
leaq 0x5b0(%rsp), %rdi
leaq 0x288(%rsp), %rsi
callq 0x6540
movb 0x38b(%rsp), %al
movb %al, 0x9f(%rsp)
movslq 0x390(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
callq 0x6a50
movq %rdx, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
jmp 0x40a1
movb 0x9f(%rsp), %al
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rdx
movq %rdx, 0x1f0(%rsp)
movq %rcx, 0x1f8(%rsp)
movzbl %al, %esi
andl $0x1, %esi
leaq 0x1f0(%rsp), %rdi
callq 0x6b30
jmp 0x40dd
leaq 0x288(%rsp), %rdi
callq 0x65a0
leaq 0x300(%rsp), %rdi
callq 0x65a0
movl 0x390(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x390(%rsp)
jmp 0x3973
leaq 0x300(%rsp), %rdi
callq 0x65a0
jmp 0x489b
cmpl $0xc8, 0x394(%rsp)
jle 0x4370
movl 0x394(%rsp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x9, %edx
jne 0x4370
leaq 0x628(%rsp), %rdi
callq 0x65e0
movl %eax, 0x98(%rsp)
jmp 0x415e
movl 0x98(%rsp), %eax
movl %eax, %eax
movq %rax, 0x90(%rsp)
leaq 0x588(%rsp), %rdi
callq 0x6b80
movq %rax, %rcx
movq 0x90(%rsp), %rax
cmpq %rcx, %rax
jae 0x418e
jmp 0x41ad
leaq 0x11294(%rip), %rdi     # 0x15429
leaq 0x112ac(%rip), %rsi     # 0x15448
movl $0xb7, %edx
leaq 0x112ac(%rip), %rcx     # 0x15454
callq 0x20e0
leaq 0x5b0(%rsp), %rdi
callq 0x65e0
movl %eax, 0x8c(%rsp)
jmp 0x41c3
movl 0x8c(%rsp), %eax
movl %eax, %eax
movq %rax, 0x80(%rsp)
leaq 0x568(%rsp), %rdi
callq 0x6b80
movq %rax, %rcx
movq 0x80(%rsp), %rax
cmpq %rcx, %rax
jae 0x41f3
jmp 0x4212
leaq 0x1126a(%rip), %rdi     # 0x15464
leaq 0x11247(%rip), %rsi     # 0x15448
movl $0xb8, %edx
leaq 0x11247(%rip), %rcx     # 0x15454
callq 0x20e0
leaq 0x628(%rsp), %rdi
callq 0x65e0
movl %eax, 0x7c(%rsp)
jmp 0x4225
movl 0x7c(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
leaq 0x588(%rsp), %rdi
callq 0x65c0
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
leaq 0x5b0(%rsp), %rdi
callq 0x65e0
movl %eax, 0x78(%rsp)
jmp 0x4253
movl 0x78(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
leaq 0x568(%rsp), %rdi
callq 0x65c0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movsd 0x10d99(%rip), %xmm0    # 0x15010
addsd 0x3b8(%rsp), %xmm0
movsd %xmm0, 0x3b8(%rsp)
movl $0x0, 0x1ec(%rsp)
cmpl $0xf, 0x1ec(%rsp)
jge 0x436e
movslq 0x1ec(%rsp), %rcx
movl %ecx, %eax
imulq $0x55555556, %rcx, %rdx # imm = 0x55555556
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
movl %eax, 0x1e8(%rsp)
movslq 0x1ec(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
callq 0x6a50
movq %rdx, 0x68(%rsp)
movq %rax, 0x70(%rsp)
jmp 0x42ef
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rcx, 0x1d8(%rsp)
movq %rax, 0x1e0(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x6ab0
xorb $-0x1, %al
testb $0x1, %al
jne 0x431e
jmp 0x4356
movl 0x1e8(%rsp), %eax
cvtsi2sd %rax, %xmm0
addsd 0x398(%rsp), %xmm0
movsd %xmm0, 0x398(%rsp)
movsd 0x10ccc(%rip), %xmm0    # 0x15010
addsd 0x3a0(%rsp), %xmm0
movsd %xmm0, 0x3a0(%rsp)
jmp 0x4358
movl 0x1ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1ec(%rsp)
jmp 0x4294
jmp 0x4370
jmp 0x4372
movl 0x394(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x394(%rsp)
jmp 0x3957
movsd 0x3a8(%rsp), %xmm1
movsd 0x3b0(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x3b0(%rsp)
movq 0x19c42(%rip), %rdi     # 0x1dff0
leaq 0x11034(%rip), %rsi     # 0x153e9
callq 0x2180
movq %rax, 0x60(%rsp)
jmp 0x43c1
movq 0x60(%rsp), %rdi
movsd 0x3b0(%rsp), %xmm0
callq 0x2290
movq %rax, 0x58(%rsp)
jmp 0x43db
movq 0x58(%rsp), %rdi
movq 0x19be1(%rip), %rsi     # 0x1dfc8
callq 0x21a0
jmp 0x43ee
movl $0x0, 0x1d4(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1c8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1c0(%rsp)
movl $0x0, 0x1bc(%rsp)
cmpl $0xf, 0x1bc(%rsp)
jge 0x4638
movslq 0x1bc(%rsp), %rsi
leaq 0x588(%rsp), %rdi
callq 0x65c0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x1b0(%rsp)
movslq 0x1bc(%rsp), %rsi
leaq 0x568(%rsp), %rdi
callq 0x65c0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x1a8(%rsp)
movsd 0x1b0(%rsp), %xmm0
movsd 0x3b8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movslq 0x1d4(%rsp), %rsi
leaq 0x548(%rsp), %rdi
callq 0x6ba0
movsd 0x40(%rsp), %xmm0
movsd (%rax), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x1a0(%rsp)
movsd 0x1a8(%rsp), %xmm0
movsd 0x3b8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movslq 0x1d4(%rsp), %rsi
movl %esi, %eax
incl %eax
movl %eax, 0x1d4(%rsp)
leaq 0x490(%rsp), %rdi
callq 0x6ba0
movsd 0x48(%rsp), %xmm0
movsd (%rax), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x198(%rsp)
movsd 0x1a0(%rsp), %xmm0
movq 0x19ad7(%rip), %rdi     # 0x1dff0
callq 0x2290
movq %rax, 0x50(%rsp)
jmp 0x4525
movq 0x50(%rsp), %rdi
leaq 0x10ec5(%rip), %rsi     # 0x153f6
callq 0x2180
movq %rax, 0x38(%rsp)
jmp 0x453d
movq 0x38(%rsp), %rdi
movsd 0x198(%rsp), %xmm0
callq 0x2290
movq %rax, 0x30(%rsp)
jmp 0x4557
movq 0x30(%rsp), %rdi
movq 0x19a65(%rip), %rsi     # 0x1dfc8
callq 0x21a0
jmp 0x456a
movsd 0x1a0(%rsp), %xmm0
movaps 0x10b06(%rip), %xmm1    # 0x15080
pand %xmm1, %xmm0
movsd 0x198(%rsp), %xmm1
movaps 0x10af2(%rip), %xmm2    # 0x15080
pand %xmm2, %xmm1
addsd %xmm1, %xmm0
addsd 0x1c8(%rsp), %xmm0
movsd %xmm0, 0x1c8(%rsp)
movsd 0x1a0(%rsp), %xmm0
movaps 0x10ac8(%rip), %xmm1    # 0x15080
pand %xmm1, %xmm0
ucomisd 0x1c0(%rsp), %xmm0
jbe 0x45e4
movsd 0x1a0(%rsp), %xmm0
movaps 0x10aa9(%rip), %xmm1    # 0x15080
pand %xmm1, %xmm0
movsd %xmm0, 0x1c0(%rsp)
movsd 0x198(%rsp), %xmm0
movaps 0x10a8c(%rip), %xmm1    # 0x15080
pand %xmm1, %xmm0
ucomisd 0x1c0(%rsp), %xmm0
jbe 0x4620
movsd 0x198(%rsp), %xmm0
movaps 0x10a6d(%rip), %xmm1    # 0x15080
pand %xmm1, %xmm0
movsd %xmm0, 0x1c0(%rsp)
jmp 0x4622
movl 0x1bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bc(%rsp)
jmp 0x441c
movsd 0x1c8(%rsp), %xmm0
movsd 0x109df(%rip), %xmm1    # 0x15028
divsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
movq 0x19993(%rip), %rdi     # 0x1dff0
leaq 0x10e23(%rip), %rsi     # 0x15487
callq 0x2180
movq %rax, 0x28(%rsp)
jmp 0x4670
movq 0x28(%rsp), %rdi
movsd 0x398(%rsp), %xmm0
movsd 0x3a0(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0x2290
movq %rax, 0x20(%rsp)
jmp 0x4697
movq 0x20(%rsp), %rdi
movq 0x19925(%rip), %rsi     # 0x1dfc8
callq 0x21a0
jmp 0x46aa
movsd 0x398(%rsp), %xmm0
movsd 0x3a0(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x3f0(%rsp), %xmm1
subsd %xmm1, %xmm0
movaps 0x109ac(%rip), %xmm1    # 0x15080
pand %xmm1, %xmm0
movlpd %xmm0, 0x190(%rsp)
movq 0x19908(%rip), %rdi     # 0x1dff0
leaq 0x10d94(%rip), %rsi     # 0x15483
callq 0x2180
movq %rax, 0x18(%rsp)
jmp 0x46fb
movq 0x18(%rsp), %rdi
movsd 0x190(%rsp), %xmm0
callq 0x2290
jmp 0x4710
movsd 0x190(%rsp), %xmm0
movsd 0x108ff(%rip), %xmm1    # 0x15020
ucomisd %xmm1, %xmm0
jbe 0x473e
movq 0x198c2(%rip), %rdi     # 0x1dff0
leaq 0x10cd3(%rip), %rsi     # 0x15408
callq 0x2180
jmp 0x473c
jmp 0x473e
movq 0x198ab(%rip), %rdi     # 0x1dff0
movq 0x1987c(%rip), %rsi     # 0x1dfc8
callq 0x21a0
jmp 0x4753
movq 0x19896(%rip), %rdi     # 0x1dff0
leaq 0x10c97(%rip), %rsi     # 0x153f8
callq 0x2180
movq %rax, 0x10(%rsp)
jmp 0x476d
movq 0x10(%rsp), %rdi
movsd 0x1c8(%rsp), %xmm0
callq 0x2290
jmp 0x4782
movsd 0x1c8(%rsp), %xmm0
movsd 0x1088d(%rip), %xmm1    # 0x15020
ucomisd %xmm1, %xmm0
jbe 0x47b0
movq 0x19850(%rip), %rdi     # 0x1dff0
leaq 0x10c61(%rip), %rsi     # 0x15408
callq 0x2180
jmp 0x47ae
jmp 0x47b0
movq 0x19839(%rip), %rdi     # 0x1dff0
movq 0x1980a(%rip), %rsi     # 0x1dfc8
callq 0x21a0
movq %rax, 0x8(%rsp)
jmp 0x47ca
movq 0x8(%rsp), %rdi
leaq 0x10c43(%rip), %rsi     # 0x15419
callq 0x2180
movq %rax, (%rsp)
jmp 0x47e1
movq (%rsp), %rdi
movsd 0x1c0(%rsp), %xmm0
callq 0x2290
jmp 0x47f5
movsd 0x1c0(%rsp), %xmm0
movsd 0x1081a(%rip), %xmm1    # 0x15020
ucomisd %xmm1, %xmm0
jbe 0x4823
movq 0x197dd(%rip), %rdi     # 0x1dff0
leaq 0x10bee(%rip), %rsi     # 0x15408
callq 0x2180
jmp 0x4821
jmp 0x4823
movq 0x197c6(%rip), %rdi     # 0x1dff0
movq 0x19797(%rip), %rsi     # 0x1dfc8
callq 0x21a0
jmp 0x4838
leaq 0x3c8(%rsp), %rdi
callq 0x6bc0
leaq 0x490(%rsp), %rdi
callq 0x6740
leaq 0x548(%rsp), %rdi
callq 0x6740
leaq 0x568(%rsp), %rdi
callq 0x66e0
leaq 0x588(%rsp), %rdi
callq 0x66e0
leaq 0x5b0(%rsp), %rdi
callq 0x65a0
leaq 0x628(%rsp), %rdi
callq 0x65a0
addq $0x1a28, %rsp           # imm = 0x1A28
retq
leaq 0x3c8(%rsp), %rdi
callq 0x6bc0
leaq 0x490(%rsp), %rdi
callq 0x6740
leaq 0x548(%rsp), %rdi
callq 0x6740
leaq 0x568(%rsp), %rdi
callq 0x66e0
leaq 0x588(%rsp), %rdi
callq 0x66e0
leaq 0x5b0(%rsp), %rdi
callq 0x65a0
leaq 0x628(%rsp), %rdi
callq 0x65a0
movq 0x5a8(%rsp), %rdi
callq 0x2260
nopw %cs:(%rax,%rax)