// File: /workspace/github_c_makefile_star2_O3/guszejnovdavid[P]MISFIT/Restart.cpp
// Function: ReadRestartFile(long)
void ReadRestartFile(long NData)
{

	long i,j;
	char line[100];
	FILE* sourcefile;
    char filename[200];

	//Get filename
	ContructFilePath("Restart_Inputs.txt", "Output", filename);
	//open file
    sourcefile=fopen(filename,"r");
    for(i=0;i<NData;i++){
    	// Rho
    	for(j=0;j<NgridTotal;j++){
     		fgets (line, 100, sourcefile);
			InputStorage[i].rho_field[j]=strtod(line, NULL);
		}
    	// T
    	for(j=0;j<NgridTotal;j++){
     		fgets (line, 100, sourcefile);
			InputStorage[i].T_field[j]=strtod(line, NULL);
		}
		// R0
     	fgets (line, 100, sourcefile);
		InputStorage[i].R0=strtod(line, NULL);
		// X0,Y0,Z0
     	fgets (line, 100, sourcefile);
		InputStorage[i].X0=strtod(line, NULL);
     	fgets (line, 100, sourcefile);
		InputStorage[i].Y0=strtod(line, NULL);
     	fgets (line, 100, sourcefile);
		InputStorage[i].Z0=strtod(line, NULL);
		// MachEdge
     	fgets (line, 100, sourcefile);
		InputStorage[i].Machedge=strtod(line, NULL);
		// VX0,VY0,VZ0
     	fgets (line, 100, sourcefile);
		InputStorage[i].RelativeVelocityX=strtod(line, NULL);
     	fgets (line, 100, sourcefile);
		InputStorage[i].RelativeVelocityY=strtod(line, NULL);
     	fgets (line, 100, sourcefile);
		InputStorage[i].RelativeVelocityZ=strtod(line, NULL);
		// Initscale
     	fgets (line, 100, sourcefile);
		InputStorage[i].InitScale=strtod(line, NULL);
		// tparent
     	fgets (line, 100, sourcefile);
		InputStorage[i].tparent=strtod(line, NULL);	
		//Vector elements
		IsUsed[i]=true;
		InputPriority[i]=PriorityFunction(&InputStorage[i]);
    }
	fclose(sourcefile);
	NInputCurrent=NData;
	remove(filename);
		
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbx
leaq 0x2134(%rip), %rdi      # 0xb123
leaq 0x20a2(%rip), %rsi      # 0xb098
leaq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0x807d
leaq 0x26ee(%rip), %rsi      # 0xb6f8
movq %r14, %rdi
callq 0x2240
movq %rax, %r14
movq %rbx, 0x8(%rsp)
testq %rbx, %rbx
jle 0x926c
xorl %r12d, %r12d
leaq 0xe0(%rsp), %r15
leaq 0x624b(%rip), %r13      # 0xf280
xorl %ebp, %ebp
xorl %ebx, %ebx
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
addq %r12, %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
cmpq $0x8000, %rbx           # imm = 0x8000
jne 0x9039
xorl %ebx, %ebx
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
addq %r12, %rax
movsd %xmm0, 0x40000(%rax,%rbx,8)
incq %rbx
cmpq $0x8000, %rbx           # imm = 0x8000
jne 0x906d
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
imulq $0x80050, %rbp, %rbx    # imm = 0x80050
movsd %xmm0, 0x80000(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80008(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80010(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80018(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80020(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80028(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80030(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80038(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
movsd %xmm0, 0x80040(%rax,%rbx)
movq %r15, %rdi
movl $0x64, %esi
movq %r14, %rdx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
callq 0x2140
movq (%r13), %rax
leaq (%rax,%rbx), %rdi
movsd %xmm0, 0x80048(%rax,%rbx)
leaq 0x6055(%rip), %rax      # 0xf290
movq (%rax), %rax
movb $0x1, (%rax,%rbp)
callq 0x7dcc
leaq 0x603a(%rip), %rax      # 0xf288
movq (%rax), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
movl $0x80050, %eax          # imm = 0x80050
addq %rax, %r12
cmpq 0x8(%rsp), %rbp
jne 0x9037
movq %r14, %rdi
callq 0x21f0
leaq 0x6025(%rip), %rax      # 0xf2a0
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x10(%rsp), %rdi
callq 0x23d0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq