// File: /workspace/github_cpp_makefile_star2_O3/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 0x7ea7
leaq 0x31fc(%rip), %rdi      # 0xb097
callq 0x22a0
xorl %ebp, %ebp
jmp 0x8004
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 0x3ab2
movq 0x58(%rbx), %rax
movq 0x340(%rax), %rdi
leaq 0x2339(%rip), %rsi      # 0xa22d
callq 0x2200
movq %rax, 0x48(%rbx)
testq %rax, %rax
jne 0x7f39
movq 0x58(%rbx), %rax
movq 0x340(%rax), %rsi
movq %rbx, %rdi
callq 0x807f
movq 0x58(%rbx), %rax
movq 0x340(%rax), %rdi
leaq 0x2306(%rip), %rsi      # 0xa22d
callq 0x2200
movq %rax, 0x48(%rbx)
testq %rax, %rax
je 0x8011
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21c0
movq 0x60a4(%rip), %r14      # 0xdff0
leaq 0x2d2f(%rip), %rsi      # 0xac82
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 0x4594
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4594
movq 0x98(%rbx), %rdi
callq 0x3dae
movq %rbx, %rdi
callq 0x3c3c
movq %rbx, %rdi
callq 0x8164
movq %rbx, %rdi
callq 0x8245
movq %rbx, %rdi
xorl %esi, %esi
callq 0x85e7
movq 0x50(%rbx), %rdi
callq 0x21f0
movq 0x50(%rbx), %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x975e
movl $0xa0, %esi
movq %rbx, %rdi
callq 0x21a0
leaq 0x307a(%rip), %rdi      # 0xb079
callq 0x22a0
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x5fb8(%rip), %rbx      # 0xdfd0
leaq 0x2c49(%rip), %rsi      # 0xac68
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
jmp 0x8004
movq %rax, %r15
movl $0xa0, %esi
movq %rbx, %rdi
jmp 0x8072
movq %rax, %r15
movl $0x350, %esi            # imm = 0x350
movq %r14, %rdi
callq 0x21a0
movq %r15, %rdi
callq 0x22e0