// File: narges64[P]SIMBA/common.cpp
// Function: ssd_info::ssd_info(parameter_value*, char*)
ssd_info::ssd_info(parameter_value * parameters, char * statistics_filename)
{
	current_time = 0;
	parameter = parameters;
	int over_provide = 100.0 * parameters->overprovide;

	// repeat_times = new int[parameters->consolidation_degree];
	last_times = 0; // new int64_t [parameters->consolidation_degree];
	// for (int cd = 0; cd < parameters->consolidation_degree; cd++){
	repeat_times=0; 
	//	last_times[cd]=0;
	//	tracefile[cd] = NULL;
	// }

	lun_token = 0;

	request_sequence_number = 0;
	subrequest_sequence_number = 0;
	gc_sequence_number = 0;

	request_queue_length = 0;
	request_queue = NULL;
	stats = new statistics(parameters->consolidation_degree);

	dram = new dram_info(parameters);

	channel_head= new channel_info *[parameters->channel_number];
	for (int i = 0; i < parameters->channel_number; i++){
		channel_head[i] = new channel_info(i, parameters);
	}

	statisticfile=fopen(statistics_filename,"w");
	if(statisticfile==NULL)
	{
		printf("the statistic file can't open\n");
		return;
	}

	fprintf(statisticfile,"-----------------------parameter file----------------------\n");
	parameters->print_all_parameters(statisticfile);
	fprintf(statisticfile,"\n");
	fprintf(statisticfile,"-----------------------simulation output----------------------\n");
	fflush(statisticfile);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
addq $0x78, %rdi
callq 0x5350
movq -0x40(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rcx
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rcx
movss 0x25c(%rcx), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xb1c8(%rip), %xmm1     # 0xf008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, -0x1c(%rbp)
movq $0x0, 0x38(%rax)
movl $0x0, 0x30(%rax)
movl $0x0, 0x14(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movl $0x0, 0x1c(%rax)
movq $0x0, 0x68(%rax)
movl $0x1d0, %edi            # imm = 0x1D0
callq 0x2130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %esi
callq 0x4150
jmp 0x3ea7
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x98(%rax)
movl $0x28, %edi
callq 0x2130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rsi
callq 0x4560
jmp 0x3ed5
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
movl 0x98(%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2040
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x90(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x98(%rcx), %eax
jae 0x3fd5
movl $0x60, %edi
callq 0x2130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
movl -0x30(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x4c50
jmp 0x3f56
movq -0x50(%rbp), %rdx
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3f21
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x1d0, %esi            # imm = 0x1D0
callq 0x2140
jmp 0x406d
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x2140
jmp 0x406d
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x60, %esi
callq 0x2140
jmp 0x406d
movq -0x18(%rbp), %rdi
leaq 0xb04b(%rip), %rsi      # 0xf02b
callq 0x2190
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x50(%rax)
cmpq $0x0, 0x50(%rax)
jne 0x4007
leaq 0xb02f(%rip), %rdi      # 0xf02d
movb $0x0, %al
callq 0x2050
jmp 0x4067
movq -0x40(%rbp), %rax
movq 0x50(%rax), %rdi
leaq 0xb036(%rip), %rsi      # 0xf04c
movb $0x0, %al
callq 0x21f0
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x50(%rax), %rsi
callq 0x3d70
movq -0x40(%rbp), %rax
movq 0x50(%rax), %rdi
leaq 0xbee9(%rip), %rsi      # 0xff26
movb $0x0, %al
callq 0x21f0
movq -0x40(%rbp), %rax
movq 0x50(%rax), %rdi
leaq 0xb036(%rip), %rsi      # 0xf089
movb $0x0, %al
callq 0x21f0
movq -0x40(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x2180
addq $0x50, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x2230
nopw %cs:(%rax,%rax)