// File: /workspace/github_cpp_makefile_star2_O1/joraso[P]Glassius/Integration.cpp
// Function: Integrator::Equilibrate(double, int)
void Integrator::Equilibrate(double t, int Nthermalize){
    /* Advanced the integration for time=t, themostating the system every
    Nthermalize steps. Records into an energy file as it does. */
    
    // Cycling indeces
    int m, n; int steps = int(t/dt);
    int cycles = int(steps/Nrecord);
    int s = 0; // thermostat counter
    
    // Retrieving the system time
    time = System->Time();
    
    // Prepping output file
    std::ofstream energyfile;
    energyfile.open(efilename, std::ios::app);
    
    // File check-stop
    if(!energyfile.is_open()){
        cout << "Error opening energy file!" << endl;
        exit(1);
    }
    
    // Integrating
    for(m=0;m<cycles;m++){
        for(n=0;n<Nrecord;n++){
            Propigate(); s++;
            if(s%Nthermalize==0){System->Thermalize(Temp);}
        }
        energyfile << time << ", ";
        energyfile << System->KE() << ", ";
        energyfile << System->PE() << ", ";
        energyfile << System->TotalEnergy() << std::endl;
        if (recordtraj) {System->SaveTrajectory();};
    }
    
    // Closing the energy file
    energyfile.close();
    
    // Storing the system time
    System->setTime(time);
    
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movl %esi, %ebp
movq %rdi, %rbx
divsd 0x18(%rdi), %xmm0
cvttsd2si %xmm0, %eax
cltd
idivl 0x28(%rdi)
movl %eax, 0x4(%rsp)
movq 0x8(%rdi), %rax
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x20(%rdi)
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2280
leaq 0x30(%rbx), %rsi
movq %r15, %rdi
movl $0x1, %edx
callq 0x20d0
leaq 0x78(%rsp), %rdi
callq 0x2070
testb %al, %al
je 0x3f67
cmpl $0x0, 0x4(%rsp)
jle 0x3f0b
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
xorl %r12d, %r12d
cmpl $0x0, 0x28(%rbx)
jle 0x3e34
xorl %r13d, %r13d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
leal (%r12,%r13), %eax
incl %eax
cltd
idivl %ebp
testl %edx, %edx
jne 0x3e28
movq 0x8(%rbx), %rdi
movsd 0x10(%rbx), %xmm0
callq 0x3630
incl %r13d
cmpl 0x28(%rbx), %r13d
jl 0x3e04
addl %r13d, %r12d
movsd 0x20(%rbx), %xmm0
movq %r15, %rdi
callq 0x2260
movl $0x2, %edx
movq %rax, %rdi
leaq 0x440c(%rip), %rsi      # 0x825c
callq 0x21e0
movq 0x8(%rbx), %r13
movq %r13, %rdi
callq 0x35dc
movsd 0x78(%r13), %xmm0
movq %r15, %rdi
callq 0x2260
movl $0x2, %edx
movq %rax, %rdi
leaq 0x43de(%rip), %rsi      # 0x825c
callq 0x21e0
movq 0x8(%rbx), %rax
movsd 0x80(%rax), %xmm0
movq %r15, %rdi
callq 0x2260
movl $0x2, %edx
movq %rax, %rdi
leaq 0x43b6(%rip), %rsi      # 0x825c
callq 0x21e0
movq 0x8(%rbx), %rax
movsd 0x78(%rax), %xmm0
addsd 0x80(%rax), %xmm0
movq %r15, %rdi
callq 0x2260
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2120
cmpb $0x1, 0x50(%rbx)
jne 0x3efd
movq 0x8(%rbx), %rdi
callq 0x3372
incl %r14d
cmpl 0x4(%rsp), %r14d
jne 0x3dfb
leaq 0x8(%rsp), %rdi
callq 0x2220
movq 0x8(%rbx), %rax
movsd 0x20(%rbx), %xmm0
movsd %xmm0, 0x70(%rax)
movq 0x70a6(%rip), %rax      # 0xafd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x10(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x8(%rsp,%rcx)
callq 0x2180
leaq 0x100(%rsp), %rdi
callq 0x2090
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x706a(%rip), %rdi      # 0xafd8
leaq 0x42cc(%rip), %rsi      # 0x8241
movl $0x1a, %edx
callq 0x21e0
movq 0x7052(%rip), %rdi      # 0xafd8
callq 0x20e0
movl $0x1, %edi
callq 0x21f0
jmp 0x3f99
jmp 0x3f99
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2240
movq %rbx, %rdi
callq 0x22b0