// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/ssd.cpp
// Function: main
int  main(int argc, char * argv[]){

	if (argc < 3) {
		printf("Not enough parameters: specify parameter file and statistic file! \n");
		return 0;
	}
	parameter_value * parameters = new parameter_value(argc, argv);
	ssd_info * ssd = new ssd_info(parameters, argv[2]); 

	ssd->tracefile = fopen(ssd->parameter->trace_filename, "r"); 
	if (ssd->tracefile == NULL){
		generate_trace_file(ssd, ssd->parameter->trace_filename); 
		ssd->tracefile = fopen(ssd->parameter->trace_filename, "r"); 
	}
	if (ssd->tracefile == NULL) {
		cout << "still trace file is null " << endl; 
		return 1; 
	}

	fseek(ssd->tracefile, 0 ,SEEK_SET);

	cerr << "start pre-conditioning " << endl;
	full_write_preconditioning(ssd, true);   // sequential 
	full_write_preconditioning(ssd, false);  // random 

	ssd->stats->print_all(); // does nothing now 
	ssd->stats->reset_all();
	
	ssd->reset_ssd_stats(); // reset read, write, erase number to zero 

	simulate(ssd);

	collect_gc_statistics(ssd, 0);
	print_epoch_statistics(ssd, 0);
	print_statistics(ssd, 0);

	close_files(ssd);
				
	delete ssd; 

	printf("\nthe simulation is completed!\n");

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x2, %edi
jg 0x7f6f
leaq 0x311c(%rip), %rdi      # 0xb07f
callq 0x22a0
xorl %ebp, %ebp
jmp 0x8116
movq %rsi, %r15
movl %edi, %ebx
movl $0x350, %edi            # imm = 0x350
callq 0x2190
movq %rax, %r14
movq %rax, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x24ec
movl $0xa0, %edi
callq 0x2190
movq %rax, %rbx
movq 0x10(%r15), %rdx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3aac
movq 0x58(%rbx), %rax
movq 0x340(%rax), %rdi
leaq 0x2271(%rip), %rsi      # 0xa22d
callq 0x2200
movq %rax, 0x48(%rbx)
testq %rax, %rax
jne 0x7ff8
movq 0x58(%rbx), %rax
movq 0x340(%rax), %rsi
movq %rbx, %rdi
callq 0x8148
movq 0x58(%rbx), %rax
movq 0x340(%rax), %rdi
leaq 0x223e(%rip), %rsi      # 0xa22d
callq 0x2200
movq %rax, 0x48(%rbx)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x80cf
xorl %esi, %esi
xorl %edx, %edx
callq 0x21c0
movq 0x5fdb(%rip), %r14      # 0xdff0
leaq 0x2c4e(%rip), %rsi      # 0xac6a
movl $0x17, %edx
movq %r14, %rdi
callq 0x21e0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x20f0
movl $0x1, %ebp
movq %rbx, %rdi
movl $0x1, %esi
callq 0x45b0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x45b0
movq 0x98(%rbx), %rdi
callq 0x3dac
movq %rbx, %rdi
callq 0x3c36
movq %rbx, %rdi
callq 0x81f5
movq %rbx, %rdi
callq 0x82d6
movq %rbx, %rdi
xorl %esi, %esi
callq 0x869f
movq 0x50(%rbx), %rdi
callq 0x21f0
movq 0x50(%rbx), %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x988c
movl $0xa0, %esi
movq %rbx, %rdi
callq 0x21a0
leaq 0x2f99(%rip), %rdi      # 0xb061
callq 0x22a0
jmp 0x8116
movq 0x5efa(%rip), %rbx      # 0xdfd0
leaq 0x2b73(%rip), %rsi      # 0xac50
movl $0x19, %edx
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x20f0
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movl $0xa0, %esi
movq %rbx, %rdi
jmp 0x813b
movq %rax, %r15
movl $0x350, %esi            # imm = 0x350
movq %r14, %rdi
callq 0x21a0
movq %r15, %rdi
callq 0x22e0