// File: tonymuu[P]distributed-kv-store/Params.cpp
// Function: Params::setparams(char*)
void Params::setparams(char *config_file) {
	//trace.funcEntry("Params::setparams");
	char CRUD[10];
	FILE *fp = fopen(config_file,"r");

	fscanf(fp,"MAX_NNB: %d", &MAX_NNB);
	fscanf(fp,"\nSINGLE_FAILURE: %d", &SINGLE_FAILURE);
	fscanf(fp,"\nDROP_MSG: %d", &DROP_MSG);
	fscanf(fp,"\nMSG_DROP_PROB: %lf", &MSG_DROP_PROB);
	fscanf(fp,"\nCRUD_TEST: %s", CRUD);

	auto type = testTypeMap.find(CRUD);
	if(type == testTypeMap.end()){
		throw std::runtime_error("Unavailable Test Type!");
	}
	else{
		this->CRUDTEST = type->second;
	}

	//printf("Parameters of the test case: %d %d %d %lf\n", MAX_NNB, SINGLE_FAILURE, DROP_MSG, MSG_DROP_PROB);

	EN_GPSZ = MAX_NNB;
	STEP_RATE=.25;
	MAX_MSG_SIZE = 4000;
	globaltime = 0;
	dropmsg = 0;
	allNodesJoined = 0;
	for ( int i = 0; i < EN_GPSZ; i++ ) {
		allNodesJoined += i;
	}
	fclose(fp);
	//trace.funcExit("Params::setparams", SUCCESS);
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x13fb2(%rip), %rsi     # 0x2c9bb
callq 0x4410
movq -0x98(%rbp), %rdx
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x1415c(%rip), %rsi     # 0x2cb80
xorl %eax, %eax
movb %al, -0x89(%rbp)
callq 0x45f0
movq -0x98(%rbp), %rdx
movb -0x89(%rbp), %al
movq -0x28(%rbp), %rdi
addq $0x4, %rdx
leaq 0x1413f(%rip), %rsi     # 0x2cb8c
callq 0x45f0
movq -0x98(%rbp), %rdx
movb -0x89(%rbp), %al
movq -0x28(%rbp), %rdi
addq $0x20, %rdx
leaq 0x14132(%rip), %rsi     # 0x2cba0
callq 0x45f0
movq -0x98(%rbp), %rdx
movb -0x89(%rbp), %al
movq -0x28(%rbp), %rdi
addq $0x8, %rdx
leaq 0x1411f(%rip), %rsi     # 0x2cbae
callq 0x45f0
movb -0x89(%rbp), %al
movq -0x28(%rbp), %rdi
leaq 0x1411d(%rip), %rsi     # 0x2cbc2
leaq -0x1a(%rbp), %rdx
movq %rdx, -0x88(%rbp)
callq 0x45f0
leaq -0x51(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x45c0
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0x7790
jmp 0x18ad8
leaq 0x30e51(%rip), %rdi     # 0x49930
leaq -0x50(%rbp), %rsi
callq 0x18c80
movq %rax, -0xa0(%rbp)
jmp 0x18af1
movq -0xa0(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4200
leaq -0x51(%rbp), %rdi
callq 0x43b0
leaq 0x30e1b(%rip), %rdi     # 0x49930
callq 0x18ce0
movq %rax, -0x70(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x18cb0
testb $0x1, %al
jne 0x18b34
jmp 0x18bc1
movl $0x10, %edi
callq 0x41a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
leaq 0x1407f(%rip), %rsi     # 0x2cbd1
callq 0x4130
jmp 0x18b59
movq -0xa8(%rbp), %rdi
movq 0x25489(%rip), %rsi     # 0x3dff0
movq 0x2544a(%rip), %rdx     # 0x3dfb8
callq 0x4590
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x18b96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4200
leaq -0x51(%rbp), %rdi
callq 0x43b0
jmp 0x18c52
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4270
jmp 0x18c52
leaq -0x30(%rbp), %rdi
callq 0x18d10
movq %rax, %rcx
movq -0x98(%rbp), %rax
movl 0x20(%rcx), %ecx
movl %ecx, 0x34(%rax)
movq -0x98(%rbp), %rax
movl (%rax), %ecx
movl %ecx, 0x18(%rax)
movsd 0x13f8a(%rip), %xmm0    # 0x2cb78
movsd %xmm0, 0x10(%rax)
movl $0xfa0, 0x1c(%rax)      # imm = 0xFA0
movl $0x0, 0x28(%rax)
movl $0x0, 0x24(%rax)
movl $0x0, 0x2c(%rax)
movl $0x0, -0x74(%rbp)
movq -0x98(%rbp), %rcx
movl -0x74(%rbp), %eax
cmpl 0x18(%rcx), %eax
jge 0x18c40
movq -0x98(%rbp), %rax
movl -0x74(%rbp), %ecx
addl 0x2c(%rax), %ecx
movl %ecx, 0x2c(%rax)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x18c16
movq -0x28(%rbp), %rdi
callq 0x4340
addq $0xb0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x45b0
nopl (%rax,%rax)