// File: /workspace/github_c_makefile_star2_O3/guszejnovdavid[P]MISFIT/InputDataManage.cpp
// Function: SaveInputStorage(char*)
void SaveInputStorage(char* filename){
	long i,j;
	ofstream myfile; //Output file handle
	
	if(file_exists (filename)){
		remove(filename); //removes previous restart data
	}
    //Open file
    myfile.open(filename,ios::out);
    //Save parameters of stars
    for(i=0;i<NInputAllocated;i++){
    	if(IsUsed[i]){ //only save usable data
	    	//Save rho
			for(j=0;j<NgridTotal;j++){
				myfile<<InputStorage[i].rho_field[j]<<"\n";
	     	}
	    	//Save T
			for(j=0;j<NgridTotal;j++){
				myfile<<InputStorage[i].T_field[j]<<"\n";
	     	}
	     	//Save R0
	     	myfile<<InputStorage[i].R0<<"\n";
	     	//Save X0,Y0,Z0
	     	myfile<<InputStorage[i].X0<<"\n"; myfile<<InputStorage[i].Y0<<"\n";	myfile<<InputStorage[i].Z0<<"\n";
	     	//Save Machedge
	     	myfile<<InputStorage[i].Machedge<<"\n";
	     	//Save VX0,VY0,VZ0
	     	myfile<<InputStorage[i].RelativeVelocityX<<"\n"; myfile<<InputStorage[i].RelativeVelocityY<<"\n";	myfile<<InputStorage[i].RelativeVelocityZ<<"\n";
	     	//Save InitScale
	     	myfile<<InputStorage[i].InitScale<<"\n";
	     	//Save tparent
	     	myfile<<InputStorage[i].tparent<<"\n";  // new line after last data item
		}
     }
     myfile.flush(); //finish writing
     myfile.close(); //close file	
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rdi, %rbx
movq %rsp, %rdi
callq 0x2380
movq %rbx, %rdi
callq 0x8058
testb %al, %al
je 0x7a23
movq %rbx, %rdi
callq 0x23d0
movq %rsp, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2040
movq 0x785e(%rip), %rax      # 0xf298
testq %rax, %rax
jle 0x7c92
xorl %r15d, %r15d
movq %rsp, %rbx
leaq 0x37e9(%rip), %r14      # 0xb239
xorl %r12d, %r12d
movq 0x7836(%rip), %rcx      # 0xf290
cmpb $0x1, (%rcx,%r12)
jne 0x7c7f
xorl %r13d, %r13d
movq 0x7811(%rip), %rax      # 0xf280
addq %r15, %rax
movsd (%rax,%r13,8), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
incq %r13
cmpq $0x8000, %r13           # imm = 0x8000
jne 0x7a68
xorl %r13d, %r13d
movq 0x77da(%rip), %rax      # 0xf280
addq %r15, %rax
movsd 0x40000(%rax,%r13,8), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
incq %r13
cmpq $0x8000, %r13           # imm = 0x8000
jne 0x7a9f
movq 0x77a2(%rip), %rax      # 0xf280
imulq $0x80050, %r12, %r13    # imm = 0x80050
movsd 0x80000(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x7772(%rip), %rax      # 0xf280
movsd 0x80008(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x7749(%rip), %rax      # 0xf280
movsd 0x80010(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x7720(%rip), %rax      # 0xf280
movsd 0x80018(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x76f7(%rip), %rax      # 0xf280
movsd 0x80020(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x76ce(%rip), %rax      # 0xf280
movsd 0x80028(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x76a5(%rip), %rax      # 0xf280
movsd 0x80030(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x767c(%rip), %rax      # 0xf280
movsd 0x80038(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x7653(%rip), %rax      # 0xf280
movsd 0x80040(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x762a(%rip), %rax      # 0xf280
movsd 0x80048(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movq 0x7619(%rip), %rax      # 0xf298
incq %r12
addq $0x80050, %r15          # imm = 0x80050
cmpq %rax, %r12
jl 0x7a53
movq %rsp, %rdi
callq 0x2120
movq %rsp, %rdi
callq 0x22c0
movq 0x72ff(%rip), %rax      # 0xefa8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x8(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, (%rsp,%rcx)
callq 0x2190
leaq 0xf8(%rsp), %rdi
callq 0x20a0
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x7cea
jmp 0x7cea
jmp 0x7cea
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22e0
movq %rbx, %rdi
callq 0x23a0