// File: kaityo256[P]thermostats/thermostats.cpp
// Function: void integrate<RungeKutta<NoseHoover>>(RungeKutta<NoseHoover>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void integrate(Method f, std::string name) {
  Vars v;
  v.q = 1.0;
  double t = 0;
  std::string pfile = name + "_ps.dat";
  std::ofstream ofs_p(pfile.c_str());
  std::cout << name << std::endl;
  std::vector<double> data_e;
  for (int i = 0; i < LOOP; i++) {
    t += dt;
    v = f(v);
    if (i % O_LOOP == 0) {
      ofs_p << t << " ";
      ofs_p << v.p << " ";
      ofs_p << v.q << " ";
      ofs_p << f.H(v) << std::endl;
      data_e.push_back(v.p * v.p * 0.5 + v.q * v.q * 0.5);
    }
  }
  std::sort(data_e.begin(), data_e.end());
  const int n = data_e.size();
  const double nd = static_cast<double>(n);
  std::string efile = name + ".dat";
  std::ofstream ofs(efile.c_str());
  for (int i = 0; i < n; i++) {
    ofs << data_e[i] << " " << static_cast<double>(i) / nd << std::endl;
  }
}

// Assembly:
subq $0x5e8, %rsp            # imm = 0x5E8
movq %rdi, 0x80(%rsp)
leaq 0x5f0(%rsp), %rax
movq %rax, 0x78(%rsp)
movq %rdi, 0x5e0(%rsp)
leaq 0x5b8(%rsp), %rdi
callq 0x5290
movq 0x80(%rsp), %rsi
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x5c0(%rsp)
movq $0x0, 0x5b0(%rsp)
leaq 0x774a(%rip), %rdx      # 0xa0c8
leaq 0x590(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x52d0
movq 0x88(%rsp), %rdi
callq 0x2060
movq %rax, %rsi
leaq 0x390(%rsp), %rdi
movl $0x10, %edx
callq 0x2170
jmp 0x29b7
movq 0x80(%rsp), %rsi
movq 0xa612(%rip), %rdi      # 0xcfd8
callq 0x2110
movq %rax, 0x70(%rsp)
jmp 0x29d2
movq 0x70(%rsp), %rdi
movq 0xa5ea(%rip), %rsi      # 0xcfc8
callq 0x2150
jmp 0x29e5
leaq 0x368(%rsp), %rdi
callq 0x5360
movl $0x0, 0x364(%rsp)
cmpl $0x989680, 0x364(%rsp) # imm = 0x989680
jge 0x2ca0
movq 0x78(%rsp), %rsi
movsd 0x5b0(%rsp), %xmm0
movsd 0x75e4(%rip), %xmm1     # 0xa008
addsd %xmm1, %xmm0
movsd %xmm0, 0x5b0(%rsp)
movq 0x5d8(%rsp), %rax
movq %rax, 0x330(%rsp)
movups 0x5b8(%rsp), %xmm0
movups 0x5c8(%rsp), %xmm1
movaps %xmm1, 0x320(%rsp)
movaps %xmm0, 0x310(%rsp)
movq 0x330(%rsp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movaps 0x310(%rsp), %xmm0
movaps 0x320(%rsp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq 0x338(%rsp), %rdi
callq 0x5370
jmp 0x2a96
leaq 0x5b8(%rsp), %rdi
leaq 0x338(%rsp), %rsi
movl $0x28, %edx
callq 0x20f0
movl 0x364(%rsp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2c88
movsd 0x5b0(%rsp), %xmm0
leaq 0x390(%rsp), %rdi
callq 0x21e0
movq %rax, 0x68(%rsp)
jmp 0x2ae5
movq 0x68(%rsp), %rdi
leaq 0x75df(%rip), %rsi      # 0xa0d0
callq 0x2130
jmp 0x2af8
movsd 0x5b8(%rsp), %xmm0
leaq 0x390(%rsp), %rdi
callq 0x21e0
movq %rax, 0x60(%rsp)
jmp 0x2b15
movq 0x60(%rsp), %rdi
leaq 0x75af(%rip), %rsi      # 0xa0d0
callq 0x2130
jmp 0x2b28
movsd 0x5c0(%rsp), %xmm0
leaq 0x390(%rsp), %rdi
callq 0x21e0
movq %rax, 0x58(%rsp)
jmp 0x2b45
movq 0x58(%rsp), %rdi
leaq 0x757f(%rip), %rsi      # 0xa0d0
callq 0x2130
jmp 0x2b58
movq 0x78(%rsp), %rdi
movq 0x5d8(%rsp), %rax
movq %rax, 0x300(%rsp)
movups 0x5b8(%rsp), %xmm0
movups 0x5c8(%rsp), %xmm1
movaps %xmm1, 0x2f0(%rsp)
movaps %xmm0, 0x2e0(%rsp)
movq 0x300(%rsp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movaps 0x2e0(%rsp), %xmm0
movaps 0x2f0(%rsp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x5680
movsd %xmm0, 0x50(%rsp)
jmp 0x2bc0
movsd 0x50(%rsp), %xmm0
leaq 0x390(%rsp), %rdi
callq 0x21e0
movq %rax, 0x48(%rsp)
jmp 0x2bda
movq 0x48(%rsp), %rdi
movq 0xa3e2(%rip), %rsi      # 0xcfc8
callq 0x2150
jmp 0x2bed
movsd 0x5b8(%rsp), %xmm0
movsd 0x5c0(%rsp), %xmm1
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
movsd 0x7401(%rip), %xmm2     # 0xa010
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x2d8(%rsp)
leaq 0x368(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0x56e0
jmp 0x2c3b
jmp 0x2c88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x2eaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x2e9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x2e90
jmp 0x2c8a
movl 0x364(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x364(%rsp)
jmp 0x29fd
leaq 0x368(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x5750
movq 0x40(%rsp), %rdi
movq %rax, 0x2d0(%rsp)
callq 0x5780
movq %rax, 0x2c8(%rsp)
movq 0x2d0(%rsp), %rdi
movq 0x2c8(%rsp), %rsi
callq 0x5710
jmp 0x2ce3
leaq 0x368(%rsp), %rdi
callq 0x57b0
movq 0x80(%rsp), %rsi
movl %eax, 0x2c4(%rsp)
cvtsi2sdl 0x2c4(%rsp), %xmm0
movsd %xmm0, 0x2b8(%rsp)
leaq 0x73b3(%rip), %rdx      # 0xa0cb
leaq 0x298(%rsp), %rdi
callq 0x52d0
jmp 0x2d27
leaq 0x298(%rsp), %rdi
callq 0x2060
movq %rax, %rsi
leaq 0x98(%rsp), %rdi
movl $0x10, %edx
callq 0x2170
jmp 0x2d4b
movl $0x0, 0x94(%rsp)
movl 0x94(%rsp), %eax
cmpl 0x2c4(%rsp), %eax
jge 0x2e3a
movslq 0x94(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x57d0
movsd (%rax), %xmm0
leaq 0x98(%rsp), %rdi
callq 0x21e0
movq %rax, 0x38(%rsp)
jmp 0x2d97
movq 0x38(%rsp), %rdi
leaq 0x732d(%rip), %rsi      # 0xa0d0
callq 0x2130
movq %rax, 0x30(%rsp)
jmp 0x2daf
movq 0x30(%rsp), %rdi
cvtsi2sdl 0x94(%rsp), %xmm0
movsd 0x2b8(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0x21e0
movq %rax, 0x28(%rsp)
jmp 0x2dd6
movq 0x28(%rsp), %rdi
movq 0xa1e6(%rip), %rsi      # 0xcfc8
callq 0x2150
jmp 0x2de9
jmp 0x2deb
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x2d56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x2e83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x2190
jmp 0x2e83
leaq 0x98(%rsp), %rdi
callq 0x2190
leaq 0x298(%rsp), %rdi
callq 0x20a0
leaq 0x368(%rsp), %rdi
callq 0x57f0
leaq 0x390(%rsp), %rdi
callq 0x2190
leaq 0x590(%rsp), %rdi
callq 0x20a0
addq $0x5e8, %rsp            # imm = 0x5E8
retq
leaq 0x298(%rsp), %rdi
callq 0x20a0
leaq 0x368(%rsp), %rdi
callq 0x57f0
leaq 0x390(%rsp), %rdi
callq 0x2190
leaq 0x590(%rsp), %rdi
callq 0x20a0
movq 0x388(%rsp), %rdi
callq 0x21c0
nopw %cs:(%rax,%rax)
nop