// File: /workspace/github_c_makefile_star2_O2/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 0x2340
movq %rbx, %rdi
callq 0x7a0c
testb %al, %al
je 0x7468
movq %rbx, %rdi
callq 0x2390
movq %rsp, %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x2040
xorl %r15d, %r15d
movq %rsp, %rbx
leaq 0x3db6(%rip), %r14      # 0xb239
xorl %r12d, %r12d
cmpq 0x7deb(%rip), %r12      # 0xf278
jge 0x7688
movq 0x7dd6(%rip), %rax      # 0xf270
cmpb $0x1, (%rax,%r12)
jne 0x7679
xorl %r13d, %r13d
cmpq $0x8000, %r13           # imm = 0x8000
je 0x74d9
movq 0x7da8(%rip), %rax      # 0xf260
addq %r15, %rax
movsd (%rax,%r13,8), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x74a8
xorl %r13d, %r13d
movq 0x7d7d(%rip), %rax      # 0xf260
cmpq $0x8000, %r13           # imm = 0x8000
je 0x7511
addq %r15, %rax
movsd 0x40000(%rax,%r13,8), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r13
jmp 0x74dc
imulq $0x80050, %r12, %r13    # imm = 0x80050
movsd 0x80000(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7d24(%rip), %rax      # 0xf260
movsd 0x80008(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7d00(%rip), %rax      # 0xf260
movsd 0x80010(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7cdc(%rip), %rax      # 0xf260
movsd 0x80018(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7cb8(%rip), %rax      # 0xf260
movsd 0x80020(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7c94(%rip), %rax      # 0xf260
movsd 0x80028(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7c70(%rip), %rax      # 0xf260
movsd 0x80030(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7c4c(%rip), %rax      # 0xf260
movsd 0x80038(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7c28(%rip), %rax      # 0xf260
movsd 0x80040(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x7c04(%rip), %rax      # 0xf260
movsd 0x80048(%rax,%r13), %xmm0
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
incq %r12
addq $0x80050, %r15          # imm = 0x80050
jmp 0x7486
movq %rsp, %rdi
callq 0x2100
movq %rsp, %rdi
callq 0x2280
movq %rsp, %rdi
callq 0x22a0
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x76b7
jmp 0x76b7
jmp 0x76b7
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22a0
movq %rbx, %rdi
callq 0x2360