// File: joraso[P]Glassius/Particles.cpp
// Function: Particles::SaveTrajectory()
void Particles::SaveTrajectory(){
    /* Writes positions, velocities and forces to their respective trajectory
    files. */
    ofstream rtraj, vtraj, ftraj;
    
    rtraj.open("Data/rtraj.csv", std::ios::app);
    vtraj.open("Data/vtraj.csv", std::ios::app);
    ftraj.open("Data/ftraj.csv", std::ios::app);
    
    // File check-stops
    if(!rtraj.is_open()){
        cout << "Error opening position-trajectory file!" << endl;
        exit(1);
    }
    if(!vtraj.is_open()){
        cout << "Error opening velocity-trajectory file!" << endl;
        exit(1);
    }
    if(!ftraj.is_open()){
        cout << "Error opening force-trajectory file!" << endl;
        exit(1);
    }
    
    rtraj << positions; vtraj << velocities; ftraj << forces;
    rtraj.close(); vtraj.close(); ftraj.close();
    
}

// Assembly:
subq $0x658, %rsp            # imm = 0x658
movq %rdi, 0x650(%rsp)
movq 0x650(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x450(%rsp), %rdi
callq 0x21e0
leaq 0x250(%rsp), %rdi
callq 0x21e0
jmp 0x3d28
leaq 0x40(%rsp), %rdi
callq 0x21e0
jmp 0x3d34
leaq 0x540d(%rip), %rsi      # 0x9148
leaq 0x450(%rsp), %rdi
movl $0x1, %edx
callq 0x2060
jmp 0x3d4f
leaq 0x5401(%rip), %rsi      # 0x9157
leaq 0x250(%rsp), %rdi
movl $0x1, %edx
callq 0x2060
jmp 0x3d6a
leaq 0x53f5(%rip), %rsi      # 0x9166
leaq 0x40(%rsp), %rdi
movl $0x1, %edx
callq 0x2060
jmp 0x3d82
leaq 0x450(%rsp), %rdi
callq 0x20e0
movb %al, 0x37(%rsp)
jmp 0x3d95
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x3e2f
jmp 0x3da3
movq 0x8226(%rip), %rdi      # 0xbfd0
leaq 0x53c4(%rip), %rsi      # 0x9175
callq 0x2140
movq %rax, 0x28(%rsp)
jmp 0x3dbd
movq 0x28(%rsp), %rdi
movq 0x81ef(%rip), %rsi      # 0xbfb8
callq 0x2150
jmp 0x3dd0
movl $0x1, %edi
callq 0x2170
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x248(%rsp)
movl %eax, 0x244(%rsp)
jmp 0x3f7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x248(%rsp)
movl %eax, 0x244(%rsp)
jmp 0x3f6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x248(%rsp)
movl %eax, 0x244(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x21c0
jmp 0x3f6f
leaq 0x250(%rsp), %rdi
callq 0x20e0
movb %al, 0x27(%rsp)
jmp 0x3e42
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x3e83
jmp 0x3e4c
movq 0x817d(%rip), %rdi      # 0xbfd0
leaq 0x5343(%rip), %rsi      # 0x919d
callq 0x2140
movq %rax, 0x18(%rsp)
jmp 0x3e66
movq 0x18(%rsp), %rdi
movq 0x8146(%rip), %rsi      # 0xbfb8
callq 0x2150
jmp 0x3e79
movl $0x1, %edi
callq 0x2170
leaq 0x40(%rsp), %rdi
callq 0x20e0
movb %al, 0x17(%rsp)
jmp 0x3e93
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x3ed4
jmp 0x3e9d
movq 0x812c(%rip), %rdi      # 0xbfd0
leaq 0x531a(%rip), %rsi      # 0x91c5
callq 0x2140
movq %rax, 0x8(%rsp)
jmp 0x3eb7
movq 0x8(%rsp), %rdi
movq 0x80f5(%rip), %rsi      # 0xbfb8
callq 0x2150
jmp 0x3eca
movl $0x1, %edi
callq 0x2170
movq 0x38(%rsp), %rsi
addq $0x20, %rsi
leaq 0x450(%rsp), %rdi
callq 0x3700
jmp 0x3eec
movq 0x38(%rsp), %rsi
addq $0x30, %rsi
leaq 0x250(%rsp), %rdi
callq 0x3700
jmp 0x3f04
movq 0x38(%rsp), %rsi
addq $0x40, %rsi
leaq 0x40(%rsp), %rdi
callq 0x3700
jmp 0x3f19
leaq 0x450(%rsp), %rdi
callq 0x21a0
jmp 0x3f28
leaq 0x250(%rsp), %rdi
callq 0x21a0
jmp 0x3f37
leaq 0x40(%rsp), %rdi
callq 0x21a0
jmp 0x3f43
leaq 0x40(%rsp), %rdi
callq 0x21c0
leaq 0x250(%rsp), %rdi
callq 0x21c0
leaq 0x450(%rsp), %rdi
callq 0x21c0
addq $0x658, %rsp            # imm = 0x658
retq
leaq 0x250(%rsp), %rdi
callq 0x21c0
leaq 0x450(%rsp), %rdi
callq 0x21c0
movq 0x248(%rsp), %rdi
callq 0x2210
nopw %cs:(%rax,%rax)