// File: /workspace/github_c_makefile_star2_O1/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 0x80d0
testb %al, %al
je 0x7a97
movq %rbx, %rdi
callq 0x23d0
movq %rsp, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x2040
cmpq $0x0, 0x77e9(%rip)      # 0xf298
jle 0x7d01
xorl %r15d, %r15d
movq %rsp, %rbx
leaq 0x3777(%rip), %r14      # 0xb239
xorl %r12d, %r12d
movq 0x77c4(%rip), %rax      # 0xf290
cmpb $0x1, (%rax,%r12)
jne 0x7cea
xorl %r13d, %r13d
movq 0x779f(%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 0x7ada
xorl %r13d, %r13d
movq 0x7768(%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 0x7b11
movq 0x7730(%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 0x7700(%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 0x76d7(%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 0x76ae(%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 0x7685(%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 0x765c(%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 0x7633(%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 0x760a(%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 0x75e1(%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 0x75b8(%rip), %rax      # 0xf280
movsd 0x80048(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2350
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
incq %r12
addq $0x80050, %r15          # imm = 0x80050
cmpq 0x759d(%rip), %r12      # 0xf298
jl 0x7ac5
movq %rsp, %rdi
callq 0x2120
movq %rsp, %rdi
callq 0x22c0
movq 0x7290(%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 0x7d59
jmp 0x7d59
jmp 0x7d59
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22e0
movq %rbx, %rdi
callq 0x23a0