// File: narges64[P]SIMBA/ssd.cpp
// Function: print_epoch_statistics(ssd_info*, int)
void print_epoch_statistics(ssd_info * ssd, int app_id){
	int epoch_num = ssd->current_time / EPOCH_LENGTH;
	fprintf(ssd->statisticfile, "epoch %d , current_time %lld \n", epoch_num, ssd->current_time);
	// =================== LATENCY ================================================================
	ssd->stats->total_flash_erase_count += ssd->stats->flash_erase_count;

	fprintf(ssd->statisticfile, "Latency epoch: %d \n", epoch_num);
	fprintf(ssd->statisticfile, "read RT avg %lld us , var %lld ms2, count %lld , max %lld us\n", ssd->stats->read_RT.get_average() , ssd->stats->read_RT.get_variance(), ssd->stats->read_RT.get_count(), ssd->stats->read_RT.get_max());
	fprintf(ssd->statisticfile, "write RT avg %lld us , var %lld ms2, count %lld , max %lld us \n", ssd->stats->write_RT.get_average(),ssd->stats->write_RT.get_variance(), ssd->stats->write_RT.get_count(), ssd->stats->write_RT.get_max());
	fprintf(ssd->statisticfile, "erase(gc) count %lld , total %lld\n", ssd->stats->flash_erase_count, ssd->stats->total_flash_erase_count);
	fprintf(ssd->statisticfile, "GC move count %d \n" , ssd->stats->gc_moved_page);
	ssd->stats->flash_erase_count = 0;

	// =================== SUBREQ STATES ===========================================================
	fprintf(ssd->statisticfile, "SUBREQ ep: %d time:\t", epoch_num);
	for (int i = 0; i < SR_MODE_NUM; i++){
		fprintf(ssd->statisticfile, "%lld\t",ssd->stats->subreq_state_time[i]);
		ssd->stats->subreq_state_time[i] = 0;
	}
	fprintf(ssd->statisticfile, "\n");

	// =================== LUN STATES ============================================================
	for (int i = 0; i < ssd->parameter->lun_num; i++){
		int channel_num = i % ssd->parameter->channel_number;
		int lun_num = (i / ssd->parameter->channel_number) % ssd->channel_head[channel_num]->lun_num;
		lun_info * the_lun = ssd->channel_head[channel_num]->lun_head[lun_num];
		fprintf(ssd->statisticfile, "lun ep: %d (%d,%d): ",epoch_num , channel_num, lun_num);
		for (int i = 0; i < LUN_MODE_NUM; i++){
			fprintf(ssd->statisticfile, "%lld\t", the_lun->state_time[i]);
			the_lun->state_time[i] = 0;
		}
		fprintf(ssd->statisticfile, "\n");
		for (int j = 0; j < ssd->parameter->plane_lun; j++){
			int plane_num = j;
			plane_info * the_plane = ssd->channel_head[channel_num]->lun_head[lun_num]->plane_head[plane_num];
			fprintf(ssd->statisticfile, "plane ep: %d (%d,%d,%d) ", epoch_num, channel_num, lun_num, plane_num);
			for (int i = 0; i < PLANE_MODE_NUM; i++){
				fprintf(ssd->statisticfile, "%lld\t",the_plane->state_time[i]);
				the_plane->state_time[i] = 0;
			}
			fprintf(ssd->statisticfile, "\n");
		}

	}
	// ==================== OTHER STATS ===================================
	fprintf(ssd->statisticfile, "Multiplane ep: %d read %lld , write %lld , erase %lld \n", epoch_num, ssd->stats->read_multiplane_count , ssd->stats->write_multiplane_count , ssd->stats->erase_multiplane_count);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movabsq $0x2540be400, %rcx      # imm = 0x2540BE400
cqto
idivq %rcx
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x10(%rbp), %edx
movq -0x8(%rbp), %rax
movq (%rax), %rcx
leaq 0x3bb8(%rip), %rsi      # 0xfd1c
movb $0x0, %al
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0x98(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
addq 0xa0(%rax), %rcx
movq %rcx, 0xa0(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x10(%rbp), %edx
leaq 0x3b93(%rip), %rsi      # 0xfd3b
movb $0x0, %al
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x8, %rdi
callq 0xe540
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x8, %rdi
callq 0xe580
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x8, %rdi
callq 0xe600
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x8, %rdi
callq 0xe610
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rdx
movq -0x70(%rbp), %rcx
movl -0x64(%rbp), %r8d
movq %rax, %r9
leaq 0x3b1f(%rip), %rsi      # 0xfd4f
movb $0x0, %al
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x30, %rdi
callq 0xe540
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x30, %rdi
callq 0xe580
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x30, %rdi
callq 0xe600
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
addq $0x30, %rdi
callq 0xe610
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl -0x48(%rbp), %r8d
movq %rax, %r9
leaq 0x3c0e(%rip), %rsi      # 0xfec6
movb $0x0, %al
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0x98(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0xa0(%rax), %rcx
leaq 0x3a9b(%rip), %rsi      # 0xfd8d
movb $0x0, %al
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movl 0xc8(%rax), %edx
leaq 0x3a97(%rip), %rsi      # 0xfdb0
movb $0x0, %al
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq $0x0, 0x98(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x10(%rbp), %edx
leaq 0x3a7b(%rip), %rsi      # 0xfdc3
movb $0x0, %al
callq 0x21f0
movl $0x0, -0x14(%rbp)
cmpl $0xa, -0x14(%rbp)
jge 0xc3b5
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0x188(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x3a53(%rip), %rsi      # 0xfdd8
movb $0x0, %al
callq 0x21f0
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0x188(%rax), %rax
movslq -0x14(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xc356
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
leaq 0x3b62(%rip), %rsi      # 0xff26
movb $0x0, %al
callq 0x21f0
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
cmpl 0x88(%rcx), %eax
jae 0xc5d9
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
xorl %edx, %edx
divl 0x98(%rcx)
movl %edx, -0x1c(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
xorl %edx, %edx
divl 0x98(%rcx)
movq -0x8(%rbp), %rcx
movq 0x90(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
xorl %edx, %edx
divl (%rcx)
movl %edx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x10(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
leaq 0x3976(%rip), %rsi      # 0xfdde
movb $0x0, %al
callq 0x21f0
movl $0x0, -0x2c(%rbp)
cmpl $0x3, -0x2c(%rbp)
jge 0xc4c7
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x393a(%rip), %rsi      # 0xfdd8
movb $0x0, %al
callq 0x21f0
movq -0x28(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xc476
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
leaq 0x3a50(%rip), %rsi      # 0xff26
movb $0x0, %al
callq 0x21f0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x58(%rcx), %rcx
cmpl 0x22c(%rcx), %eax
jae 0xc5c9
movl -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x10(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x34(%rbp), %r9d
leaq 0x38a7(%rip), %rsi      # 0xfdf3
movb $0x0, %al
callq 0x21f0
movl $0x0, -0x44(%rbp)
cmpl $0x3, -0x44(%rbp)
jge 0xc5a5
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x3859(%rip), %rsi      # 0xfdd8
movb $0x0, %al
callq 0x21f0
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x44(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xc55a
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
leaq 0x3972(%rip), %rsi      # 0xff26
movb $0x0, %al
callq 0x21f0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc4e4
jmp 0xc5cb
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xc3d2
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x10(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0xe0(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0xe8(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq 0xf0(%rax), %r9
leaq 0x37eb(%rip), %rsi      # 0xfe0c
movb $0x0, %al
callq 0x21f0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)