LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: get_new_ppn(ssd_info*, int, local const*, bool)
int get_new_ppn(ssd_info *ssd, int lpn, const local * location, bool hot){ // hot specify if we need a page in hot or cold active block 
	local * new_location;
	if (location != NULL) {
		new_location = new local(location->channel, location->lun, location->plane);
	}else {
		new_location = new local(0,0,0);
		allocate_plane(ssd, new_location);
	}
	if (allocate_page_in_plane(ssd, new_location, hot) != SUCCESS){
		delete new_location;
		return -1;
	}
	int ppn = find_ppn(ssd, new_location);
	delete new_location;
	return ppn;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r15
movq %rdi, %r14
pushq $0x18
popq %rdi
callq 0x2160
movq %rax, %rbx
testq %r15, %r15
je 0x44f4
movl 0x8(%r15), %eax
movq (%r15), %rcx
movq %rcx, (%rbx)
movl %eax, 0x8(%rbx)
jmp 0x4507
andq $0x0, (%rbx)
andl $0x0, 0x8(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5987
movzbl %bpl, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x59eb
testl %eax, %eax
je 0x4529
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5a68
movl %eax, %ebp
jmp 0x452c
pushq $-0x1
popq %rbp
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x2170
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: check_need_gc(ssd_info*, int)
bool check_need_gc(ssd_info * ssd, int ppn){
	local * location = new local(0,0,0);
	find_location(ssd, ppn, location);

	int free_page = ssd->channel_head[location->channel]->
				lun_head[location->lun]->plane_head[location->plane]->free_page;
	int all_page = ssd->parameter->page_block*ssd->parameter->block_plane;

	if (free_page > (all_page * ssd->parameter->gc_down_threshold)){
		delete location;
		return false;
	}
	delete location;
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %r14
pushq $0x18
popq %rbx
movq %rbx, %rdi
callq 0x2160
movq %rax, %r15
andq $0x0, (%rax)
andl $0x0, 0x8(%rax)
movq %r14, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x45f8
movq 0x58(%r14), %rax
movq 0x90(%r14), %rcx
movslq (%r15), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x50(%rcx), %rcx
movslq 0x4(%r15), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
movslq 0x8(%r15), %rdx
movl 0x230(%rax), %esi
imull 0x234(%rax), %esi
movq (%rcx,%rdx,8), %rcx
cvtsi2ssl (%rcx), %xmm0
cvtsi2ss %esi, %xmm1
mulss 0x28c(%rax), %xmm1
ucomiss %xmm1, %xmm0
setbe %bpl
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2170
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: find_location(ssd_info*, int, local*)
void find_location(ssd_info * ssd, int ppn, local * location){
	int pn,ppn_value=ppn;
	int page_plane=0,page_lun=0,page_channel=0;

	pn = ppn;

	page_plane=ssd->parameter->page_block*ssd->parameter->block_plane;
	page_lun=page_plane*ssd->parameter->plane_lun;

	int page = ppn % (page_lun * ssd->parameter->lun_num);
	int channel = 0;
	while (true){
		page_channel = page_lun * ssd->parameter->lun_channel[location->channel];
		page = page - page_channel;
		if (page < 0){
			page = page + page_channel;
			break;
		}else {
			channel++;
		}
	}
	int lun = page/page_lun;
	int plane = (page%page_lun)/page_plane;
	int block = ((page%page_lun)%page_plane)/ssd->parameter->page_block;
	int page_ = (((page%page_lun)%page_plane)%ssd->parameter->page_block)%ssd->parameter->page_block;

	if (location == NULL) {
		location = new local(channel, lun, plane, block, page_);
	}else {
		location->channel = channel;
		location->lun     = lun;
		location->plane   = plane;
		location->block   = block;
		location->page    = page_;
	}
}

// Assembly:
movq %rdx, %rcx
movl %esi, %eax
movq 0x58(%rdi), %r9
movl 0x234(%r9), %r8d
movl 0x230(%r9), %edi
imull %r8d, %edi
movl 0x22c(%r9), %esi
imull %edi, %esi
movl 0x88(%r9), %r10d
imull %esi, %r10d
xorl %edx, %edx
divl %r10d
movslq (%rcx), %rax
movl 0x9c(%r9,%rax,4), %r10d
imull %esi, %r10d
pushq $-0x1
popq %r9
movl %edx, %eax
incl %r9d
subl %r10d, %edx
jns 0x4640
cltd
idivl %esi
movl %eax, %esi
movl %edx, %eax
cltd
idivl %edi
movl %eax, %edi
movl %edx, %eax
xorl %edx, %edx
divl %r8d
movl %r9d, (%rcx)
movl %esi, 0x4(%rcx)
movl %edi, 0x8(%rcx)
movl %eax, 0xc(%rcx)
movl %edx, 0x10(%rcx)
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: distribute(ssd_info*)
ssd_info * distribute(ssd_info *ssd){

	if (ssd->dram != NULL)
		ssd->dram->current_time=ssd->current_time;

	request * req = ssd->request_tail; // The request we want to distribute
	if (req->size == 0) {
		cout << "size zero " << endl; 
		return ssd; 
	}
	unsigned lsn  = req->lsn;
	unsigned last_lpn  = (req->lsn+req->size-1)/ssd->parameter->subpage_page;
	unsigned first_lpn = req->lsn/ssd->parameter->subpage_page;
	unsigned lpn  = first_lpn;

	if (req->operation == READ)
	{
		while(lpn<=last_lpn)
		{
			sub_request * sub     = create_sub_request(ssd,lpn, req,req->operation, req->io_num);
			if (service_in_buffer(ssd, sub) != SUCCESS)
				printf("Error in servicing a request in buffer \n");

			lpn++;
		}
	}
	else if(req->operation==WRITE)
	{
		while (lpn<=last_lpn)
		{
			sub_request * sub=create_sub_request(ssd,lpn, req,req->operation, req->io_num);
			if (service_in_buffer(ssd, sub) != SUCCESS)
				printf("Error in servicing write requset in buffer! \n");
			lpn++;
		}
	} else {
		// FIXME for TRIM
	}
	return ssd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x60(%rdi), %rax
testq %rax, %rax
je 0x4687
movq (%rbx), %rcx
movq %rcx, 0x8(%rax)
movq 0x70(%rbx), %r14
movl 0x14(%r14), %eax
testl %eax, %eax
je 0x471b
movl 0x10(%r14), %ecx
movl 0x18(%r14), %esi
addl %ecx, %eax
decl %eax
movq 0x58(%rbx), %rdx
movl 0x238(%rdx), %edi
xorl %edx, %edx
divl %edi
movl %eax, %ebp
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %eax, %r15d
cmpl $0x1, %esi
je 0x4714
testl %esi, %esi
jne 0x4736
cmpl %ebp, %r15d
ja 0x4736
movl 0x4(%r14), %r8d
movl 0x18(%r14), %ecx
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x4744
movq %rbx, %rdi
movq %rax, %rsi
callq 0x486a
incl %r15d
jmp 0x46c5
movl 0x4(%r14), %r8d
movl 0x18(%r14), %ecx
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x4744
movq %rbx, %rdi
movq %rax, %rsi
callq 0x486a
incl %r15d
cmpl %ebp, %r15d
jbe 0x46f0
jmp 0x4736
movq 0x98ae(%rip), %rdi      # 0xdfd0
leaq 0x4e87(%rip), %rsi      # 0x95b0
callq 0x2140
movq %rax, %rdi
callq 0x20b0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: create_sub_request(ssd_info*, int, request*, unsigned int, int)
sub_request * create_sub_request( ssd_info * ssd, int lpn,
				 request * req,unsigned int operation, int io_num = -1){

	sub_request * sub = new sub_request(ssd->current_time, lpn,
				ssd->subrequest_sequence_number++, operation);

	if(req!=NULL)
	{
		sub->next_subs = req->subs;
		req->subs = sub;

		sub->app_id = req->app_id;
		sub->io_num = req->io_num;

		sub->state_time[SR_MODE_WAIT] = ssd->current_time - req->time;
		sub->state_current_time = ssd->current_time;
	}
	else
	{
		sub->io_num = io_num;
		sub->state_time[SR_MODE_WAIT] = 0;
		sub->state_current_time = ssd->current_time;
	}

	if (operation == READ)
	{
		sub->ppn = ssd->dram->map->map_entry[lpn].pn;
		if (sub->ppn >= 0) {
			find_location(ssd,sub->ppn, sub->location);
			if (ssd->dram->map->map_entry[lpn].state)
				sub->state = 1;
			else
				sub->state = 0;
		}else {
			sub->state = 0;
		}
	}
	else if(operation == WRITE)
	{
		sub->ppn = -1; // ssd->dram->map->map_entry[lpn].pn;
		sub->state=0;
	}
	else
	{
		delete sub;
		printf("\n FIXME TRIM command \n");
		return NULL;
	}

	return sub;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r12d
movl %ecx, %r15d
movq %rdx, %r13
movl %esi, %ebp
movq %rdi, %r14
movl $0xa0, %edi
callq 0x2160
movq %rax, %rbx
movq (%r14), %rsi
movl 0xc(%r14), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0xc(%r14)
movq %rbx, %rdi
movl %ebp, %edx
movl %r15d, %r8d
callq 0x5ee2
testq %r13, %r13
je 0x47a9
movq 0x30(%r13), %rax
movq %rax, 0x68(%rbx)
movq %rbx, 0x30(%r13)
movl (%r13), %eax
movl %eax, (%rbx)
movl 0x4(%r13), %r12d
movq (%r14), %rax
subq 0x8(%r13), %rax
jmp 0x47ab
xorl %eax, %eax
movq 0x80(%rbx), %rcx
movq %rax, (%rcx)
movq (%r14), %rax
movl %r12d, 0x4(%rbx)
movq %rax, 0x88(%rbx)
testl %r15d, %r15d
je 0x4813
cmpl $0x1, %r15d
jne 0x481d
movq 0x60(%r14), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movslq %ebp, %r15
shlq $0x4, %r15
movl (%rax,%r15), %esi
movl %esi, 0x10(%rbx)
testl %esi, %esi
js 0x4817
movq 0x60(%rbx), %rdx
movq %r14, %rdi
callq 0x45f8
movq 0x60(%r14), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
cmpb $0x1, 0x4(%rax,%r15)
jne 0x4817
movl $0x1, 0x40(%rbx)
jmp 0x4840
orl $-0x1, 0x10(%rbx)
andl $0x0, 0x40(%rbx)
jmp 0x4840
movq %rbx, %rdi
callq 0x5d62
movl $0xa0, %esi
movq %rbx, %rdi
callq 0x2170
leaq 0x50bd(%rip), %rdi      # 0x98f6
callq 0x2270
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0xa0, %esi
movq %rbx, %rdi
callq 0x2170
movq %r14, %rdi
callq 0x22b0
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: service_in_flash(ssd_info*, sub_request*)
void service_in_flash(ssd_info * ssd, sub_request * sub){
	if (sub->operation == READ) {
		if (ssd->channel_head[sub->location->channel]->
			lun_head[sub->location->lun]->
			rsubs_queue.find_subreq(sub)){
			// the request already exists
			sub->complete_time=ssd->current_time+1000;
			change_subrequest_state(ssd, sub,SR_MODE_ST_S,
					ssd->current_time,SR_MODE_COMPLETE,
					sub->complete_time);
			sub->state_current_time = sub->next_state_predict_time;
			ssd->stats->queue_read_count++;
		} else {
			ssd->channel_head[sub->location->channel]->
					lun_head[sub->location->lun]->
					rsubs_queue.push_tail(sub);
		}
	} else if (sub->operation == WRITE){
		if(invalid_old_page(ssd, sub) == FAIL) {
			#if DEBUG 
			cout << "error in invaliding the old page " << endl;
			#endif 
		}
		sub->ppn = get_new_ppn(ssd, sub->lpn, sub->location, true);

		if(sub->ppn == -1 || write_page(ssd, sub->lpn, sub->ppn) == FAIL) {
			cout << "there is problem "<< sub->ppn << endl;
			return;
		}
		find_location(ssd, sub->ppn, sub->location);
		ssd->channel_head[sub->location->channel]->lun_head[sub->location->lun]->
			wsubs_queue.push_tail(sub);

		Schedule_GC(ssd, sub);
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x20(%rsi), %eax
testl %eax, %eax
je 0x4a54
cmpl $0x1, %eax
jne 0x4a4c
movq 0x90(%r14), %rax
movq 0x60(%rbx), %rcx
movslq (%rcx), %rdx
movq (%rax,%rdx,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x60, %rdi
movq %rbx, %rsi
callq 0x40c6
testb %al, %al
je 0x4aff
movq (%r14), %rcx
leaq 0x3e8(%rcx), %r9
movq %r9, 0x58(%rbx)
pushq $0x1
popq %rdx
pushq $0x9
popq %r8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x637a
movq 0x38(%rbx), %rax
movq %rax, 0x88(%rbx)
movq 0x98(%r14), %rax
incq 0xb0(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4b30
movq 0x60(%rbx), %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
callq 0x44c6
movl %eax, 0x10(%rbx)
cmpl $-0x1, %eax
je 0x4ad2
movl 0xc(%rbx), %esi
movq %r14, %rdi
movl %eax, %edx
callq 0x4544
testl %eax, %eax
je 0x4ad2
movl 0x10(%rbx), %esi
movq 0x60(%rbx), %rdx
movq %r14, %rdi
callq 0x45f8
movq 0x90(%r14), %rax
movq 0x60(%rbx), %rcx
movslq (%rcx), %rdx
movq (%rax,%rdx,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x78, %rdi
movq %rbx, %rsi
callq 0x4120
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6eb1
movq 0x94f7(%rip), %rdi      # 0xdfd0
leaq 0x4adb(%rip), %rsi      # 0x95bb
callq 0x2140
movl 0x10(%rbx), %esi
movq %rax, %rdi
callq 0x22a0
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20b0
movq 0x90(%r14), %rax
movq 0x60(%rbx), %rcx
movslq (%rcx), %rdx
movq (%rax,%rdx,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x60, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4120
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: invalid_old_page(ssd_info*, sub_request*)
STATE invalid_old_page(ssd_info * ssd, sub_request * sub){ // const int lpn){
	int lpn = sub->lpn;
	if (ssd->dram->map->map_entry[lpn].state == false){
		#if DUBG 
		cout << "error 1 " << sub->lpn  << endl; 	
		#endif 
		 return FAIL;
	}
	int old_ppn = ssd->dram->map->map_entry[lpn].pn;
	find_location(ssd, old_ppn, sub->location);
	if( update_map_entry(ssd, lpn, -1) == FAIL) {
		cout << "error 2" << endl; 
		return FAIL;
	}
	if (update_physical_page(ssd, old_ppn, -1)  == FAIL) {
		cout << "error 3 " << endl; 
		return FAIL;
	} 
	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movslq 0xc(%rsi), %r15
movq 0x60(%rdi), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %r15, %rcx
shlq $0x4, %rcx
xorl %ebx, %ebx
cmpb $0x0, 0x4(%rax,%rcx)
je 0x4bad
movq %rdi, %r14
addq %rcx, %rax
movl (%rax), %ebp
movq 0x60(%rsi), %rdx
movl %ebp, %esi
callq 0x45f8
pushq $-0x1
popq %r12
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x57f5
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x582f
testl %eax, %eax
je 0x4b92
pushq $0x1
popq %rbx
jmp 0x4bad
movq 0x9437(%rip), %rdi      # 0xdfd0
leaq 0x4b2b(%rip), %rsi      # 0x96cb
callq 0x2140
movq %rax, %rdi
callq 0x20b0
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: process(ssd_info*)
ssd_info *process( ssd_info *ssd)   {
	// use some random to stop always prioritizing a single channel (channel 0)
	int random = rand();
	for(int chan=0;chan<ssd->parameter->channel_number;chan++)
	{
		int c = ( chan + random ) % ssd->parameter->channel_number;
		unsigned int flag=0;
		if(find_channel_state(ssd, c) == CHANNEL_MODE_IDLE)
		{
			services_2_io(ssd, c, &flag);
			if(flag == 0)
				services_2_gc(ssd, c, &flag);
		}
	}
	return ssd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
xorl %r12d, %r12d
callq 0x2090
movl %eax, %r14d
leaq 0xc(%rsp), %r15
movq 0x58(%rbx), %rax
movl 0x98(%rax), %ecx
cmpl %ecx, %r12d
jae 0x4c29
leal (%r14,%r12), %eax
xorl %edx, %edx
divl %ecx
movl %edx, %ebp
andl $0x0, 0xc(%rsp)
movq %rbx, %rdi
movl %edx, %esi
callq 0x6216
testl %eax, %eax
jne 0x4c24
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x4c39
cmpl $0x0, 0xc(%rsp)
jne 0x4c24
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x4f14
incl %r12d
jmp 0x4bd7
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: update_map_entry(ssd_info*, int, int)
STATE update_map_entry(ssd_info * ssd, int lpn, int ppn){
	bool full_page= true;
	if (ppn == -1) {
		ssd->dram->map->map_entry[lpn].pn = -1;
		ssd->dram->map->map_entry[lpn].state = false;
		ssd->dram->map->map_entry[lpn].buf_ent = NULL;
	} else {
		ssd->dram->map->map_entry[lpn].pn=ppn;
		ssd->dram->map->map_entry[lpn].state = true;
	}

	return SUCCESS;
}

// Assembly:
movq 0x60(%rdi), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movslq %esi, %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
leaq (%rax,%rcx), %rdi
addq $0x4, %rdi
cmpl $-0x1, %edx
je 0x581f
movl %edx, (%rsi)
movb $0x1, (%rdi)
jmp 0x582b
orl $-0x1, (%rsi)
movb $0x0, (%rdi)
andq $0x0, 0x8(%rax,%rcx)
pushq $0x1
popq %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: update_physical_page(ssd_info*, int, int)
STATE update_physical_page(ssd_info * ssd, const int ppn, const int lpn){
	local * location = new local(0,0,0);
	find_location(ssd, ppn, location);

	int c = location->channel;
	int l = location->lun;
	int p = location->plane;
	int b = location->block;
	int pg = location->page;

	blk_info * block = ssd->channel_head[c]->lun_head[l]->plane_head[p]->blk_head[b];

	if (lpn != -1) {
		if (block->last_write_page > pg) {
			cout << "update physical page, writing backward " << block->last_write_page  << "  "  << pg<< endl;
			return FAIL;
		}
		ssd->channel_head[c]->lun_head[l]->plane_head[p]->blk_head[b]->page_head[pg]->lpn=lpn;
		ssd->channel_head[c]->lun_head[l]->plane_head[p]->blk_head[b]->page_head[pg]->valid_state=true;

		ssd->channel_head[c]->lun_head[l]->plane_head[p]->free_page--;
		ssd->stats->flash_prog_count++;
		ssd->channel_head[c]->program_count++;
		ssd->channel_head[c]->lun_head[l]->program_count++;
		ssd->channel_head[c]->lun_head[l]->plane_head[p]->program_count++;
	}else {

		if (block->page_head[pg]->lpn == -1 || block->page_head[pg]->valid_state == false) {
			cout << "invalidating has problem, the page is already invalid or free " << endl;
			return FAIL;
		}

		block->page_head[pg]->lpn=-1;
		if (block->page_head[pg]->valid_state){
			block->invalid_page_num++;
		}
		block->page_head[pg]->valid_state=false;
		ssd->channel_head[c]->lun_head[l]->plane_head[p]->invalid_page++;

	}
	delete location;
	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
pushq $0x18
popq %rdi
callq 0x2160
movq %rax, %rbx
andq $0x0, (%rax)
andl $0x0, 0x8(%rax)
movq %r15, %rdi
movl %r14d, %esi
movq %rax, %rdx
callq 0x45f8
movslq (%rbx), %rax
movslq 0x4(%rbx), %rdx
movslq 0x8(%rbx), %rsi
movslq 0xc(%rbx), %rdi
movslq 0x10(%rbx), %r14
movq 0x90(%r15), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x50(%rcx), %rax
movq (%rax,%rdx,8), %rdx
movq (%rdx), %rax
movq (%rax,%rsi,8), %rax
movq 0x20(%rax), %rsi
movq (%rsi,%rdi,8), %r12
cmpl $-0x1, %ebp
je 0x58dd
cmpl %r14d, 0x10(%r12)
jle 0x5901
movq 0x8728(%rip), %rdi      # 0xdfd0
leaq 0x3d95(%rip), %rsi      # 0x9644
callq 0x2140
movl 0x10(%r12), %esi
movq %rax, %rdi
callq 0x22a0
leaq 0x3b7b(%rip), %rsi      # 0x9443
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
movl %r14d, %esi
callq 0x22a0
jmp 0x5952
movq 0x20(%r12), %rcx
movq (%rcx,%r14,8), %rcx
cmpl $-0x1, 0x4(%rcx)
je 0x593f
cmpb $0x0, (%rcx)
je 0x593f
orl $-0x1, 0x4(%rcx)
incl 0x8(%r12)
movb $0x0, (%rcx)
pushq $0x8
jmp 0x592a
movq 0x20(%r12), %rsi
movq (%rsi,%r14,8), %rsi
movl %ebp, 0x4(%rsi)
movb $0x1, (%rsi)
decq (%rax)
movq 0x98(%r15), %rsi
incq 0x88(%rsi)
incq 0x10(%rcx)
incl 0xc(%rdx)
pushq $0x40
popq %rcx
incq (%rax,%rcx)
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x2170
pushq $0x1
popq %rax
jmp 0x595c
movq 0x868a(%rip), %rdi      # 0xdfd0
leaq 0x3d1f(%rip), %rsi      # 0x966c
callq 0x2140
movq %rax, %rdi
callq 0x20b0
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: set_entry_state(ssd_info*, int, unsigned int)
uint64_t set_entry_state(ssd_info *ssd, int lsn,unsigned int size){
	uint64_t temp,state,move;

	temp=~(0xffffffffffffffff<<size);
	move=lsn%ssd->parameter->subpage_page;
	state=temp<<move;

	return state;
}

// Assembly:
movl %edx, %ecx
movl %esi, %eax
pushq $-0x1
popq %rsi
shlq %cl, %rsi
notq %rsi
movq 0x58(%rdi), %rcx
xorl %edx, %edx
divl 0x238(%rcx)
movl %edx, %ecx
shlq %cl, %rsi
movq %rsi, %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: allocate_plane(ssd_info*, local*)
STATE allocate_plane( ssd_info * ssd , local * location){
	sub_request * update=NULL;
	unsigned int channel_num=0,lun_num=0,plane_num=0;
	if (location == NULL) location = new local(0,0,0);
	channel_num = ssd->parameter->channel_number;
	lun_num=ssd->parameter->lun_channel[0];
	plane_num=ssd->parameter->plane_lun;

	unsigned int target_lun = get_target_lun(ssd);
	location->channel=target_lun % channel_num;
	location->lun= (target_lun / channel_num) % ssd->parameter->lun_channel[location->channel];
	location->plane= get_target_plane(ssd, location->channel, location->lun);
	return SUCCESS;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
jne 0x59a1
pushq $0x18
popq %rdi
callq 0x2160
movq %rax, %rbx
movq 0x58(%r14), %rdi
movl 0x14(%r14), %ecx
leal 0x1(%rcx), %eax
xorl %edx, %edx
divl 0x88(%rdi)
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl 0x98(%rdi)
movl %esi, 0x14(%r14)
movl %edx, (%rbx)
movslq %edx, %rsi
xorl %edx, %edx
divl 0x9c(%rdi,%rsi,4)
movl %edx, 0x4(%rbx)
movq %r14, %rdi
callq 0x5b13
movl %eax, 0x8(%rbx)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: allocate_page_in_plane(ssd_info*, local*, bool)
STATE allocate_page_in_plane( ssd_info *ssd, local * location, bool hot){
	int channel = location->channel;
	int lun = location->lun;
	int plane = location->plane;
	int active_block= -1; 
	if (hot) 
		active_block = get_active_block(ssd, location);
	else 
		active_block = get_cold_active_block(ssd, location); 

	if (active_block == -1) return FAIL;
	int active_page = ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->
					blk_head[active_block]->last_write_page + 1;

	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[active_block]->last_write_page++;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[active_block]->
					last_write_time = ssd->current_time;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[active_block]->free_page_num--;

	location->block = active_block;
	location->page = active_page;


	return SUCCESS;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movslq (%rsi), %r13
movslq 0x4(%rsi), %r12
movslq 0x8(%rsi), %r15
testl %edx, %edx
je 0x5a10
callq 0x5b4b
jmp 0x5a15
callq 0x5bf9
cmpl $-0x1, %eax
je 0x5a5c
movq 0x90(%r14), %rcx
movq (%rcx,%r13,8), %rcx
movq 0x50(%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movq (%rcx), %rcx
movq (%rcx,%r15,8), %rcx
movq 0x20(%rcx), %rcx
movslq %eax, %rdx
movq (%rcx,%rdx,8), %rcx
movl 0x10(%rcx), %edx
incl %edx
movl %edx, 0x10(%rcx)
movq (%r14), %rsi
movq %rsi, 0x18(%rcx)
decl 0x4(%rcx)
movl %eax, 0xc(%rbx)
movl %edx, 0x10(%rbx)
pushq $0x1
popq %rax
jmp 0x5a5e
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: find_ppn(ssd_info*, local const*)
int find_ppn(ssd_info * ssd,const local * location){
	unsigned int channel = location->channel;
	unsigned int lun = location->lun;
	unsigned int plane = location->plane;
	unsigned int block = location->block;
	unsigned int page = location->page;

	int ppn=0;

	int page_plane=0,page_lun=0;
	int page_channel[100];

	page_plane=ssd->parameter->page_block*ssd->parameter->block_plane;
	page_lun=page_plane*ssd->parameter->plane_lun;

	unsigned int i=0;
	while(i<ssd->parameter->channel_number)
	{
		page_channel[i]=ssd->parameter->lun_channel[i]*page_lun;
		i++;
	}


	i=0;
	while(i<channel)
	{
		ppn=ppn+page_channel[i];
		i++;
	}
	ppn=ppn+page_lun*lun+page_plane*plane+block*ssd->parameter->page_block+page;

	return ppn;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movl (%rsi), %r10d
movl 0x4(%rsi), %r8d
movl 0x8(%rsi), %r9d
movl 0xc(%rsi), %edx
movl 0x10(%rsi), %ecx
movq 0x58(%rdi), %r11
movl 0x98(%r11), %ebx
movl 0x234(%r11), %eax
movl 0x230(%r11), %esi
imull %eax, %esi
movl 0x22c(%r11), %edi
imull %esi, %edi
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x5ac7
movl 0x9c(%r11,%r14,4), %ebp
imull %edi, %ebp
movl %ebp, -0x80(%rsp,%r14,4)
incq %r14
jmp 0x5aad
xorl %ebx, %ebx
xorl %r11d, %r11d
cmpq %rbx, %r10
je 0x5adb
addl -0x80(%rsp,%rbx,4), %r11d
incq %rbx
jmp 0x5acc
imull %r8d, %edi
imull %r9d, %esi
addl %edi, %esi
imull %edx, %eax
addl %ecx, %eax
addl %esi, %eax
addl %r11d, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: get_active_block(ssd_info*, local*)
int get_active_block(ssd_info *ssd, local * location){
	int channel = location->channel;
	int lun = location->lun;
	int plane = location->plane;

	int active_block = ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->active_block;
	int free_page_num = ssd->channel_head[channel]->lun_head[lun]->
					plane_head[plane]->blk_head[active_block]->free_page_num;
	int cold_active_block = ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->cold_active_block; 
	int count=0;
	while(((free_page_num==0))&&(count<ssd->parameter->block_plane))
	{
		active_block=(active_block+1)%ssd->parameter->block_plane;
		if (active_block == cold_active_block) 
			active_block=(active_block+1)%ssd->parameter->block_plane;
		free_page_num=ssd->channel_head[channel]->lun_head[lun]->
					plane_head[plane]->blk_head[active_block]->free_page_num;
		count++;
	}
	if (count == ssd->parameter->block_plane) {
		cout << "could not find active_block " << endl;
		return -1;
	}
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->active_block=active_block;

	return active_block;
}

// Assembly:
pushq %rax
movslq (%rsi), %rax
movslq 0x4(%rsi), %rcx
movslq 0x8(%rsi), %rdx
movq 0x58(%rdi), %rsi
movq 0x90(%rdi), %rdi
movq (%rdi,%rax,8), %rax
movq 0x50(%rax), %rax
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq (%rax,%rdx,8), %rcx
movq 0x10(%rcx), %rax
movq 0x20(%rcx), %r8
movslq %eax, %rdx
leaq (%r8,%rdx,8), %rdx
movl 0x18(%rcx), %r9d
xorl %r10d, %r10d
xorl %edi, %edi
movq (%rdx), %rdx
cmpl $0x0, 0x4(%rdx)
jne 0x5bc4
movl 0x230(%rsi), %r11d
cmpl %r11d, %edi
jae 0x5bcb
incl %eax
xorl %edx, %edx
divl %r11d
leal 0x1(%rdx), %eax
cmpl %r11d, %eax
cmovel %r10d, %eax
cmpl %r9d, %edx
cmovnel %edx, %eax
movslq %eax, %rdx
leaq (%r8,%rdx,8), %rdx
incl %edi
jmp 0x5b8d
movl 0x230(%rsi), %r11d
cmpl %edi, %r11d
jne 0x5bf0
movq 0x83f9(%rip), %rdi      # 0xdfd0
leaq 0x3af6(%rip), %rsi      # 0x96d4
callq 0x2140
movq %rax, %rdi
callq 0x20b0
pushq $-0x1
popq %rax
jmp 0x5bf7
movslq %eax, %rdx
movq %rdx, 0x10(%rcx)
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/ftl.cpp
// Function: get_cold_active_block(ssd_info*, local*)
int get_cold_active_block(ssd_info *ssd, local * location){
	int channel = location->channel;
	int lun = location->lun;
	int plane = location->plane;

	int cold_active_block = ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->cold_active_block;
	int free_page_num = ssd->channel_head[channel]->lun_head[lun]->
					plane_head[plane]->blk_head[cold_active_block]->free_page_num;
	int active_block = ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->active_block; 
	int count=0;
	while(((free_page_num==0))&&(count<ssd->parameter->block_plane))
	{
		cold_active_block=(cold_active_block+1)%ssd->parameter->block_plane;
		if (cold_active_block == active_block) 
			cold_active_block=(cold_active_block+1)%ssd->parameter->block_plane;
		free_page_num=ssd->channel_head[channel]->lun_head[lun]->
					plane_head[plane]->blk_head[cold_active_block]->free_page_num;
		count++;
	}
	if (count == ssd->parameter->block_plane) {
		cout << "could not find cold active_block " << endl;
		return -1;
	}
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->cold_active_block=cold_active_block;

	return cold_active_block;
}

// Assembly:
pushq %rax
movslq (%rsi), %rax
movslq 0x4(%rsi), %rcx
movslq 0x8(%rsi), %rdx
movq 0x58(%rdi), %rsi
movq 0x90(%rdi), %rdi
movq (%rdi,%rax,8), %rax
movq 0x50(%rax), %rax
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq (%rax,%rdx,8), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %r8
movslq %eax, %rdx
leaq (%r8,%rdx,8), %rdx
movl 0x10(%rcx), %r9d
xorl %r10d, %r10d
xorl %edi, %edi
movq (%rdx), %rdx
cmpl $0x0, 0x4(%rdx)
jne 0x5c72
movl 0x230(%rsi), %r11d
cmpl %r11d, %edi
jae 0x5c79
incl %eax
xorl %edx, %edx
divl %r11d
leal 0x1(%rdx), %eax
cmpl %r11d, %eax
cmovel %r10d, %eax
cmpl %r9d, %edx
cmovnel %edx, %eax
movslq %eax, %rdx
leaq (%r8,%rdx,8), %rdx
incl %edi
jmp 0x5c3b
movl 0x230(%rsi), %r11d
cmpl %edi, %r11d
jne 0x5c9e
movq 0x834b(%rip), %rdi      # 0xdfd0
leaq 0x3a65(%rip), %rsi      # 0x96f1
callq 0x2140
movq %rax, %rdi
callq 0x20b0
pushq $-0x1
popq %rax
jmp 0x5ca5
movslq %eax, %rdx
movq %rdx, 0x18(%rcx)
popq %rcx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: write_buffer::hit_read(buffer_entry*)
void hit_read(buffer_entry * entry){
		if (entry == NULL) {
			cout << "Error in hit read " << endl;
			return;
		}
		read_hit++;
		if (entry->outlier) 
			cout << "outlier shouldn't get a hit in read " << endl; 
	}

// Assembly:
testq %rsi, %rsi
je 0x5cbe
incl (%rdi)
cmpb $0x1, 0x8(%rsi)
jne 0x5cdb
leaq 0x3a6a(%rip), %rsi      # 0x9726
jmp 0x5cc5
leaq 0x3a4e(%rip), %rsi      # 0x9713
pushq %rax
movq 0x8303(%rip), %rdi      # 0xdfd0
callq 0x2140
movq %rax, %rdi
popq %rax
jmp 0x20b0
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: write_buffer::hit_write(buffer_entry*)
void hit_write(buffer_entry * entry){
		if (entry == NULL){
		//	cout << "Error in hit write " << endl;
			return;
		}
		write_hit++;
		entry->modified = true;
		if (entry->outlier) 
			cout << "outlier shouldn't get a hit in write " << endl; 
	}

// Assembly:
testq %rsi, %rsi
je 0x5d61
incl 0x4(%rdi)
movb $0x1, 0x1(%rsi)
cmpb $0x1, 0x8(%rsi)
jne 0x5d61
pushq %rax
movq 0x8284(%rip), %rdi      # 0xdfd0
leaq 0x3a31(%rip), %rsi      # 0x9784
callq 0x2140
movq %rax, %rdi
popq %rax
jmp 0x20b0
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: write_buffer::remove_entry(buffer_entry*)
buffer_entry * remove_entry (buffer_entry * entry){
		if (entry == NULL) return NULL;
		if (entry_count == 0) return NULL;
		if (entry == buffer_first_outlier) {
			buffer_first_outlier = entry->prev_entry; 
		} 
		if (entry == buffer_head) {
			return remove_head();
		}
		if (entry == buffer_tail){
			return remove_tail();
		}
		entry->prev_entry->next_entry = entry->next_entry;
		entry->next_entry->prev_entry = entry->prev_entry;
		entry->next_entry = NULL;
		entry->prev_entry = NULL;
		entry_count--;

		if (buffer_head == NULL && buffer_tail != NULL){
			cout << "**** Buffer head and tail problem 1 8" << endl;

		}
		if (buffer_head != NULL && buffer_tail == NULL){
			cout << "**** Buffer head and tail problem 2 8" << endl;
		}
	
		return entry;
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x5e74
movq %rdi, %r14
movl 0xc(%rdi), %ecx
testl %ecx, %ecx
je 0x5e74
movq %rsi, %rbx
cmpq %rsi, 0x20(%r14)
jne 0x5de0
movq 0x20(%rbx), %rax
movq %rax, 0x20(%r14)
movq 0x10(%r14), %rax
cmpq %rbx, %rax
je 0x5e81
cmpq %rbx, 0x18(%r14)
je 0x5e90
movq 0x18(%rbx), %rdx
movq 0x20(%rbx), %rsi
movq %rdx, 0x18(%rsi)
movq %rsi, 0x20(%rdx)
decl %ecx
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
movl %ecx, 0xc(%r14)
testq %rax, %rax
setne %dl
movq 0x18(%r14), %rcx
testq %rcx, %rcx
sete %sil
orb %dl, %sil
jne 0x5e4d
movq 0x819f(%rip), %rdi      # 0xdfd0
leaq 0x3972(%rip), %rsi      # 0x97aa
callq 0x2140
movq %rax, %rdi
callq 0x20b0
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
testq %rax, %rax
je 0x5e76
testq %rcx, %rcx
jne 0x5e76
movq 0x8172(%rip), %rdi      # 0xdfd0
leaq 0x396b(%rip), %rsi      # 0x97d0
callq 0x2140
movq %rax, %rdi
callq 0x20b0
jmp 0x5e76
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x602c
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x60f4
nop
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: write_buffer::move_outlier()
buffer_entry * move_outlier(){
		buffer_entry * temp = buffer_first_outlier;

		if (temp == NULL) return NULL; 
	
		if (temp->outlier == false) {
			cout << "error outlier is not outlier " << endl;
			return NULL;  
		}

		buffer_first_outlier = temp->prev_entry;  	
		temp->outlier = false; 
		
		return temp; 
	}

// Assembly:
movq 0x20(%rdi), %rax
testq %rax, %rax
je 0x5ebc
cmpb $0x0, 0x8(%rax)
je 0x5ebf
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%rdi)
movb $0x0, 0x8(%rax)
retq
xorl %eax, %eax
retq
pushq %rax
movq 0x8109(%rip), %rdi      # 0xdfd0
leaq 0x3a0a(%rip), %rsi      # 0x98d8
callq 0x2140
movq %rax, %rdi
callq 0x20b0
xorl %eax, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: sub_request::sub_request(long, int, int, int)
sub_request(int64_t ct, int lpnum, int sn, int op){
		app_id = -1;
		io_num = -1;
		seq_num = sn;
		lpn = lpnum;
		ppn = -1;
		buf_entry = NULL;
		operation = op;
		state = 0;
		begin_time = ct;
		wait_time = 0;
		complete_time = MAX_INT64;
		gc_node = NULL;
		trigger_gc = false; 
		next_node = NULL;
		next_subs = NULL;
		update = NULL;
		location = new local(0,0,0,0,0);
		state_time = new int64_t[SR_MODE_NUM];
		for (int i = 0; i < SR_MODE_NUM; i++) state_time[i] = 0;
		current_time = ct;
		current_state = SR_MODE_WAIT;
		state_current_time = ct;
		next_state = SR_MODE_WAIT;
		next_state_predict_time = ct;
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
orq $-0x1, (%rdi)
movl %ecx, 0x8(%rdi)
movl %edx, 0xc(%rdi)
orl $-0x1, 0x10(%rdi)
andq $0x0, 0x18(%rdi)
movl %r8d, 0x20(%rdi)
andl $0x0, 0x40(%rdi)
movq %rsi, 0x48(%rdi)
andq $0x0, 0x50(%rdi)
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
movq %rax, 0x58(%rdi)
andq $0x0, 0x90(%rdi)
movb $0x0, 0x98(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%rdi)
andq $0x0, 0x78(%rdi)
pushq $0x18
popq %rdi
callq 0x2160
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andl $0x0, 0x10(%rax)
movq %rax, 0x60(%r14)
pushq $0x50
popq %rdi
callq 0x2040
movq %rax, 0x80(%r14)
xorl %ecx, %ecx
cmpq $0xa, %rcx
je 0x5f70
andq $0x0, (%rax,%rcx,8)
incq %rcx
jmp 0x5f60
movq %rbx, 0x28(%r14)
andl $0x0, 0x24(%r14)
movq %rbx, 0x88(%r14)
andl $0x0, 0x30(%r14)
movq %rbx, 0x38(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: write_buffer::add_head(buffer_entry*)
bool add_head(buffer_entry * entry){
		if (entry == NULL) return false;
		if (entry_count >= buffer_capacity){
			entry->outlier = true;
			if (buffer_first_outlier == NULL) 
				buffer_first_outlier = entry; 
		}
		if (buffer_head == NULL) {
			if (buffer_tail != NULL || entry_count != 0){
				cout << "error in add head " << endl;
				return false;
			}
			entry_count = 1;
			buffer_head = entry;
			buffer_tail = entry;
			buffer_head->prev_entry = NULL; // just to make sure everything is fine
			buffer_tail->next_entry = NULL; // just to make sure everything is fine
		}else {
			buffer_head->prev_entry = entry;
			entry->next_entry = buffer_head;
			buffer_head = entry;
			buffer_head->prev_entry = NULL;
			entry_count++;
		}

		if (buffer_head == NULL && buffer_tail != NULL){
			cout << "**** Buffer head and tail problem 1 7" << endl;
			return false;
		}
		if (buffer_head != NULL && buffer_tail == NULL){
			cout << "**** Buffer head and tail problem 2 7" << endl;
			return false;
		}

		return true;
	}

// Assembly:
testq %rsi, %rsi
je 0x5fcf
movl 0xc(%rdi), %eax
cmpl 0x8(%rdi), %eax
jl 0x5fae
movb $0x1, 0x8(%rsi)
cmpq $0x0, 0x20(%rdi)
jne 0x5fae
movq %rsi, 0x20(%rdi)
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x5fd2
movq %rsi, 0x20(%rcx)
movq %rcx, 0x18(%rsi)
movq %rsi, 0x10(%rdi)
andq $0x0, 0x20(%rsi)
incl %eax
movl %eax, 0xc(%rdi)
jmp 0x5ffc
xorl %eax, %eax
retq
cmpq $0x0, 0x18(%rdi)
leaq 0x376d(%rip), %rax      # 0x974b
jne 0x600c
cmpl $0x0, 0xc(%rdi)
jne 0x600c
movl $0x1, 0xc(%rdi)
movq %rsi, 0x10(%rdi)
movq %rsi, 0x18(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsi)
movb $0x1, %al
cmpq $0x0, 0x18(%rdi)
jne 0x5fd1
leaq 0x3752(%rip), %rax      # 0x975e
pushq %rax
movq 0x7fbc(%rip), %rdi      # 0xdfd0
movq %rax, %rsi
callq 0x2140
movq %rax, %rdi
callq 0x20b0
xorl %eax, %eax
addq $0x8, %rsp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: write_buffer::remove_head()
buffer_entry * remove_head(){
		if (entry_count == 0) return NULL;
		if (buffer_head == NULL) {
				cout << "error in remove head" << endl;
				return NULL;
		}
		if (buffer_head->prev_entry != NULL) {
				cout << "error in remove head " << endl;
				return NULL;
		}

		buffer_entry * temp = buffer_head;
		buffer_head = temp->next_entry;
		if (buffer_head != NULL)
			buffer_head->prev_entry = NULL;
		else
			buffer_tail = NULL;
		temp->next_entry = NULL;
		temp->prev_entry = NULL;
		entry_count--;

		if (buffer_head == NULL && buffer_tail != NULL){
			cout << "**** Buffer head and tail problem 1 9" << endl;

		}
		if (buffer_head != NULL && buffer_tail == NULL){
			cout << "**** Buffer head and tail problem 2 9" << endl;

		}

		return temp;
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0xc(%rdi), %ecx
testl %ecx, %ecx
je 0x6053
movq %rdi, %r14
movq 0x10(%rdi), %rbx
testq %rbx, %rbx
je 0x6057
cmpq $0x0, 0x20(%rbx)
je 0x607f
leaq 0x37ba(%rip), %rsi      # 0x980b
jmp 0x605e
xorl %ebx, %ebx
jmp 0x6074
leaq 0x3798(%rip), %rsi      # 0x97f6
xorl %ebx, %ebx
movq 0x7f69(%rip), %rdi      # 0xdfd0
callq 0x2140
movq %rax, %rdi
callq 0x20b0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x18(%rbx), %rax
movq %rax, 0x10(%r14)
leaq 0x18(%r14), %rdx
leaq 0x20(%rax), %rsi
testq %rax, %rax
cmoveq %rdx, %rsi
setne %dl
andq $0x0, (%rsi)
decl %ecx
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
movl %ecx, 0xc(%r14)
movq 0x18(%r14), %rcx
testq %rcx, %rcx
sete %sil
orb %dl, %sil
jne 0x60dd
movq 0x7f0f(%rip), %rdi      # 0xdfd0
leaq 0x3759(%rip), %rsi      # 0x9821
callq 0x2140
movq %rax, %rdi
callq 0x20b0
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
testq %rax, %rax
je 0x6074
testq %rcx, %rcx
jne 0x6074
leaq 0x3759(%rip), %rsi      # 0x9847
jmp 0x6060
nop
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/./common.hh
// Function: write_buffer::remove_tail()
buffer_entry * remove_tail(){
		if (entry_count == 0) return NULL;
		if (buffer_tail == NULL) {
			cout << "error in buffer tail remove " << endl;
			return NULL;
		}
		if (buffer_tail->next_entry != NULL) {
			cout << "error in buffer tail remove " << endl;
			return NULL;
		}
		buffer_entry * temp = buffer_tail;
		buffer_tail = temp->prev_entry;
		if (buffer_tail != NULL)
			buffer_tail->next_entry = NULL;
		else
			buffer_head = NULL;
		temp->prev_entry = NULL;
		temp->next_entry = NULL;
		entry_count--;

		if (buffer_head == NULL && buffer_tail != NULL){
			cout << "**** Buffer head and tail problem 1 10" << endl;

		}
		if (buffer_head != NULL && buffer_tail == NULL){
			cout << "**** Buffer head and tail problem 2 10" << endl;

		}

		return temp;
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0xc(%rdi), %eax
testl %eax, %eax
je 0x6131
movq %rdi, %r14
movq 0x18(%rdi), %rbx
leaq 0x3760(%rip), %rsi      # 0x986d
testq %rbx, %rbx
je 0x6119
cmpq $0x0, 0x18(%rbx)
je 0x613e
xorl %ebx, %ebx
movq 0x7eae(%rip), %rdi      # 0xdfd0
callq 0x2140
movq %rax, %rdi
callq 0x20b0
jmp 0x6133
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdx
movq %rdx, 0x18(%r14)
testq %rdx, %rdx
je 0x615e
andq $0x0, 0x18(%rdx)
cmpq $0x0, 0x10(%r14)
setne %dl
jmp 0x6165
andq $0x0, 0x10(%r14)
xorl %edx, %edx
decl %eax
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movl %eax, 0xc(%r14)
movq 0x18(%r14), %rax
testq %rax, %rax
sete %cl
orb %dl, %cl
jne 0x619e
movq 0x7e4a(%rip), %rdi      # 0xdfd0
leaq 0x36fd(%rip), %rsi      # 0x988a
callq 0x2140
movq %rax, %rdi
callq 0x20b0
movq 0x18(%r14), %rax
cmpq $0x0, 0x10(%r14)
je 0x6133
testq %rax, %rax
jne 0x6133
leaq 0x3700(%rip), %rsi      # 0x98b1
jmp 0x611b
nop
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/garbage_collection.cpp
// Function: gc_for_plane(ssd_info*, gc_operation*)
void gc_for_plane(ssd_info * ssd, gc_operation * gc_node){
	unsigned int page_move_count = 0;
	local * location = gc_node->location;
	if (find_victim_block(ssd, location) != SUCCESS) {
		printf("Error: invalid block selected for gc \n");
		return;
	}
	int last_write = ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]->blk_head[location->block]->last_write_page; 
	for(int i=0;i<=last_write;i++)
	{
		if(ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]->blk_head[location->block]->page_head[i]->valid_state == true)
		{
			location->page=i;
			if (move_page(ssd, location, gc_node) == FAIL){
				cout << "Error: problem while moving valid pages in GC " << endl;
				return;
			}
			page_move_count++;
		}
	}
	ssd->stats->gc_moved_page += page_move_count;
	
	sub_request * erase_subreq = create_gc_sub_request( ssd, location, ERASE, gc_node);
	ssd->channel_head[location->channel]->lun_head[location->lun]->GCSubs.push_tail(erase_subreq);
	erase_block(ssd,location);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
movq (%rsi), %rbx
movq %rbx, %rsi
callq 0x64eb
cmpl $0x1, %eax
jne 0x644b
movq 0x90(%r14), %rax
movslq (%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movslq 0x8(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rax), %rax
movslq 0xc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x10(%rax), %r12
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpq %r12, %r13
jg 0x6465
movq 0x90(%r14), %rax
movslq (%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movslq 0x8(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rax), %rax
movslq 0xc(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rax), %rax
movq (%rax,%r13,8), %rax
cmpb $0x1, (%rax)
jne 0x6446
movl %r13d, 0x10(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x664f
testl %eax, %eax
je 0x64c2
incl %ebp
incq %r13
jmp 0x63eb
leaq 0x3663(%rip), %rdi      # 0x9ab5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2270
movq 0x98(%r14), %rax
addl %ebp, 0xc8(%rax)
pushq $0x2
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x67a4
movq 0x90(%r14), %rcx
movslq (%rbx), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x50(%rcx), %rcx
movslq 0x4(%rbx), %rdx
movq (%rcx,%rdx,8), %rdi
addq $0x48, %rdi
movq %rax, %rsi
callq 0x4120
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x69a1
movq 0x7b07(%rip), %rdi      # 0xdfd0
leaq 0x3458(%rip), %rsi      # 0x9928
callq 0x2140
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20b0
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/garbage_collection.cpp
// Function: move_page(ssd_info*, local const*, gc_operation*)
STATE move_page(ssd_info * ssd,  const local * location, gc_operation * gc_node){

	sub_request * rsub = create_gc_sub_request(ssd, location, READ, gc_node);
	ssd->channel_head[rsub->location->channel]->lun_head[rsub->location->lun]->GCSubs.push_tail(rsub);


	sub_request * wsub = create_gc_sub_request(ssd, location, WRITE, gc_node);
	wsub->location = new local(location->channel, location->lun, location->plane);
	invalid_old_page(ssd, wsub);
	wsub->ppn = get_new_ppn(ssd, wsub->lpn, wsub->location, false); // false---> cold block 
	if( wsub->ppn == -1 || write_page(ssd, wsub->lpn, wsub->ppn) == FAIL) {
		cout << "error in move page " << endl; 
		return FAIL; 
	}
		
	find_location(ssd, wsub->ppn, wsub->location);	

	buffer_entry * buf_ent = ssd->dram->map->map_entry[wsub->lpn].buf_ent; 
	if (buf_ent == NULL){
		ssd->channel_head[wsub->location->channel]->lun_head[wsub->location->lun]->GCSubs.push_tail(wsub);
	} else {
		if (!buf_ent->gc) 
			ssd->dram->buffer->hit_write(buf_ent); 
		else 
			ssd->dram->gc_buffer->hit_write(buf_ent); 	
		delete wsub; 
	}	

	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
pushq $0x1
popq %rbx
movl %ebx, %edx
movq %r15, %rcx
callq 0x67a4
movq 0x90(%r14), %rcx
movq 0x60(%rax), %rdx
movslq (%rdx), %rsi
movq (%rcx,%rsi,8), %rcx
movq 0x50(%rcx), %rcx
movslq 0x4(%rdx), %rdx
movq (%rcx,%rdx,8), %rdi
addq $0x48, %rdi
movq %rax, %rsi
callq 0x4120
xorl %ebp, %ebp
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x67a4
movq %rax, %r15
pushq $0x18
popq %rdi
callq 0x2160
movl 0x8(%r12), %ecx
movq (%r12), %rdx
movq %rdx, (%rax)
movl %ecx, 0x8(%rax)
movq %rax, 0x60(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4b30
movl 0xc(%r15), %esi
movq 0x60(%r15), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x44c6
movl %eax, 0x10(%r15)
cmpl $-0x1, %eax
je 0x6750
movl 0xc(%r15), %esi
movq %r14, %rdi
movl %eax, %edx
callq 0x4544
testl %eax, %eax
je 0x6750
movl 0x10(%r15), %esi
movq 0x60(%r15), %rdx
movq %r14, %rdi
callq 0x45f8
movq 0x60(%r14), %rax
movq 0x10(%rax), %rcx
movq (%rcx), %rcx
movl 0xc(%r15), %edx
shlq $0x4, %rdx
movq 0x8(%rcx,%rdx), %rsi
testq %rsi, %rsi
je 0x676d
movzbl (%rsi), %ecx
movq 0x18(%rax,%rcx,8), %rdi
callq 0x5d32
movq %r15, %rdi
callq 0x5d62
movl $0xa0, %esi
movq %r15, %rdi
callq 0x2170
jmp 0x6797
movq 0x7879(%rip), %rdi      # 0xdfd0
leaq 0x3310(%rip), %rsi      # 0x9a6e
callq 0x2140
movq %rax, %rdi
callq 0x20b0
jmp 0x6799
movq 0x90(%r14), %rax
movq 0x60(%r15), %rcx
movslq (%rcx), %rdx
movq (%rax,%rdx,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x48, %rdi
movq %r15, %rsi
callq 0x4120
movl %ebx, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/narges64[P]SIMBA/garbage_collection.cpp
// Function: erase_block(ssd_info*, local const*)
int erase_block(ssd_info * ssd,const local * location){

	
	unsigned int channel = location->channel;
	unsigned int lun = location->lun;
	unsigned int plane = location->plane;
	unsigned int block = location->block;

//	int initial_free = ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[block]->free_page_num;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[block]->free_page_num=ssd->parameter->page_block;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[block]->invalid_page_num=0;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[block]->last_write_page=-1;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[block]->erase_count++;

	for (int i=0;i<ssd->parameter->page_block;i++)
	{
		ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[block]->page_head[i]->valid_state=false;
		ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->blk_head[block]->page_head[i]->lpn=-1;
	}

	ssd->stats->flash_erase_count++;
	ssd->channel_head[channel]->erase_count++;
	ssd->channel_head[channel]->lun_head[lun]->erase_count++;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->erase_count++;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->free_page += ssd->parameter->page_block;
	ssd->channel_head[channel]->lun_head[lun]->plane_head[plane]->invalid_page -= ssd->parameter->page_block;

//	cout << "erase block " << channel << " "<< lun << " "<< plane << " "<< block << endl;
	return SUCCESS;

}

// Assembly:
movl (%rsi), %ecx
movl 0x4(%rsi), %edx
movl 0x8(%rsi), %r8d
movl 0xc(%rsi), %r9d
movq 0x58(%rdi), %rax
movq 0x90(%rdi), %rsi
movl 0x234(%rax), %eax
movq (%rsi,%rcx,8), %rcx
movq 0x50(%rcx), %rsi
movq (%rsi,%rdx,8), %rsi
movq (%rsi), %rdx
movq (%rdx,%r8,8), %rdx
movq 0x20(%rdx), %r8
movq (%r8,%r9,8), %r8
movl %eax, 0x4(%r8)
andl $0x0, 0x8(%r8)
orl $-0x1, 0x10(%r8)
incl (%r8)
xorl %r9d, %r9d
cmpq %r9, %rax
je 0x6a09
movq 0x20(%r8), %r10
movq (%r10,%r9,8), %r10
movb $0x0, (%r10)
orl $-0x1, 0x4(%r10)
incq %r9
jmp 0x69ee
movq 0x98(%rdi), %rdi
incq 0x98(%rdi)
incq 0x18(%rcx)
incl 0x8(%rsi)
incq 0x30(%rdx)
addq %rax, (%rdx)
subq %rax, 0x8(%rdx)
pushq $0x1
popq %rax
retq