LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
subq $0x110, %rsp            # imm = 0x110
movl (%rsi), %r8d
movq 0x58(%rdi), %rdi
movl 0x98(%rdi), %r9d
movl 0x234(%rdi), %eax
movl 0x230(%rdi), %ecx
imull %eax, %ecx
movl 0x22c(%rdi), %edx
imull %ecx, %edx
testq %r9, %r9
je 0x63b7
xorl %r10d, %r10d
movl 0x9c(%rdi,%r10,4), %r11d
imull %edx, %r11d
movl %r11d, -0x80(%rsp,%r10,4)
incq %r10
cmpq %r10, %r9
jne 0x639e
movl 0x4(%rsi), %r11d
movl 0x8(%rsi), %r9d
movl 0xc(%rsi), %edi
movl 0x10(%rsi), %esi
testq %r8, %r8
je 0x63de
xorl %ebx, %ebx
xorl %r10d, %r10d
addl -0x80(%rsp,%rbx,4), %r10d
incq %rbx
cmpq %rbx, %r8
jne 0x63cf
jmp 0x63e1
xorl %r10d, %r10d
imull %r11d, %edx
imull %r9d, %ecx
addl %edx, %ecx
imull %edi, %eax
addl %esi, %eax
addl %ecx, %eax
addl %r10d, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/ftl.cpp
// Function: get_target_plane(ssd_info*, int, int)
int get_target_plane(ssd_info * ssd, int channel, int lun) {
	int target_plane = ssd->channel_head[channel]->lun_head[lun]->plane_token;
	ssd->channel_head[channel]->lun_head[lun]->plane_token =
			(ssd->channel_head[channel]->lun_head[lun]->plane_token + 1) % ssd->parameter->plane_lun;
	return target_plane;
}

// Assembly:
movq 0x58(%rdi), %r8
movq 0x90(%rdi), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movslq %edx, %rcx
movq (%rax,%rcx,8), %rsi
movl 0x9c(%rsi), %ecx
leal 0x1(%rcx), %eax
xorl %edx, %edx
divl 0x22c(%r8)
movl %edx, 0x9c(%rsi)
movl %ecx, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
movslq (%rsi), %rax
movslq 0x4(%rsi), %rcx
movslq 0x8(%rsi), %rdx
movq 0x90(%rdi), %rsi
movq (%rsi,%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
movq (%r8,%rdx,8), %rdx
xorl %esi, %esi
cmpl $0x0, 0x4(%rdx)
jne 0x64cf
movl 0x18(%rcx), %r10d
movq 0x58(%rdi), %rdx
movl 0x230(%rdx), %r9d
xorl %r11d, %r11d
xorl %esi, %esi
cmpl %esi, %r9d
je 0x64cc
incl %eax
xorl %edx, %edx
divl %r9d
leal 0x1(%rdx), %eax
cmpl %r9d, %eax
cmovel %r11d, %eax
cmpl %r10d, %edx
cmovnel %edx, %eax
movslq %eax, %rdx
incl %esi
movq (%r8,%rdx,8), %rdx
cmpl $0x0, 0x4(%rdx)
je 0x649f
jmp 0x64cf
movl %r9d, %esi
movq 0x58(%rdi), %rdx
cmpl 0x230(%rdx), %esi
jne 0x6524
movq 0x7aee(%rip), %rbx      # 0xdfd0
leaq 0x42be(%rip), %rsi      # 0xa7a7
movl $0x1c, %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 $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x652b
movslq %eax, %rdx
movq %rdx, 0x10(%rcx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
movslq (%rsi), %rax
movslq 0x4(%rsi), %rcx
movslq 0x8(%rsi), %rdx
movq 0x90(%rdi), %rsi
movq (%rsi,%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
movq (%r8,%rdx,8), %rdx
xorl %esi, %esi
cmpl $0x0, 0x4(%rdx)
jne 0x65ae
movl 0x10(%rcx), %r10d
movq 0x58(%rdi), %rdx
movl 0x230(%rdx), %r9d
xorl %r11d, %r11d
xorl %esi, %esi
cmpl %esi, %r9d
je 0x65ab
incl %eax
xorl %edx, %edx
divl %r9d
leal 0x1(%rdx), %eax
cmpl %r9d, %eax
cmovel %r11d, %eax
cmpl %r10d, %edx
cmovnel %edx, %eax
movslq %eax, %rdx
incl %esi
movq (%r8,%rdx,8), %rdx
cmpl $0x0, 0x4(%rdx)
je 0x657e
jmp 0x65ae
movl %r9d, %esi
movq 0x58(%rdi), %rdx
cmpl 0x230(%rdx), %esi
jne 0x6603
movq 0x7a0f(%rip), %rbx      # 0xdfd0
leaq 0x41fc(%rip), %rsi      # 0xa7c4
movl $0x21, %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 $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x660a
movslq %eax, %rdx
movq %rdx, 0x18(%rcx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbx
testq %rsi, %rsi
je 0x662f
incl (%rdi)
cmpb $0x1, 0x8(%rsi)
jne 0x6676
movq 0x79af(%rip), %rdi      # 0xdfd0
leaq 0x41d1(%rip), %rsi      # 0xa7f9
movl $0x24, %edx
jmp 0x6642
movq 0x799a(%rip), %rdi      # 0xdfd0
leaq 0x41a9(%rip), %rsi      # 0xa7e6
movl $0x12, %edx
callq 0x21e0
movq 0x7982(%rip), %rbx      # 0xdfd0
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
popq %rbx
jmp 0x20f0
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x66ce
incl 0x4(%rdi)
movb $0x1, 0x1(%rsi)
cmpb $0x1, 0x8(%rsi)
jne 0x66ce
pushq %rbx
movq 0x793e(%rip), %rbx      # 0xdfd0
leaq 0x41e4(%rip), %rsi      # 0xa87d
movl $0x25, %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
popq %rbx
jmp 0x20f0
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
testq %rsi, %rsi
je 0x6829
movq %rdi, %r14
movl 0xc(%rdi), %eax
testl %eax, %eax
je 0x6829
movq %rsi, %rbx
cmpq %rsi, 0x20(%r14)
jne 0x6751
movq 0x20(%rbx), %rcx
movq %rcx, 0x20(%r14)
movq 0x10(%r14), %rcx
cmpq %rbx, %rcx
je 0x6834
cmpq %rbx, 0x18(%r14)
je 0x6841
movq 0x18(%rbx), %rdx
movq 0x20(%rbx), %rsi
movq %rdx, 0x18(%rsi)
movq 0x18(%rbx), %rdx
movq %rsi, 0x20(%rdx)
decl %eax
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
movl %eax, 0xc(%r14)
testq %rcx, %rcx
jne 0x67d7
cmpq $0x0, 0x18(%r14)
je 0x67d7
movq 0x7834(%rip), %r15      # 0xdfd0
leaq 0x4100(%rip), %rsi      # 0xa8a3
movl $0x25, %edx
movq %r15, %rdi
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x20f0
cmpq $0x0, 0x10(%r14)
je 0x682b
cmpq $0x0, 0x18(%r14)
jne 0x682b
movq 0x77e4(%rip), %r14      # 0xdfd0
leaq 0x40d6(%rip), %rsi      # 0xa8c9
movl $0x25, %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
jmp 0x682b
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x6a74
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x6ba6
// File: /workspace/github_cpp_makefile_star2_O1/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 0x686a
cmpb $0x0, 0x8(%rax)
je 0x686d
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%rdi)
movb $0x0, 0x8(%rax)
retq
xorl %eax, %eax
retq
pushq %rbx
movq 0x775b(%rip), %rbx      # 0xdfd0
leaq 0x4155(%rip), %rsi      # 0xa9d1
movl $0x1d, %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
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq $-0x1, (%rdi)
movl %ecx, 0x8(%rdi)
movl %edx, 0xc(%rdi)
movl $0xffffffff, 0x10(%rdi) # imm = 0xFFFFFFFF
xorl %r15d, %r15d
movq %r15, 0x18(%rdi)
movl %r8d, 0x20(%rdi)
movl %r15d, 0x40(%rdi)
movq %rsi, 0x48(%rdi)
movq %r15, 0x50(%rdi)
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
movq %rax, 0x58(%rdi)
movq %r15, 0x90(%rdi)
movb $0x0, 0x98(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%rdi)
movq %r15, 0x78(%rdi)
movl $0x18, %edi
callq 0x2190
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl %r15d, 0x10(%rax)
movq %rax, 0x60(%r14)
movl $0x50, %edi
callq 0x2040
movq %rax, 0x80(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movq %rbx, 0x28(%r14)
movl %r15d, 0x24(%r14)
movq %rbx, 0x88(%r14)
movl %r15d, 0x30(%r14)
movq %rbx, 0x38(%r14)
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x69af
movl 0xc(%rdi), %eax
cmpl 0x8(%rdi), %eax
jl 0x698a
movb $0x1, 0x8(%rsi)
cmpq $0x0, 0x20(%rdi)
jne 0x698a
movq %rsi, 0x20(%rdi)
pushq %rbx
movq 0x10(%rdi), %rcx
testq %rcx, %rcx
je 0x69b2
movq %rsi, 0x20(%rcx)
movq %rcx, 0x18(%rsi)
movq %rsi, 0x10(%rdi)
movq $0x0, 0x20(%rsi)
incl %eax
movl %eax, 0xc(%rdi)
jmp 0x69d5
xorl %eax, %eax
retq
cmpq $0x0, 0x18(%rdi)
jne 0x6a29
cmpl $0x0, 0xc(%rdi)
jne 0x6a29
movl $0x1, 0xc(%rdi)
movq %rsi, 0x10(%rdi)
movq %rsi, 0x18(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsi)
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %rcx
testq %rax, %rax
setne %dl
testq %rcx, %rcx
sete %sil
orb %dl, %sil
je 0x6a14
testq %rcx, %rcx
sete %cl
testq %rax, %rax
setne %dl
andb %cl, %dl
movb $0x1, %al
cmpb $0x1, %dl
jne 0x6a71
movq 0x75c5(%rip), %rdi      # 0xdfd0
leaq 0x3e45(%rip), %rsi      # 0xa857
jmp 0x6a22
movq 0x75b5(%rip), %rdi      # 0xdfd0
leaq 0x3e0f(%rip), %rsi      # 0xa831
movl $0x25, %edx
jmp 0x6a3c
movq 0x75a0(%rip), %rdi      # 0xdfd0
leaq 0x3de7(%rip), %rsi      # 0xa81e
movl $0x12, %edx
callq 0x21e0
movq 0x7588(%rip), %rbx      # 0xdfd0
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
xorl %eax, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movl 0xc(%rdi), %eax
testl %eax, %eax
je 0x6aa8
movq %rdi, %r14
movq 0x10(%rdi), %rbx
testq %rbx, %rbx
je 0x6aac
cmpq $0x0, 0x20(%rbx)
je 0x6afd
movq 0x7536(%rip), %rdi      # 0xdfd0
leaq 0x3e63(%rip), %rsi      # 0xa904
movl $0x15, %edx
jmp 0x6abf
xorl %ebx, %ebx
jmp 0x6af4
movq 0x751d(%rip), %rdi      # 0xdfd0
leaq 0x3e35(%rip), %rsi      # 0xa8ef
movl $0x14, %edx
callq 0x21e0
xorl %ebx, %ebx
movq 0x7503(%rip), %r14      # 0xdfd0
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
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq 0x18(%rbx), %rcx
movq %rcx, 0x10(%r14)
leaq 0x18(%r14), %rdx
leaq 0x20(%rcx), %rsi
decl %eax
testq %rcx, %rcx
cmoveq %rdx, %rsi
movq $0x0, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
movl %eax, 0xc(%r14)
jne 0x6b73
cmpq $0x0, 0x18(%r14)
je 0x6b73
movq 0x7498(%rip), %r15      # 0xdfd0
leaq 0x3ddb(%rip), %rsi      # 0xa91a
movl $0x25, %edx
movq %r15, %rdi
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x20f0
cmpq $0x0, 0x10(%r14)
je 0x6af4
cmpq $0x0, 0x18(%r14)
jne 0x6af4
movq 0x7440(%rip), %rdi      # 0xdfd0
leaq 0x3da9(%rip), %rsi      # 0xa940
movl $0x25, %edx
callq 0x21e0
jmp 0x6ac6
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movl 0xc(%rdi), %eax
testl %eax, %eax
je 0x6c0f
movq %rdi, %r14
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
je 0x6bc5
cmpq $0x0, 0x18(%rbx)
je 0x6c1a
movq 0x7404(%rip), %rdi      # 0xdfd0
leaq 0x3d93(%rip), %rsi      # 0xa966
movl $0x1c, %edx
callq 0x21e0
xorl %ebx, %ebx
movq 0x73ea(%rip), %r14      # 0xdfd0
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
jmp 0x6c11
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdx
leaq 0x10(%r14), %rsi
leaq 0x18(%rdx), %rdi
testq %rdx, %rdx
cmoveq %rsi, %rdi
movq %rdx, 0x18(%r14)
movq $0x0, (%rdi)
decl %eax
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movl %eax, 0xc(%r14)
cmpq $0x0, 0x10(%r14)
jne 0x6c98
cmpq $0x0, 0x18(%r14)
je 0x6c98
movq 0x7373(%rip), %r15      # 0xdfd0
leaq 0x3d1f(%rip), %rsi      # 0xa983
movl $0x26, %edx
movq %r15, %rdi
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x20f0
cmpq $0x0, 0x10(%r14)
je 0x6c11
cmpq $0x0, 0x18(%r14)
jne 0x6c11
movq 0x731b(%rip), %rdi      # 0xdfd0
leaq 0x3cee(%rip), %rsi      # 0xa9aa
movl $0x26, %edx
callq 0x21e0
jmp 0x6bdf
nop
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/flash.cpp
// Function: change_lun_state(ssd_info*, unsigned int, unsigned int, unsigned int, long, unsigned int, long)
void change_lun_state (ssd_info * ssd, unsigned int channel, unsigned int lun, unsigned int current_state, int64_t current_time, unsigned int next_state, int64_t next_time){
	// have been in the next state for some time 
	int state1 = ssd->channel_head[channel]->lun_head[lun]->current_state; 
	int state2 = ssd->channel_head[channel]->lun_head[lun]->next_state; 
	int64_t state1_time = ssd->channel_head[channel]->lun_head[lun]->current_time; 
	int64_t state2_time = ssd->channel_head[channel]->lun_head[lun]->next_state_predict_time; 

	ssd->channel_head[channel]->lun_head[lun]->state_time[state1] += ((state2_time - state1_time) > 0)? state2_time - state1_time: 0; 
	ssd->channel_head[channel]->lun_head[lun]->state_time[state2] += ((current_time - state2_time) > 0)? (current_time - state2_time): 0; 
	
	ssd->channel_head[channel]->lun_head[lun]->current_state=current_state;	
	ssd->channel_head[channel]->lun_head[lun]->current_time=current_time;
	
	ssd->channel_head[channel]->lun_head[lun]->next_state=next_state; 	
	ssd->channel_head[channel]->lun_head[lun]->next_state_predict_time=next_time;
}

// Assembly:
pushq %rbx
movq 0x90(%rdi), %rax
movl %esi, %esi
movq (%rax,%rsi,8), %rax
movq 0x50(%rax), %rax
movl %edx, %edx
movq (%rax,%rdx,8), %rax
movslq 0x14(%rax), %rdx
movslq 0x20(%rax), %rsi
movq 0x28(%rax), %rdi
movq %r8, %r10
subq %rdi, %r10
subq 0x18(%rax), %rdi
xorl %r11d, %r11d
testq %rdi, %rdi
cmovleq %r11, %rdi
movq 0x90(%rax), %rbx
addq %rdi, (%rbx,%rdx,8)
testq %r10, %r10
cmovleq %r11, %r10
movq 0x10(%rsp), %rdx
addq %r10, (%rbx,%rsi,8)
movl %ecx, 0x14(%rax)
movq %r8, 0x18(%rax)
movl %r9d, 0x20(%rax)
movq %rdx, 0x28(%rax)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/flash.cpp
// Function: change_channel_state(ssd_info*, unsigned int, unsigned int, long, unsigned int, long)
void change_channel_state(ssd_info * ssd, unsigned int channel, unsigned int current_state, int64_t current_time, unsigned int next_state, int64_t next_time){	
	int state1 = ssd->channel_head[channel]->current_state; 
	int state2 = ssd->channel_head[channel]->next_state; 
	int64_t state1_time = ssd->channel_head[channel]->current_time; 
	int64_t state2_time = ssd->channel_head[channel]->next_state_predict_time; 
	
	ssd->channel_head[channel]->state_time[state1] += (state2_time - state1_time)>0? state2_time - state1_time : 0; 
	ssd->channel_head[channel]->state_time[state2] += (current_time - state2_time)>0? current_time - state2_time : 0;  
	
	int prev_state = ssd->channel_head[channel]->current_state;  
	ssd->channel_head[channel]->state_time[prev_state] += current_time - ssd->channel_head[channel]->current_time; 
	
	ssd->channel_head[channel]->current_state=current_state;	
	ssd->channel_head[channel]->current_time=current_time;
	
	ssd->channel_head[channel]->next_state=next_state; 	
	ssd->channel_head[channel]->next_state_predict_time=next_time; 
}

// Assembly:
pushq %r14
pushq %rbx
movq 0x90(%rdi), %rax
movl %esi, %esi
movq (%rax,%rsi,8), %rax
movslq 0x38(%rax), %rsi
movslq 0x3c(%rax), %rdi
movq 0x48(%rax), %r10
movq %rcx, %r11
subq %r10, %r11
subq 0x40(%rax), %r10
xorl %ebx, %ebx
testq %r10, %r10
cmovleq %rbx, %r10
movq 0x58(%rax), %r14
addq %r10, (%r14,%rsi,8)
testq %r11, %r11
cmovleq %rbx, %r11
addq %r11, (%r14,%rdi,8)
movq %rcx, %rdi
subq 0x40(%rax), %rdi
addq %rdi, (%r14,%rsi,8)
movl %edx, 0x38(%rax)
movq %rcx, 0x40(%rax)
movl %r8d, 0x3c(%rax)
movq %r9, 0x48(%rax)
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movl $0x1, %edx
movq %r14, %rcx
callq 0x7368
movq 0x90(%r15), %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 0x44d6
xorl %ebx, %ebx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x7368
movq %rax, %r14
movl $0x18, %edi
callq 0x2190
movq (%r12), %rcx
movl 0x8(%r12), %edx
movq %rcx, (%rax)
movl %edx, 0x8(%rax)
movq %rax, 0x60(%r14)
movq %r15, %rdi
movq %r14, %rsi
callq 0x511f
movl 0xc(%r14), %esi
movq 0x60(%r14), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x49c6
movl %eax, 0x10(%r14)
cmpl $-0x1, %eax
je 0x72e7
movl 0xc(%r14), %esi
movq %r15, %rdi
movl %eax, %edx
callq 0x4a50
testl %eax, %eax
je 0x72e7
movl 0x10(%r14), %esi
movq 0x60(%r14), %rdx
movq %r15, %rdi
callq 0x4b02
movq 0x60(%r15), %rax
movq 0x10(%rax), %rcx
movq (%rcx), %rcx
movl 0xc(%r14), %edx
shlq $0x4, %rdx
movq 0x8(%rcx,%rdx), %rsi
testq %rsi, %rsi
je 0x7337
movzbl (%rsi), %ecx
movq 0x18(%rax,%rcx,8), %rdi
callq 0x6678
movl $0x1, %ebx
testq %r14, %r14
je 0x7329
movq %r14, %rdi
callq 0x66d0
movl $0xa0, %esi
movq %r14, %rdi
callq 0x21a0
jmp 0x7329
movq 0x6ce2(%rip), %r14      # 0xdfd0
leaq 0x3875(%rip), %rsi      # 0xab6a
movl $0x13, %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 %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x90(%r15), %rax
movq 0x60(%r14), %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 %r14, %rsi
callq 0x44d6
movl $0x1, %ebx
jmp 0x7329
// File: /workspace/github_cpp_makefile_star2_O1/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
incl (%r8)
movl %eax, 0x4(%r8)
movl $0x0, 0x8(%r8)
movl $0xffffffff, 0x10(%r8)  # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x765e
movq 0x20(%r8), %r8
xorl %r9d, %r9d
movq (%r8,%r9,8), %r10
movb $0x0, (%r10)
movl $0xffffffff, 0x4(%r10)  # imm = 0xFFFFFFFF
incq %r9
cmpq %r9, %rax
jne 0x7646
movq 0x98(%rdi), %rdi
incq 0x98(%rdi)
incq 0x18(%rcx)
incl 0x8(%rsi)
incq 0x30(%rdx)
addq %rax, (%rdx)
subq %rax, 0x8(%rdx)
movl $0x1, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: greedy_algorithm(ssd_info*, local*)
STATE greedy_algorithm(ssd_info * ssd,  local * location){
	int active_block = get_active_block(ssd,location);
	int cold_active_block = get_cold_active_block(ssd, location); 
	location->block = best_cost(ssd, ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane], active_block, cold_active_block);
	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x644e
movl %eax, %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x652d
movq 0x90(%r14), %rcx
movslq (%rbx), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x50(%rcx), %rcx
movslq 0x4(%rbx), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
movslq 0x8(%rbx), %rdx
movq (%rcx,%rdx,8), %rsi
movq %r14, %rdi
movl %ebp, %edx
movl %eax, %ecx
callq 0x7ee4
movl %eax, 0xc(%rbx)
movl $0x1, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: fifo_algorithm(ssd_info*, local*)
STATE fifo_algorithm(ssd_info * ssd,  local * location){
	int block = -1;
	int64_t min_time = 10000000000000;
	plane_info * the_plane = ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]; 
	int active_block = get_active_block(ssd,location);
	int cold_active_block = get_cold_active_block(ssd, location); 
	for (int i = 0; i < ssd->parameter->block_plane; i++){
		if ((i == active_block) || (i == cold_active_block)) continue;
		if(the_plane->blk_head[i]->free_page_num > 0) continue; 
		if(the_plane->blk_head[i]->invalid_page_num == 0) continue; 

		if (the_plane->blk_head[i]->last_write_time <= min_time){
			min_time = the_plane->blk_head[i]->last_write_time;
			block = i;
		}
	}
	location->block = block;
	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x90(%rdi), %rax
movslq (%rsi), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rsi), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movslq 0x8(%rsi), %rcx
movq (%rax,%rcx,8), %r15
callq 0x644e
movl %eax, %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x652d
movq 0x58(%r14), %rcx
movl 0x230(%rcx), %ecx
testq %rcx, %rcx
je 0x7780
movl %eax, %eax
movl %ebp, %esi
movabsq $0x9184e72a000, %rdi    # imm = 0x9184E72A000
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x7776
cmpq %r8, %rax
je 0x7776
movq 0x20(%r15), %r9
movq (%r9,%r8,8), %r9
cmpl $0x0, 0x4(%r9)
jg 0x7776
cmpl $0x0, 0x8(%r9)
je 0x7776
movq 0x18(%r9), %r9
cmpq %rdi, %r9
cmovlq %r9, %rdi
cmovlel %r8d, %edx
incq %r8
cmpq %r8, %rcx
jne 0x7747
jmp 0x7785
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, 0xc(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: RANDOM_algorithm(ssd_info*, local*)
STATE RANDOM_algorithm(ssd_info * ssd, local * location){
	unsigned int block = -1;
	int active_block = get_active_block(ssd,location);
	int cold_active_block = get_cold_active_block(ssd, location); 
	unsigned int rand_block = rand() % ssd->parameter->block_plane;
	plane_info * the_plane = ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]; 
	while ((rand_block == active_block) || (rand_block == cold_active_block) || (the_plane->blk_head[rand_block]->free_page_num > 0))
		rand_block = rand() % ssd->parameter->block_plane;

	location->block = rand_block;
	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x644e
movl %eax, %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x652d
movl %eax, %r15d
callq 0x20a0
movq 0x58(%r14), %rcx
movq 0x90(%r14), %rsi
xorl %edx, %edx
divl 0x230(%rcx)
movslq (%rbx), %rax
movq (%rsi,%rax,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), %r12
cmpl %ebp, %edx
je 0x79a2
cmpl %r15d, %edx
je 0x79a2
movq 0x20(%r12), %rax
movl %edx, %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x4(%rax)
jle 0x79b5
callq 0x20a0
movq 0x58(%r14), %rcx
xorl %edx, %edx
divl 0x230(%rcx)
jmp 0x7988
movl %edx, 0xc(%rbx)
movl $0x1, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: RANDOM_p_algorithm(ssd_info*, local*)
STATE RANDOM_p_algorithm(ssd_info * ssd, local * location){
	unsigned int block = -1;
	int active_block = get_active_block(ssd,location);
	int cold_active_block = get_cold_active_block(ssd, location); 

	unsigned int rand_block = rand() % ssd->parameter->block_plane;
	while ((rand_block == active_block) || (rand_block == cold_active_block) || ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]->blk_head[rand_block]->invalid_page_num == 0)
		rand_block = rand() % ssd->parameter->block_plane;

	location->block = rand_block;

	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x644e
movl %eax, %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x652d
movl %eax, %r15d
callq 0x20a0
movq 0x58(%r14), %rcx
xorl %edx, %edx
divl 0x230(%rcx)
cmpl %ebp, %edx
je 0x79e8
cmpl %r15d, %edx
je 0x79e8
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
movl %edx, %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x8(%rax)
je 0x79e8
movl %edx, 0xc(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: RANDOM_pp_algorithm(ssd_info*, local*)
STATE RANDOM_pp_algorithm(ssd_info * ssd, local * location){
	unsigned int least_invalid = ssd->parameter->overprovide * ssd->parameter->block_plane;

	unsigned int block = -1;
	int active_block = get_active_block(ssd,location);
	int cold_active_block = get_cold_active_block(ssd, location); 
	unsigned int rand_block = rand() % ssd->parameter->block_plane;
	plane_info * the_plane = ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]; 
	int counter = 0;
	while ((rand_block == active_block) || (rand_block == cold_active_block )||(the_plane->blk_head[rand_block]->invalid_page_num < least_invalid && counter <= ssd->parameter->block_plane)
				|| (the_plane->blk_head[rand_block]->free_page_num > 0)){
		rand_block = rand() % ssd->parameter->block_plane;
		counter++;
	}

	location->block = rand_block;
	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x58(%rdi), %rax
movl 0x230(%rax), %ecx
cvtsi2ss %rcx, %xmm0
mulss 0x25c(%rax), %xmm0
cvttss2si %xmm0, %r12
callq 0x644e
movl %eax, %ebp
movq %r14, %rdi
movq %rbx, %rsi
callq 0x652d
movl %eax, %r15d
callq 0x20a0
movq 0x58(%r14), %rcx
movq 0x90(%r14), %rsi
xorl %r13d, %r13d
xorl %edx, %edx
divl 0x230(%rcx)
movslq (%rbx), %rax
movq (%rsi,%rax,8), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rbx, (%rsp)
movslq 0x8(%rbx), %rcx
movq (%rax,%rcx,8), %rbx
cmpl %ebp, %edx
je 0x7af5
cmpl %r15d, %edx
je 0x7af5
movq 0x20(%rbx), %rax
movl %edx, %ecx
movq (%rax,%rcx,8), %rax
cmpl %r12d, 0x8(%rax)
jae 0x7aef
movq 0x58(%r14), %rcx
cmpl 0x230(%rcx), %r13d
jbe 0x7af5
cmpl $0x0, 0x4(%rax)
jle 0x7b0b
callq 0x20a0
movq 0x58(%r14), %rcx
xorl %edx, %edx
divl 0x230(%rcx)
incl %r13d
jmp 0x7ac9
movq (%rsp), %rax
movl %edx, 0xc(%rax)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: Schedule_GC(ssd_info*, sub_request*)
bool Schedule_GC(ssd_info * ssd, sub_request * sub){
		
	local * location = sub->location; 
	unsigned int free_page = ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]->free_page;
	unsigned int invalid_page = ssd->channel_head[location->channel]->lun_head[location->lun]->plane_head[location->plane]->invalid_page;
	unsigned int all_page = ssd->parameter->page_block*ssd->parameter->block_plane;
	gc_operation * gc_node = NULL;



	if (free_page > (all_page * ssd->parameter->gc_down_threshold)){
		return false;
	}
	gc_node = new gc_operation(location, ssd->gc_sequence_number++);

	if (add_gc_node(ssd, gc_node) != SUCCESS){
		delete gc_node;
		return false;
	}

	sub->trigger_gc = true; 	
	
	//int invalid_00 = ssd->channel_head[0]->lun_head[0]->plane_head[location->plane]->invalid_page;
	//int invalid_01 = ssd->channel_head[0]->lun_head[1]->plane_head[location->plane]->invalid_page;
	//int invalid_10 = ssd->channel_head[1]->lun_head[0]->plane_head[location->plane]->invalid_page;
	//int invalid_11 = ssd->channel_head[1]->lun_head[1]->plane_head[location->plane]->invalid_page;
	//cout << "GC starts for planes " << location->channel << location->lun << " with (" << invalid_00 << "," << invalid_01 << "," << invalid_10 << "," << invalid_11 << ")\n";
	gc_for_plane(ssd, gc_node);

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x60(%rsi), %r13
movq 0x58(%rdi), %rax
movq 0x90(%rdi), %r12
movslq (%r13), %rcx
movq (%r12,%rcx,8), %rcx
movq 0x50(%rcx), %rcx
movslq 0x4(%r13), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
movslq 0x8(%r13), %rdx
movq (%rcx,%rdx,8), %rcx
movl 0x230(%rax), %edx
imull 0x234(%rax), %edx
movl (%rcx), %ecx
cvtsi2ss %rcx, %xmm0
cvtsi2ss %rdx, %xmm1
mulss 0x28c(%rax), %xmm1
ucomiss %xmm1, %xmm0
ja 0x7c39
movq %rsi, %r14
movq %rdi, %rbx
movss %xmm1, (%rsp)
movss %xmm0, 0x4(%rsp)
movl $0x20, %edi
callq 0x2190
movq %rax, %r15
movl 0x10(%rbx), %ebp
leal 0x1(%rbp), %eax
movl %eax, 0x10(%rbx)
movq $0x0, 0x18(%r15)
movl $0x0, 0xc(%r15)
movl $0x18, %edi
callq 0x2190
movq (%r13), %rcx
movl 0x8(%r13), %edx
movq %rcx, (%rax)
movl %edx, 0x8(%rax)
movq $0x0, 0xc(%rax)
movq %rax, (%r15)
movl %ebp, 0x8(%r15)
movslq (%rax), %rcx
movq (%r12,%rcx,8), %rcx
movq 0x50(%rcx), %rcx
movslq 0x4(%rax), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
movslq 0x8(%rax), %rax
movq (%rcx,%rax,8), %rax
movq 0x70(%rax), %rcx
addq $0x70, %rax
leaq 0x18(%rcx), %rdx
testq %rcx, %rcx
cmoveq %rax, %rdx
movq %r15, (%rdx)
movb $0x1, 0x98(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6ea0
movss 0x4(%rsp), %xmm0
movss (%rsp), %xmm1
ucomiss %xmm1, %xmm0
setbe %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x20, %esi
movq %r15, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x22e0
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: delete_gc_node(ssd_info*, gc_operation*)
STATE delete_gc_node(ssd_info * ssd, gc_operation * gc_node){
	if (gc_node == NULL) return FAIL;
	if (ssd->channel_head[gc_node->location->channel]->lun_head[gc_node->location->lun]->plane_head[gc_node->location->plane]->scheduled_gc == NULL) return FAIL;
	ssd->channel_head[gc_node->location->channel]->lun_head[gc_node->location->lun]->plane_head[gc_node->location->plane]->scheduled_gc = gc_node->next_node;
	delete gc_node;
	return SUCCESS;
}

// Assembly:
xorl %eax, %eax
testq %rsi, %rsi
je 0x7ee3
pushq %rbx
movq %rsi, %rbx
movq 0x90(%rdi), %rcx
movq (%rsi), %rdi
movslq (%rdi), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x50(%rcx), %rcx
movslq 0x4(%rdi), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
movslq 0x8(%rdi), %rdx
movq (%rcx,%rdx,8), %rcx
cmpq $0x0, 0x70(%rcx)
je 0x7ee2
movq 0x18(%rbx), %rax
movq %rax, 0x70(%rcx)
movl $0x18, %esi
callq 0x21a0
movl $0x20, %esi
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/garbage_collection.cpp
// Function: best_cost(ssd_info*, plane_info*, int, int)
unsigned int best_cost(ssd_info * ssd, plane_info * the_plane, int active_block, int cold_active_block){
	int max_invalid = -1; // ssd->parameter->page_block; 
	int selected_block = -1; 
	for (int i = 0; i < ssd->parameter->block_plane; i++){
		if ((i == active_block) || (i == cold_active_block)) continue; 
		int free_count = the_plane->blk_head[i]->free_page_num; 
		int invalid_count = the_plane->blk_head[i]->invalid_page_num; 
		
		if (free_count > 0) continue; 
		if (invalid_count > max_invalid) {
			max_invalid = invalid_count; 
			selected_block = i; 
		} 
	}	
	return selected_block; 
}

// Assembly:
pushq %rbx
movq 0x58(%rdi), %rax
movl 0x230(%rax), %edi
testq %rdi, %rdi
je 0x7f48
movl %ecx, %ecx
movl %edx, %edx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %r9, %rdx
sete %r10b
cmpq %r9, %rcx
sete %r11b
orb %r10b, %r11b
jne 0x7f3e
movq 0x20(%rsi), %r10
movq (%r10,%r9,8), %r10
movl 0x8(%r10), %r11d
cmpl %r8d, %r11d
movl %eax, %ebx
cmovgl %r9d, %ebx
cmovlel %r8d, %r11d
cmpl $0x0, 0x4(%r10)
cmovlel %ebx, %eax
cmovlel %r11d, %r8d
incq %r9
cmpq %r9, %rdi
jne 0x7f06
jmp 0x7f4d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/ssd.cpp
// Function: generate_trace_file(ssd_info*, char*)
void generate_trace_file(ssd_info * ssd, char * trace_filename){
	ssd->tracefile = fopen(trace_filename, "w"); 
	if (ssd->tracefile == NULL) {
		cout << "file is not ready " << endl; 
		return; 
	} 
	int64_t nearest_event_time = MAX_INT64; 
	struct request * request1; 
	do {
		request1 = generate_next_request(ssd, nearest_event_time);
		if (request1 != NULL && request1->time != MAX_INT64)
			request1->print_to_file(ssd->tracefile); 
	}while(request1 != NULL && request1->time != MAX_INT64);
	
	fclose(ssd->tracefile); 		

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x1ff1(%rip), %rsi      # 0xa14b
movq %rax, %rdi
callq 0x2200
movq %rax, 0x48(%rbx)
testq %rax, %rax
je 0x81ae
movabsq $0x7fffffffffffffff, %r14 # imm = 0x7FFFFFFFFFFFFFFF
movq %rbx, %rdi
movq %r14, %rsi
callq 0x909e
testq %rax, %rax
je 0x81a0
movq %rax, %r15
cmpq %r14, 0x8(%rax)
je 0x819a
movq 0x48(%rbx), %rsi
movq %r15, %rdi
callq 0x998a
cmpq %r14, 0x8(%r15)
jne 0x8175
movq 0x48(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2180
movq 0x5e1b(%rip), %rbx      # 0xdfd0
leaq 0x2b1a(%rip), %rsi      # 0xacd6
movl $0x12, %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
popq %rbx
popq %r14
popq %r15
jmp 0x20f0
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/ssd.cpp
// Function: simulate(ssd_info*)
ssd_info *simulate(ssd_info *ssd){

	int flag=0;
	unsigned int a=0,b=0;
	static int second = 0;

	printf("\n");
	printf("begin simulating.......................\n");
	printf("\n");

	int i = 0;
	while(flag!=100)
	{
		flag=get_requests_consolidation(ssd);
		if(flag == 1)
		{
			distribute(ssd); // in ssd.cpp
		}
		process(ssd); // in ftl.cpp
		trace_output(ssd);
		if(flag == 0 && ssd->request_queue == NULL){
			flag = 100;
		}
		if (ssd->current_time != MAX_INT64 && ssd->current_time / EPOCH_LENGTH  > second){
			print_epoch_statistics(ssd, 1);
			while (ssd->current_time / (EPOCH_LENGTH) > second)
				second++;
		}

//		if (!ssd->dram->buffer->check_buffer()) {
//			cout << "BUFFER FAIL " << endl;
//			break;
//		}
	}

	return ssd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0xa, %edi
callq 0x2260
leaq 0x2eb2(%rip), %rdi      # 0xb0c2
callq 0x22a0
movl $0xa, %edi
callq 0x2260
movabsq $0x7fffffffffffffff, %r15 # imm = 0x7FFFFFFFFFFFFFFF
movabsq $0x36f9bfb3af7b757, %r14 # imm = 0x36F9BFB3AF7B757
movq %rbx, %rdi
callq 0x8b18
movl %eax, %ebp
cmpl $0x1, %eax
jne 0x824a
movq %rbx, %rdi
callq 0x4b79
movq %rbx, %rdi
callq 0x51dc
movq %rbx, %rdi
callq 0x8b47
testl %ebp, %ebp
je 0x8262
xorl %ebp, %ebp
jmp 0x826b
cmpq $0x0, 0x68(%rbx)
sete %bpl
movq (%rbx), %rax
cmpq %r15, %rax
je 0x82be
imulq %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x1b, %rdx
addq %rax, %rdx
movslq 0x5f29(%rip), %rax      # 0xe1b4
cmpq %rax, %rdx
jle 0x82be
movq %rbx, %rdi
callq 0x82d6
movq %r14, %rax
imulq (%rbx)
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x1b, %rdx
addq %rax, %rdx
movslq 0x5f01(%rip), %rax      # 0xe1b4
cmpq %rax, %rdx
jle 0x82be
movl %edx, 0x5ef6(%rip)      # 0xe1b4
testb %bpl, %bpl
je 0x8233
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq