LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/./Thread.h
// Function: Thread::start()
void start()
    {
        if (m_threadbase_ptr == NULL) {
            m_threadbase_ptr = new pthread_t;
            int rc = pthread_create(m_threadbase_ptr, NULL, threadbase_dispatcher, this);
            if (rc != 0) {
                throw std::runtime_error("threadbase pthread_create failed");
            }
        } else {
            throw std::runtime_error("multiple threadbase start");
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpq $0x0, 0x8(%rdi)
jne 0x28c1e
movq %rdi, %rbx
movl $0x8, %edi
callq 0x32d0
movq %rax, 0x8(%rbx)
leaq -0x34(%rip), %rdx       # 0x28bd4
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x3500
testl %eax, %eax
jne 0x28c3c
popq %rbx
popq %r14
popq %rbp
retq
movl $0x10, %edi
callq 0x3130
movq %rax, %rbx
leaq 0x922b(%rip), %rsi      # 0x31e5d
movq %rax, %rdi
callq 0x30f0
jmp 0x28c58
movl $0x10, %edi
callq 0x3130
movq %rax, %rbx
leaq 0x91ec(%rip), %rsi      # 0x31e3c
movq %rax, %rdi
callq 0x30f0
movq 0x11391(%rip), %rsi     # 0x39ff0
movq 0x1135a(%rip), %rdx     # 0x39fc0
movq %rbx, %rdi
callq 0x3460
jmp 0x28c70
movq %rax, %r14
movq %rbx, %rdi
callq 0x31e0
movq %r14, %rdi
callq 0x34b0
nop
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/./Thread.h
// Function: Thread::join()
void join()
    {
        if (m_threadbase_ptr) {
            int rc = pthread_join(*m_threadbase_ptr, NULL);
            if (rc != 0) {
                throw std::runtime_error("threadbase pthread_join failed");
            }
            delete m_threadbase_ptr;
            m_threadbase_ptr = NULL;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x28cc0
movq %rdi, %rbx
movq (%rax), %rdi
xorl %esi, %esi
callq 0x3270
testl %eax, %eax
jne 0x28cc5
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x28cb8
movl $0x8, %esi
callq 0x32e0
movq $0x0, 0x8(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movl $0x10, %edi
callq 0x3130
movq %rax, %rbx
leaq 0x919e(%rip), %rsi      # 0x31e77
movq %rax, %rdi
callq 0x30f0
movq 0x11308(%rip), %rsi     # 0x39ff0
movq 0x112d1(%rip), %rdx     # 0x39fc0
movq %rbx, %rdi
callq 0x3460
movq %rax, %r14
movq %rbx, %rdi
callq 0x31e0
movq %r14, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/./ThreadEncoderReader.h
// Function: ThreadEncoderReader::run()
virtual void run()
    {
        long u = 100000000;
        double elapsedTime = 0.0;

        struct timeval t1;
        gettimeofday(&t1, NULL);

        struct timeval t2;

        while(u > 0)
        {
            u--;
        }
        gettimeofday(&t2, NULL);

        elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0;      // sec to ms
        elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0;   // us to ms
        std::cout << elapsedTime << " ms.\n" << std::endl;

    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
leaq -0x30(%rbp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3400
leaq -0x20(%rbp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x3400
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq (%rbx), %rax
cvtsi2sd %rax, %xmm1
movsd 0x8f00(%rip), %xmm2     # 0x31c58
mulsd %xmm2, %xmm1
subq 0x8(%rbx), %rcx
cvtsi2sd %rcx, %xmm0
divsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x11254(%rip), %rdi     # 0x39fc8
callq 0x33f0
movq %rax, %rbx
leaq 0x909b(%rip), %rsi      # 0x31e1e
movl $0x5, %edx
movq %rax, %rdi
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x31b0
nop
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/./ThreadTargetCalculator.h
// Function: ThreadTargetCalculator::run()
virtual void run()
    {
        long long k = 0;
        long long a = 0;
        while(true)
        {
            k = 0;
            for(int i=0;i<10000;i++)
            {
                k+=i;
            }
            k=0;
            a++;
            if(a > 10000)
            {
                std::cout << "hello I'm still here..." << std::endl;
                a = 0;
            }
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
xorl %eax, %eax
movq 0x111e2(%rip), %rbx     # 0x39fc8
leaq 0x9037(%rip), %r14      # 0x31e24
leaq 0x1(%rax), %rcx
cmpq $0x2710, %rax           # imm = 0x2710
movq %rcx, %rax
jl 0x28ded
movl $0x17, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31b0
xorl %eax, %eax
jmp 0x28ded
nop
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/Utils.cpp
// Function: Util::diff180(double, double)
double Util::diff180(double a, double b)
{
  double diff = a - b;

  while (diff <= -180.0)
  {
    diff += 360.0;
  }

  while (diff > 180.0)
  {
    diff -= 360.0;
  }

  return diff;
}

// Assembly:
subsd %xmm1, %xmm0
movsd 0x6b8c(%rip), %xmm1     # 0x31c08
ucomisd %xmm0, %xmm1
jb 0x2b094
movsd 0xfde(%rip), %xmm2      # 0x2c068
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
jae 0x2b08a
pushq %rbp
movq %rsp, %rbp
ucomisd 0x6b70(%rip), %xmm0     # 0x31c10
jbe 0x2b0bc
movsd 0x6e86(%rip), %xmm1     # 0x31f30
movsd 0x6b5e(%rip), %xmm2     # 0x31c10
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
ja 0x2b0b2
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/Utils.cpp
// Function: Util::crudeCalcSeparation(double, double, double, double)
unsigned int Util::crudeCalcSeparation(double az1, double el1, double az2, double el2)
{
    double cossep;

    az1 *= radPerDeg;
    el1 *= radPerDeg;
    az2 *= radPerDeg;
    el2 *= radPerDeg;

    cossep = (MathLib::sin(el1)*MathLib::sin(el2)) + (MathLib::cos(el1)*MathLib::cos(el2)*MathLib::cos(az1-az2));

    return (unsigned int)(20000.0*(1.0-cossep));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movapd %xmm1, %xmm4
movsd 0xf8e(%rip), %xmm1      # 0x2c060
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm4
movsd %xmm4, -0x10(%rbp)
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
movsd %xmm0, -0x20(%rbp)
mulsd %xmm3, %xmm1
movsd %xmm1, -0x8(%rbp)
movapd %xmm4, %xmm0
callq 0x572e
movsd %xmm0, -0x28(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x572e
movsd %xmm0, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x5724
movsd %xmm0, -0x10(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x5724
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x5724
mulsd -0x8(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
mulsd -0x28(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd 0xec6(%rip), %xmm0      # 0x2c020
subsd %xmm1, %xmm0
mulsd 0x6dd2(%rip), %xmm0     # 0x31f38
cvttsd2si %xmm0, %rax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/Utils.cpp
// Function: Util::goodAlignmentGeometry(StarData&, StarData&)
bool Util::goodAlignmentGeometry(StarData& starData1, StarData& starData2)
{
    unsigned int crudeSep, minCrudeSep;
    double azDiff;

    // Reject alignments with insufficient separation in azimuth, even if the
    // elevations are quite different.

    azDiff = diff180(starData1.az, starData2.az);

    if (fabs(azDiff) < 5.0)
    {
        return false;
    }

    // Also make sure the recorded az/el positions are not identical
    // or very close to each other.
    minCrudeSep = crudeCalcSeparation(0.0, 0.0, 0.0, 5.0);  // 5.0 degree min sep

    crudeSep = crudeCalcSeparation(starData1.az, starData1.el, starData2.az, starData2.az);

    if (crudeSep < minCrudeSep)
    {
        return false;
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movsd 0x8(%rdi), %xmm0
subsd 0x8(%rsi), %xmm0
movsd 0x6a74(%rip), %xmm1     # 0x31c08
ucomisd %xmm0, %xmm1
jb 0x2b1ac
movsd 0xec6(%rip), %xmm2      # 0x2c068
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
jae 0x2b1a2
ucomisd 0x6a5c(%rip), %xmm0     # 0x31c10
jbe 0x2b1d0
movsd 0x6d72(%rip), %xmm1     # 0x31f30
movsd 0x6a4a(%rip), %xmm2     # 0x31c10
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
ja 0x2b1c6
andpd 0xfe8(%rip), %xmm0      # 0x2c1c0
movsd 0x6890(%rip), %xmm1     # 0x31a70
ucomisd %xmm0, %xmm1
jbe 0x2b1ea
xorl %eax, %eax
jmp 0x2b226
movsd 0x687e(%rip), %xmm3     # 0x31a70
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x2b0be
movl %eax, %r15d
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm1
movsd 0x8(%rbx), %xmm2
movapd %xmm2, %xmm3
callq 0x2b0be
cmpl %r15d, %eax
setae %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/Utils.cpp
// Function: Util::getEffectiveTime()
long long Util::getEffectiveTime()
{
    time_t timer;
    struct tm y2k;
    double seconds;

    y2k.tm_hour = 0;   y2k.tm_min = 0; y2k.tm_sec = 0;
    y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;

    time(&timer);  /* get current time; same as: timer = time(NULL)  */
    seconds = difftime(timer,mktime(&y2k));
    return seconds;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq -0x50(%rbp), %rbx
movq %rax, 0x8(%rbx)
movq $0x0, (%rbx)
movabsq $0x6400000000, %rax     # imm = 0x6400000000
movq %rax, 0x10(%rbx)
leaq -0x18(%rbp), %r14
movq %r14, %rdi
callq 0x3280
movq (%r14), %r14
movq %rbx, %rdi
callq 0x31a0
movq %r14, %rdi
movq %rax, %rsi
callq 0x3150
cvttsd2si %xmm0, %rax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/philipperemy[P]digital-setting-circles/main.cpp
// Function: main
int main()
{
    Test test;
    test.run_all();

  /*  Encoder encoder_1(23, 24);
    Encoder encoder_2(21, 22);

    encoderNameSpace::_callback();

    StarData starData;
    cout << "validate star data = " << starDataNamespace::validStarData(starData) << endl;

    Calc c;
    double ra = 0;
    double *raptr = &ra;
    double dec = 0;
    double *decptr = &dec;

    c.setAlignmentData(0, 200, 323, 123, 233, 2000000);
    c.setAlignmentData(1, 201, 324, 124, 234, 2000001);
    c.finalizeAlignment(false);
    c.AzElToEq(201, 122, 2000002, raptr, decptr);
    cout << "ra " << *raptr << endl;
    cout << "dec " << *decptr << endl;
    cout << "Hello world!" << endl;

    return 0;*/

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
leaq -0x20(%rbp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
leaq -0x30(%rbp), %rdi
callq 0x2675c
movq -0x30(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b2ed
movq -0x20(%rbp), %rsi
incq %rsi
callq 0x32e0
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq -0x30(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b310
movq -0x20(%rbp), %rsi
incq %rsi
callq 0x32e0
movq %rbx, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: parameter_value::parameter_value(int, char**)
parameter_value::parameter_value(int argc, char ** argv){
		trace_filename = new char[100]; 		 
		synthetic = false; 

		strcpy(filename, argv[1]);
		load_parameters(argv[1]);
	
		load_inline_parameters(argc, argv);
	
		if (synthetic) {	
			sprintf(trace_filename, "trace_%.1f_%d_%d_%d", syn_rd_ratio , 
							syn_req_size , syn_req_count ,
							syn_interarrival_mean);
		}
	
		// distribute luns between channels
		for (int i = 0; i < channel_number; i++){
				lun_channel[i] = 0;
		}
		int channel = 0;
		for (int i = 0; i < lun_num; i++){
				lun_channel[channel]++;
				channel = (channel + 1) % channel_number;
		}

		channel = 0;
		for (int i = 0; i < channel_number; i++){
				if (lun_channel[i] != 0){
						channel++;
				}
		}
		channel_number = channel;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
movl $0x64, %edi
callq 0x2040
movq %rax, 0x340(%rbx)
movb $0x0, 0x348(%rbx)
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x2130
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x25e8
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x36a8
cmpb $0x1, 0x348(%rbx)
jne 0x256e
cvtss2sd 0x324(%rbx), %xmm0
movq 0x340(%rbx), %rdi
movl 0x328(%rbx), %ecx
movl 0x32c(%rbx), %edx
movl 0x330(%rbx), %r8d
leaq 0x7bcd(%rip), %rsi      # 0xa134
movb $0x1, %al
callq 0x2080
movl 0x98(%rbx), %edx
testq %rdx, %rdx
je 0x258b
leaq 0x9c(%rbx), %rdi
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20d0
cmpl $0x0, 0x88(%rbx)
je 0x25b6
xorl %ecx, %ecx
xorl %edx, %edx
movslq %edx, %rax
incl 0x9c(%rbx,%rax,4)
incl %eax
xorl %edx, %edx
divl 0x98(%rbx)
incl %ecx
cmpl 0x88(%rbx), %ecx
jb 0x2598
movl 0x98(%rbx), %eax
testq %rax, %rax
je 0x25da
xorl %edx, %edx
xorl %ecx, %ecx
cmpl $0x1, 0x9c(%rbx,%rdx,4)
sbbl $-0x1, %ecx
incq %rdx
cmpq %rdx, %rax
jne 0x25c5
jmp 0x25dc
xorl %ecx, %ecx
movl %ecx, 0x98(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: parameter_value::print_all_parameters(_IO_FILE*)
void parameter_value::print_all_parameters(FILE * stat_file){
		FILE * fp = fopen(filename, "r");
		char buffer[300];
		while (fgets(buffer, 300, fp)){
				fprintf(stat_file, "%s", buffer);
				fflush(stat_file);
		}
		fclose(fp);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq %rsi, %rbx
leaq 0x67df(%rip), %rsi      # 0xa22d
callq 0x2200
movq %rax, %r14
movq %rsp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %rax, %rdx
callq 0x22b0
testq %rax, %rax
je 0x3a96
movq %rsp, %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x21f0
movq %r15, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r14, %rdx
callq 0x22b0
testq %rax, %rax
jne 0x3a6e
movq %r14, %rdi
callq 0x2180
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: statistics::statistics(int)
statistics::statistics(int cons_deg){
	consolidation_degree = cons_deg;

	read_request_size = new int64_t[cons_deg];
	total_read_request_size = new int64_t[cons_deg];
	write_request_size = new int64_t[cons_deg];
	total_write_request_size = new int64_t[cons_deg];

	subreq_state_time = new int64_t[SR_MODE_NUM];

	reset_all();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
movq %rcx, 0x28(%rdi)
movq %rax, 0x20(%rdi)
movl %eax, 0x30(%rdi)
movups %xmm0, 0x38(%rdi)
movq %rcx, 0x50(%rdi)
movq %rax, 0x48(%rdi)
movups %xmm0, 0x190(%rdi)
movups %xmm0, 0x1a0(%rdi)
movups %xmm0, 0x1b0(%rdi)
movups %xmm0, 0x1c0(%rdi)
movl %esi, (%rdi)
movslq %esi, %rax
leaq (,%rax,8), %rcx
testl %eax, %eax
movq $-0x1, %r14
cmovnsq %rcx, %r14
movq %r14, %rdi
callq 0x2040
movq %rax, 0x58(%rbx)
movq %r14, %rdi
callq 0x2040
movq %rax, 0x60(%rbx)
movq %r14, %rdi
callq 0x2040
movq %rax, 0x68(%rbx)
movq %r14, %rdi
callq 0x2040
movq %rax, 0x70(%rbx)
movl $0x50, %edi
callq 0x2040
movq %rax, 0x188(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3dac
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: statistics::~statistics()
statistics::~statistics(){
	delete read_request_size;
	delete total_read_request_size;
	delete write_request_size;
	delete total_write_request_size;
	delete subreq_state_time;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x58(%rdi), %rdi
testq %rdi, %rdi
je 0x3e6f
movl $0x8, %esi
callq 0x21a0
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x3e82
movl $0x8, %esi
callq 0x21a0
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x3e95
movl $0x8, %esi
callq 0x21a0
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x3ea8
movl $0x8, %esi
callq 0x21a0
movq 0x188(%rbx), %rdi
testq %rdi, %rdi
je 0x3ebf
movl $0x8, %esi
popq %rbx
jmp 0x21a0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: dram_info::dram_info(parameter_value*)
dram_info::dram_info(parameter_value * parameters)
{
	map = new map_info();
	int page_num = parameters->page_block*parameters->block_plane*parameters->plane_lun*parameters->lun_num;
	map->count = page_num * (1-parameters->overprovide); 
	map->map_entry = new entry[page_num];

	dram_capacity = parameters->dram_capacity;
	gcb_capacity = 0; // parameters->gcb_capacity; 
	int io_share = dram_capacity - gcb_capacity; 
	buffer = new write_buffer(io_share, parameters->subpage_page);
	gc_buffer = buffer; // new write_buffer(gcb_capacity , parameters->subpage_page);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl $0x10, %edi
callq 0x2190
movq %rax, %r15
movl $0x0, 0x8(%rax)
movq %rax, 0x10(%rbx)
movl 0x230(%r14), %eax
imull 0x234(%r14), %eax
imull 0x22c(%r14), %eax
imull 0x88(%r14), %eax
cvtsi2ss %eax, %xmm0
movss 0x621a(%rip), %xmm1     # 0xa130
subss 0x25c(%r14), %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
movl %ecx, 0x8(%r15)
movslq %eax, %r13
movq %r13, %r12
shlq $0x4, %r12
testl %r13d, %r13d
movq $-0x1, %rdi
cmovnsq %r12, %rdi
callq 0x2040
testl %r13d, %r13d
je 0x3f71
movq %rax, %rcx
addq %r12, %rcx
movq %rax, %rdx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
movb $0x0, 0x4(%rdx)
movq $0x0, 0x8(%rdx)
addq $0x10, %rdx
cmpq %rcx, %rdx
jne 0x3f56
movq %rax, (%r15)
movl 0x8c(%r14), %ebp
movl %ebp, (%rbx)
movl $0x0, 0x4(%rbx)
movl $0x28, %edi
callq 0x2190
movq %rax, %rcx
shll $0xb, %ebp
movl %ebp, %eax
cltd
idivl 0x238(%r14)
movl %eax, 0x8(%rcx)
movq $0x0, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rcx)
movups %xmm0, 0xc(%rcx)
movq %rcx, 0x18(%rbx)
movq %rcx, 0x20(%rbx)
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/common.cpp
// Function: blk_info::blk_info(parameter_value*)
blk_info::blk_info(parameter_value * parameters)
{
	free_page_num = parameters->page_block;	// all pages are free
	last_write_page = -1;	// no page has been programmed
	last_write_time = 0; 
	page_num = parameters->page_block;
	invalid_page_num = 0;

	page_head = new page_info*[parameters->page_block];
	for(int i = 0; i<parameters->page_block; i++)
	{
		page_head[i] = new page_info();
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x234(%rsi), %r14d
movl %r14d, 0x4(%rdi)
movl $0xffffffff, 0x10(%rdi) # imm = 0xFFFFFFFF
movq $0x0, 0x18(%rdi)
movl %r14d, 0xc(%rdi)
movl $0x0, 0x8(%rdi)
leaq (,%r14,8), %rdi
callq 0x2040
movq %rax, 0x20(%rbx)
testq %r14, %r14
je 0x4040
xorl %r15d, %r15d
movl $0x8, %edi
callq 0x2190
movb $0x0, (%rax)
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movq 0x20(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x401c
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: plane_info::plane_info(parameter_value*)
plane_info::plane_info(parameter_value  * parameters)
{
	free_page=parameters->block_plane*parameters->page_block;
	invalid_page = 0; 
	
	blk_head = new blk_info*[parameters->block_plane];
	for(int i = 0; i<parameters->block_plane; i++)
	{
		blk_head[i] = new blk_info(parameters);
	}
	block_num = parameters->block_plane;
	active_block = 0;
	cold_active_block = 1; 
	erase_count = 0;
	program_count = 0;
	GCMode = false;
	current_state = PLANE_MODE_IDLE;
	next_state = PLANE_MODE_IDLE;
	current_time = 0;
	next_state_predict_time = 0;
	state_time = new int64_t[PLANE_MODE_NUM];
	for (int i = 0; i < PLANE_MODE_NUM; i++){
		state_time[i] = 0;
	}
	scheduled_gc = NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl 0x230(%rsi), %edi
movl 0x234(%rsi), %eax
imull %edi, %eax
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
shlq $0x3, %rdi
callq 0x2040
movq %rax, 0x20(%rbx)
movl 0x230(%r14), %eax
testl %eax, %eax
je 0x40b8
xorl %r12d, %r12d
movl $0x28, %edi
callq 0x2190
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x3fd6
movq 0x20(%rbx), %rax
movq %r15, (%rax,%r12,8)
incq %r12
movl 0x230(%r14), %eax
cmpq %rax, %r12
jb 0x4089
movl %eax, %eax
movq %rax, 0x28(%rbx)
xorl %r14d, %r14d
movq %r14, 0x10(%rbx)
movq $0x1, 0x18(%rbx)
movq %r14, 0x30(%rbx)
movb $0x0, 0x68(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x50(%rbx)
movl $0x18, %edi
callq 0x2040
movq %rax, 0x60(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r14, 0x10(%rax)
movq %r14, 0x70(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movl $0x28, %esi
movq %r15, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x22e0
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: lun_info::lun_info(parameter_value*)
lun_info::lun_info(parameter_value * parameter)
{
	current_state = LUN_MODE_IDLE;
	next_state = LUN_MODE_IDLE;
	current_time = 0;
	next_state_predict_time = 0;
	read_count = 0;
	program_count = 0;
	erase_count = 0;
	read_avg = 0;
	program_avg = 0;
	gc_avg = 0;
	plane_token = 0;

	GCMode = false;
	plane_head = new plane_info*[parameter->plane_lun];
	for (int i = 0; i<parameter->plane_lun; i++)
	{
		plane_head[i] = new plane_info(parameter);
	}

	state_time = new int64_t [LUN_MODE_NUM];
	for (int i = 0; i < LUN_MODE_NUM; i++)
		state_time[i] = 0;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, 0x70(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x78(%rdi)
movl %eax, 0x88(%rdi)
movb $0x0, 0x98(%rdi)
movups %xmm0, 0x8(%rdi)
movups %xmm0, 0x14(%rdi)
movups %xmm0, 0x28(%rdi)
movups %xmm0, 0x38(%rdi)
movups %xmm0, 0x48(%rdi)
movl %eax, 0x58(%rdi)
movups %xmm0, 0x9c(%rdi)
movups %xmm0, 0xac(%rdi)
movups %xmm0, 0xbc(%rdi)
movups %xmm0, 0xcc(%rdi)
movups %xmm0, 0xdc(%rdi)
movups %xmm0, 0xec(%rdi)
movl %eax, 0xfc(%rdi)
movl 0x22c(%rsi), %r15d
leaq (,%r15,8), %rdi
callq 0x2040
movq %rax, (%rbx)
testq %r15, %r15
je 0x41ef
xorl %r12d, %r12d
movl $0x78, %edi
callq 0x2190
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x4046
movq (%rbx), %rax
movq %r15, (%rax,%r12,8)
incq %r12
movl 0x22c(%r14), %eax
cmpq %rax, %r12
jb 0x41c1
movl $0x18, %edi
callq 0x2040
movq %rax, 0x90(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movl $0x78, %esi
movq %r15, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x22e0
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: channel_info::channel_info(int, parameter_value*)
channel_info::channel_info(int channel_number, parameter_value * parameters) {
	// set the parameter of each channel
	lun_num = parameters->lun_channel[channel_number];
	current_state = CHANNEL_MODE_IDLE;
	next_state = CHANNEL_MODE_IDLE;
	current_time = 0;
	next_state_predict_time = 0;
	lun_head = new lun_info*[lun_num];

	for (int j = 0; j< lun_num; j++)
	{
		lun_head[j] = new lun_info(parameters);
	}

	state_time = new int64_t[CHANNEL_MODE_NUM];
	for (int i = 0; i < CHANNEL_MODE_NUM; i++){
		state_time[i] = 0;
	}

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
movslq %esi, %rax
movslq 0x9c(%rdx,%rax,4), %rax
leaq (,%rax,8), %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
movl %eax, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbx)
movq $0x0, 0x48(%rbx)
callq 0x2040
movq %rax, 0x50(%rbx)
cmpl $0x0, (%rbx)
jle 0x42d6
xorl %r12d, %r12d
movl $0x100, %edi            # imm = 0x100
callq 0x2190
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x4130
movq 0x50(%rbx), %rax
movq %r15, (%rax,%r12,8)
incq %r12
movslq (%rbx), %rax
cmpq %rax, %r12
jl 0x42ab
movl $0x18, %edi
callq 0x2040
movq %rax, 0x58(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x22e0
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: file_assert(int, char const*)
void file_assert(int error,const char *s){
	if(error == 0) return;
	printf("open %s error\n",s);
	getchar();
	exit(-1);
}

// Assembly:
testl %edi, %edi
jne 0x431b
retq
pushq %rax
leaq 0x61f3(%rip), %rdi      # 0xa516
xorl %eax, %eax
callq 0x2060
callq 0x2250
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2210
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: trace_assert(long, int, unsigned int, int, int)
void trace_assert(int64_t time,int device,unsigned int lsn,int size,int ope)
{
	if(time <0 || device < 0  || size < 0 || ope < 0)
	{
		cout << "trace error: " << time << "  " << device << " " << lsn << " " << size << "  " << ope << endl;
		getchar();
		exit(-1);
	}
	if(time == 0 && device == 0 && lsn == 0 && size == 0 && ope == 0)
	{
		printf("probable read a blank line\n");
		getchar();
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %r15
testq %rdi, %rdi
js 0x438e
movl %ebp, %eax
orl %r12d, %eax
movl %eax, %ecx
orl %ebx, %ecx
js 0x438e
testq %r15, %r15
jne 0x4385
orl %ebx, %r14d
orl %r14d, %eax
jne 0x4385
leaq 0x6200(%rip), %rdi      # 0xa573
callq 0x22a0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2250
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x9c3b(%rip), %rdi      # 0xdfd0
leaq 0x6189(%rip), %rsi      # 0xa525
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x22f0
leaq 0x6180(%rip), %r15      # 0xa533
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movq %rax, %rdi
movl %r12d, %esi
callq 0x22d0
leaq 0x6bfa(%rip), %r12      # 0xafca
movq %rax, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, %rdi
movl %r14d, %esi
callq 0x2240
movq %rax, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, %rdi
movl %ebp, %esi
callq 0x22d0
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movq %rax, %rdi
movl %ebx, %esi
callq 0x22d0
movq %rax, %rdi
callq 0x20c0
callq 0x2250
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2210
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: SubQueue::get_subreq(int)
sub_request * SubQueue::get_subreq(int index){

	if (index < 0) return NULL;
	int temp = 0;
	sub_request * qsub = queue_head;

	while (qsub != NULL) {
		if (temp == index) return qsub;
		qsub = qsub->next_node;
		temp++;
	}

	return NULL;

}

// Assembly:
testl %esi, %esi
sets %cl
movq (%rdi), %rax
testq %rax, %rax
sete %dl
orb %cl, %dl
jne 0x445f
incl %esi
decl %esi
je 0x4461
movq 0x70(%rax), %rax
testq %rax, %rax
jne 0x4452
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: SubQueue::find_subreq(sub_request*)
bool SubQueue::find_subreq(sub_request * sub){
	// is there any request for the same location and same operation (read and write FIXME??? )
	sub_request * qsub = queue_head;

	while (qsub != NULL){

		if (qsub == sub) return true;
		if (qsub->lpn == sub->lpn) return true;
		if (qsub->location->channel == sub->location->channel && qsub->location->lun == sub->location->lun && qsub->location->plane == sub->location->plane){

			if (qsub->location->block == sub->location->block && qsub->location->page == sub->location->page) {
				// FIXME do we need to compare state??
				return true;

			}

		}

		qsub = qsub->next_node;
	}
	return false;
}

// Assembly:
movq (%rdi), %rcx
testq %rcx, %rcx
setne %al
sete %dl
cmpq %rsi, %rcx
sete %dil
orb %dl, %dil
jne 0x44d3
movl 0xc(%rsi), %edx
cmpl %edx, 0xc(%rcx)
je 0x44d3
movq 0x60(%rsi), %rdi
movl (%rdi), %r8d
movq 0x60(%rcx), %r9
cmpl %r8d, (%r9)
jne 0x44ba
movl 0x4(%r9), %r10d
cmpl 0x4(%rdi), %r10d
jne 0x44ba
movl 0x8(%r9), %r10d
cmpl 0x8(%rdi), %r10d
jne 0x44ba
movl 0xc(%r9), %r10d
cmpl 0xc(%rdi), %r10d
jne 0x44ba
movl 0x10(%r9), %r9d
cmpl 0x10(%rdi), %r9d
je 0x44d3
movq 0x70(%rcx), %rcx
testq %rcx, %rcx
setne %al
cmpq %rsi, %rcx
je 0x44d3
testq %rcx, %rcx
je 0x44d3
cmpl %edx, 0xc(%rcx)
jne 0x4489
andb $0x1, %al
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: SubQueue::push_head(sub_request*)
void SubQueue::push_head(sub_request * sub){
	if (sub == NULL) return;

	size++;
	if (queue_tail == NULL){
		queue_head = sub;
		queue_tail = sub;
		return;
	}

	sub->next_node = queue_head;
	queue_head = sub;

}

// Assembly:
testq %rsi, %rsi
je 0x4522
incl 0x10(%rdi)
cmpq $0x0, 0x8(%rdi)
je 0x4518
movq (%rdi), %rax
movq %rax, 0x70(%rsi)
jmp 0x451f
movq %rsi, (%rdi)
addq $0x8, %rdi
movq %rsi, (%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/common.cpp
// Function: SubQueue::target_request(int, int, int)
sub_request * SubQueue::target_request(int plane, int block, int page ){

	sub_request * sub = queue_head;

	while (sub != NULL){
		if (sub->location->plane == plane)
			if (block == -1 || sub->location->block == block )
				if (page == -1 || sub->location->page == page)
					return sub;


		sub = sub->next_node;

	}

	return sub;
}

// Assembly:
movq (%rdi), %rax
testq %rax, %rax
je 0x45a5
movq 0x60(%rax), %rdi
cmpl %esi, 0x8(%rdi)
jne 0x459f
cmpl $-0x1, %edx
je 0x4595
cmpl %edx, 0xc(%rdi)
jne 0x459f
cmpl $-0x1, %ecx
je 0x45a5
cmpl %ecx, 0x10(%rdi)
je 0x45a5
movq 0x70(%rax), %rax
jmp 0x457d
retq
// File: /workspace/github_cpp_makefile_star2_O1/narges64[P]SIMBA/ftl.cpp
// Function: invalid_old_page(ssd_info*, int, local*)
STATE invalid_old_page(ssd_info * ssd, const int lpn, local * location){
	if (ssd->dram->map->map_entry[lpn].state == false) {
		if (ssd->current_time > 0){
			#if DEBUG 
			cout << "error in invalid old page error 1 " << endl;
			#endif 
		}
		return FAIL;
	}
	int old_ppn = ssd->dram->map->map_entry[lpn].pn;
	find_location(ssd, old_ppn, location);
	if( update_physical_page(ssd, old_ppn, -1) == FAIL) {
			cout << "could not update physical page " << endl;
			return FAIL;
	}
	if (update_map_entry(ssd, lpn, -1) == FAIL ) {
		cout << "could not update mapping entry " << endl;
		return FAIL;
	}
	return SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x60(%rdi), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movslq %esi, %r15
shlq $0x4, %r15
xorl %ebx, %ebx
cmpb $0x0, 0x4(%rax,%r15)
je 0x49b9
movq %rdi, %r14
addq %r15, %rax
movl (%rax), %ebp
movl %ebp, %esi
callq 0x4b02
movq %r14, %rdi
movl %ebp, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x60a2
testl %eax, %eax
je 0x4977
movq 0x60(%r14), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movl $0xffffffff, (%rax,%r15) # imm = 0xFFFFFFFF
movb $0x0, 0x4(%rax,%r15)
movq $0x0, 0x8(%rax,%r15)
movl $0x1, %ebx
jmp 0x49b9
movq 0x9652(%rip), %r14      # 0xdfd0
leaq 0x5df9(%rip), %rsi      # 0xa77e
movl $0x1f, %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 %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x18, %edi
callq 0x2190
movq %rax, %rbx
testq %r15, %r15
je 0x49f6
movq (%r15), %rax
movl 0x8(%r15), %ecx
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
jmp 0x4a0f
movq $0x0, (%rbx)
movl $0x0, 0x8(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6258
movzbl %bpl, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x62e9
testl %eax, %eax
je 0x4a31
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6368
movl %eax, %ebp
jmp 0x4a36
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x18, %esi
movq %rbx, %rdi
callq 0x21a0
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
movl $0x18, %edi
callq 0x2190
movq %rax, %rbx
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
movq %r14, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x4b02
movq 0x58(%r14), %rax
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
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
movl $0x18, %esi
movq %rbx, %rdi
callq 0x21a0
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl %edx, %eax
incl %r9d
subl %r10d, %edx
jns 0x4b4c
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_O1/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 0x4b93
movq (%rbx), %rcx
movq %rcx, 0x8(%rax)
movq 0x70(%rbx), %r14
movl 0x14(%r14), %eax
testl %eax, %eax
je 0x4c2c
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 0x4c25
testl %esi, %esi
je 0x4bfa
jmp 0x4c6e
movl 0x4(%r14), %r8d
movl 0x18(%r14), %ecx
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x4c7c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4daf
incl %r15d
cmpl %ebp, %r15d
jbe 0x4bd6
jmp 0x4c6e
movl 0x4(%r14), %r8d
movl 0x18(%r14), %ecx
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x4c7c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4daf
incl %r15d
cmpl %ebp, %r15d
jbe 0x4c01
jmp 0x4c6e
movq 0x939d(%rip), %r14      # 0xdfd0
leaq 0x5a49(%rip), %rsi      # 0xa683
movl $0xa, %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
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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, %r13d
movl %ecx, %r15d
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r14
movl $0xa0, %edi
callq 0x2190
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 0x68b4
testq %r12, %r12
je 0x4ce8
movq 0x30(%r12), %rax
movq %rax, 0x68(%rbx)
movq %rbx, 0x30(%r12)
movl (%r12), %eax
movl %eax, (%rbx)
movl 0x4(%r12), %eax
movl %eax, 0x4(%rbx)
movq (%r14), %rax
subq 0x8(%r12), %rax
jmp 0x4cee
movl %r13d, 0x4(%rbx)
xorl %eax, %eax
movq 0x80(%rbx), %rcx
movq %rax, (%rcx)
movq (%r14), %rax
movq %rax, 0x88(%rbx)
testl %r15d, %r15d
je 0x4d52
cmpl $0x1, %r15d
jne 0x4d62
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 0x4d59
movq 0x60(%rbx), %rdx
movq %r14, %rdi
callq 0x4b02
movq 0x60(%r14), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
cmpb $0x1, 0x4(%rax,%r15)
jne 0x4d59
movl $0x1, 0x40(%rbx)
jmp 0x4d85
movl $0xffffffff, 0x10(%rbx) # imm = 0xFFFFFFFF
movl $0x0, 0x40(%rbx)
jmp 0x4d85
movq %rbx, %rdi
callq 0x66d0
movl $0xa0, %esi
movq %rbx, %rdi
callq 0x21a0
leaq 0x5c71(%rip), %rdi      # 0xa9ef
callq 0x22a0
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 0x21a0
movq %r14, %rdi
callq 0x22e0
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
movslq 0xc(%rsi), %r14
movq 0x60(%rdi), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
shlq $0x4, %r14
xorl %eax, %eax
cmpb $0x0, 0x4(%rcx,%r14)
je 0x51d7
movq %rdi, %rbx
addq %r14, %rcx
movl (%rcx), %ebp
movq 0x60(%rsi), %rdx
movl %ebp, %esi
callq 0x4b02
movq 0x60(%rbx), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movl $0xffffffff, (%rax,%r14) # imm = 0xFFFFFFFF
movb $0x0, 0x4(%rax,%r14)
movq $0x0, 0x8(%rax,%r14)
movq %rbx, %rdi
movl %ebp, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x60a2
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0x51d7
movq 0x8e36(%rip), %rbx      # 0xdfd0
leaq 0x55fd(%rip), %rsi      # 0xa79e
movl $0x8, %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
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
callq 0x20a0
movl %eax, %r14d
movq 0x58(%rbx), %rax
movl 0x98(%rax), %ecx
testl %ecx, %ecx
je 0x525c
xorl %r12d, %r12d
leaq 0xc(%rsp), %r15
leal (%r14,%r12), %eax
xorl %edx, %edx
divl %ecx
movl %edx, %ebp
movl $0x0, 0xc(%rsp)
movq %rbx, %rdi
movl %edx, %esi
callq 0x6d2a
testl %eax, %eax
jne 0x524a
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x526c
cmpl $0x0, 0xc(%rsp)
jne 0x524a
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x55ee
incl %r12d
movq 0x58(%rbx), %rax
movl 0x98(%rax), %ecx
cmpl %ecx, %r12d
jb 0x5209
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x608a
movl %edx, (%rsi)
movb $0x1, (%rdi)
jmp 0x609c
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
movb $0x0, (%rdi)
movq $0x0, 0x8(%rax,%rcx)
movl $0x1, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movq $-0x1, %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_O1/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 %rbx
movq %rdi, %rbx
testq %rsi, %rsi
jne 0x627c
movl $0x18, %edi
callq 0x2190
movq %rax, %rsi
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
movq 0x58(%rbx), %r8
movl 0x14(%rbx), %ecx
leal 0x1(%rcx), %eax
xorl %edx, %edx
divl 0x88(%r8)
movl %edx, %edi
movl %ecx, %eax
xorl %edx, %edx
divl 0x98(%r8)
movl %edi, 0x14(%rbx)
movl %edx, (%rsi)
movslq %edx, %rcx
xorl %edx, %edx
divl 0x9c(%r8,%rcx,4)
movl %edx, 0x4(%rsi)
movq 0x90(%rbx), %rax
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movslq %edx, %rcx
movq (%rax,%rcx,8), %rcx
movl 0x9c(%rcx), %edi
leal 0x1(%rdi), %eax
xorl %edx, %edx
divl 0x22c(%r8)
movl %edx, 0x9c(%rcx)
movl %edi, 0x8(%rsi)
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x630e
callq 0x644e
jmp 0x6313
callq 0x652d
cmpl $-0x1, %eax
je 0x635c
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)
movl $0x1, %eax
jmp 0x635e
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq