LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/akgupta007[P]DBMS-query-processing-Algotihms/check.cpp
// Function: checkPage(std::__cxx11::list<int, std::allocator<int>>, char*)
list<int> checkPage(list<int> lst, char* pageData){
	int n;
	int num = lst.front();
	list<int> position;
	int i = 0;
	for(; i< PAGE_CONTENT_SIZE/sizeof(int); i++){
		memcpy (&n, &pageData[i*sizeof(int)], sizeof(int));
		if (n == INT_MIN){
			break;
		}
		if (n > num){
			lst.pop_front();
			position.push_back(i);
			i--;
			if(lst.empty()){
				break;
			}
			num = lst.front();
		}
	}
	while( !lst.empty() ){
		position.push_back(i);
		lst.pop_front();
	}
	return position;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %r12
movl 0x10(%r12), %eax
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
movq $0x0, 0x10(%rdi)
xorl %r13d, %r13d
movl %r13d, %ecx
movl (%r15,%rcx,4), %ecx
movl %ecx, %edx
negl %edx
jo 0x3f75
cmpl %eax, %ecx
jle 0x3f69
decq 0x10(%r14)
movq %r12, %rdi
callq 0x2230
movq %r12, %rdi
callq 0x2180
movl $0x18, %edi
callq 0x21b0
movl %r13d, 0x10(%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
incq 0x10(%rbx)
movq (%r14), %r12
cmpq %r14, %r12
je 0x3fb3
decl %r13d
movl 0x10(%r12), %eax
incl %r13d
cmpl $0x3ff, %r13d           # imm = 0x3FF
jb 0x3f17
cmpq %r14, %r12
je 0x3fb3
movl $0x18, %edi
callq 0x21b0
movl %r13d, 0x10(%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2050
incq 0x10(%rbx)
movq (%r14), %r15
decq 0x10(%r14)
movq %r15, %rdi
callq 0x2230
movq %r15, %rdi
callq 0x2180
cmpq %r14, (%r14)
jne 0x3f7a
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3fc7
movq %rax, %r14
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x3fe2
movq (%rdi), %r15
callq 0x2180
movq %r15, %rdi
cmpq %rbx, %r15
jne 0x3fd2
movq %r14, %rdi
callq 0x2280
// File: /workspace/github_cpp_makefile_star2_O3/akgupta007[P]DBMS-query-processing-Algotihms/check.cpp
// Function: InsertValue(int, int, int, FileHandler&)
void InsertValue(int num, int position, int pageNo, FileHandler &fh){
	try{
		PageHandler ph = fh.PageAt(pageNo);
		bool pin = fh.MarkDirty(pageNo);
		char *pageData = ph.GetData();
		int n;
		int max_data = PAGE_CONTENT_SIZE/sizeof(int);
		for(int i = position; i< max_data; i++){
			memcpy (&n, &pageData[i*sizeof(int)], sizeof(int));
			if( n == INT_MIN ){
				if (i == max_data -1){
					fh.UnpinPage(pageNo);
					InsertValue(num, 0, pageNo + 1, fh);
					return;
				}
				else {
					memcpy (&pageData[i*sizeof(int)], &num, sizeof(int));
					memcpy (&pageData[(i+1)*sizeof(int)], &n, sizeof(int));
					break;
				}
			}
			memcpy (&pageData[i*sizeof(int)], &num, sizeof(int));
			num = n;
		}
		return;
	}
	catch(InvalidPageException args){
		//create New Page
		PageHandler ph = fh.NewPage();
		char *pageData = ph.GetData();
		int m = INT_MIN;
		memcpy (&pageData[0], &m, sizeof(int));
		InsertValue(num, 0, ph.GetPageNum(), fh);
		return;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rcx, %rbx
movl %edx, %r15d
movl %esi, %r12d
movl %edi, %r14d
leaq -0x38(%rbp), %rdi
movq %rcx, %rsi
callq 0x37f0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x396e
leaq -0x38(%rbp), %rdi
callq 0x3638
cmpl $0x3fe, %r12d           # imm = 0x3FE
jg 0x40ab
movabsq $0x100000000, %rsi      # imm = 0x100000000
movslq %r12d, %rdx
movq %rdx, %rcx
shlq $0x20, %rcx
addq %rsi, %rcx
incq %rdx
movl -0x4(%rax,%rdx,4), %edi
movl %edi, %r8d
negl %r8d
jo 0x4072
movl %r14d, -0x4(%rax,%rdx,4)
addq %rsi, %rcx
movq %rdx, %r8
incq %r8
movl %edi, %r14d
cmpl $0x3ff, %edx            # imm = 0x3FF
movq %r8, %rdx
jne 0x4048
jmp 0x40ab
cmpq $0x3ff, %rdx            # imm = 0x3FF
jne 0x409b
movq %rbx, %rdi
movl %r15d, %esi
callq 0x38a8
incl %r15d
movl %r14d, %edi
xorl %esi, %esi
movl %r15d, %edx
movq %rbx, %rcx
callq 0x3fea
jmp 0x40ab
movl %r14d, -0x4(%rax,%rdx,4)
sarq $0x1e, %rcx
movl $0x80000000, (%rax,%rcx) # imm = 0x80000000
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x40be
jmp 0x40be
jmp 0x40be
movq %rax, %r15
cmpl $0x1, %edx
jne 0x4139
movq %r15, %rdi
callq 0x21e0
leaq 0x3c73(%rip), %rax      # 0x7d48
movq %rax, -0x28(%rbp)
movq %r15, %rdi
callq 0x20b0
leaq -0x38(%rbp), %rdi
movq %rbx, %rsi
callq 0x38c2
leaq -0x38(%rbp), %rdi
callq 0x3638
movl $0x80000000, (%rax)     # imm = 0x80000000
leaq -0x38(%rbp), %rdi
callq 0x3642
movl %r14d, %edi
xorl %esi, %esi
movl %eax, %edx
movq %rbx, %rcx
callq 0x3fea
leaq -0x28(%rbp), %rdi
callq 0x22c8
callq 0x2240
jmp 0x40ab
jmp 0x4128
jmp 0x4128
movq %rax, %r15
leaq -0x28(%rbp), %rdi
callq 0x22c8
callq 0x2240
movq %r15, %rdi
callq 0x2280
movq %rax, %rdi
callq 0x313c
// File: /workspace/github_cpp_makefile_star2_O3/akgupta007[P]DBMS-query-processing-Algotihms/check.cpp
// Function: PrintPage(PageHandler)
void PrintPage(PageHandler ph){
	char* data = ph.GetData ();
	int temp_num;
	// Output the all integers
	for(int i=0; i<1022 ; i++){
		memcpy (&temp_num, &data[i*4], sizeof(int));
		cout << i<< "th number: " << temp_num << endl;
		if(temp_num == INT_MIN) break;
	}
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x3638
movq %rax, %rbx
xorl %r14d, %r14d
leaq 0x1254(%rip), %r12      # 0x53bd
movl (%rbx,%r14,4), %r13d
movq 0x3e5c(%rip), %rdi      # 0x7fd0
movl %r14d, %esi
callq 0x2270
movq %rax, %r15
movl $0xb, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x21c0
movq %r15, %rdi
movl %r13d, %esi
callq 0x2270
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
negl %r13d
jo 0x41d9
leaq 0x1(%r14), %rax
cmpq $0x3fd, %r14            # imm = 0x3FD
movq %rax, %r14
jne 0x4169
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/akgupta007[P]DBMS-query-processing-Algotihms/check.cpp
// Function: main
int main(int argc, char* argv[]) {
	//read input file
	
	FileManager fm;
	FileHandler fh;
	
	// Reopen the same file, but for reading this time
	fh = fm.OpenFile (argv[1]);
	
	PageHandler ph_last = fh.LastPage ();
	int total_pages = ph_last.GetPageNum ()+1;
	for(int i = 0; i<total_pages; i++){
		cout<< "Page : "<<i <<endl;
		ph_last = fh.PageAt(i);
		PrintPage(ph_last);
		fh.UnpinPage(i);
	}
	cout<<total_pages<<endl;
	fh.FlushPages();
	fm.CloseFile (fh);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
leaq -0x30(%rbp), %rdi
callq 0x3aae
leaq -0x70(%rbp), %rdi
callq 0x364a
movq 0x8(%rbx), %rdx
leaq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3c14
leaq -0x50(%rbp), %rdi
movups (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
leaq -0x70(%rbp), %rsi
movaps %xmm1, 0x10(%rsi)
movaps %xmm0, (%rsi)
callq 0x374c
leaq -0x50(%rbp), %rdi
callq 0x3642
leal 0x1(%rax), %ebx
testl %eax, %eax
js 0x4955
xorl %r14d, %r14d
leaq -0x70(%rbp), %r12
leaq -0x90(%rbp), %r13
movl $0x7, %edx
movq 0x3702(%rip), %rdi      # 0x7fd0
leaq 0xaf4(%rip), %rsi       # 0x53c9
callq 0x21c0
movq 0x36ef(%rip), %rdi      # 0x7fd0
movl %r14d, %esi
callq 0x2270
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
leaq -0x80(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0x37f0
movups -0x80(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r13, %rdi
leaq -0x50(%rbp), %rsi
callq 0x360c
movq %r13, %rdi
callq 0x4149
movq %r12, %rdi
movl %r14d, %esi
callq 0x38a8
incl %r14d
cmpl %r14d, %ebx
jne 0x48c2
movq 0x3674(%rip), %rdi      # 0x7fd0
movl %ebx, %esi
callq 0x2270
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
leaq -0x70(%rbp), %rdi
callq 0x3a04
leaq -0x30(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3cdc
leaq -0x30(%rbp), %rdi
callq 0x3b2a
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x49c7
jmp 0x49c7
jmp 0x49c7
jmp 0x49c7
jmp 0x49c7
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x3b2a
movq %rbx, %rdi
callq 0x2280
nop
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/server_fail.cpp
// Function: server_shutdown(int)
void server_shutdown (int s)
{
    (void) s;
    cout << "\n";
    cout << "Initiating Server Shutdown...\n";
    cout << "Closing All Connections... ";
    site.close ();
    cout << "\nAll Connections Closed. Exiting...\n\n";
    exit (EXIT_SUCCESS);
}

// Assembly:
pushq %rbx
movq 0x979c(%rip), %rbx      # 0xbfd0
leaq 0x69b9(%rip), %rsi      # 0x91f4
movq %rbx, %rdi
callq 0x2250
leaq 0x67de(%rip), %rsi      # 0x9028
movq %rbx, %rdi
callq 0x2250
leaq 0x67ee(%rip), %rsi      # 0x9047
movq %rbx, %rdi
callq 0x2250
leaq 0x99b0(%rip), %rdi      # 0xc218
callq 0x6a00
leaq 0x67ef(%rip), %rsi      # 0x9063
movq %rbx, %rdi
callq 0x2250
xorl %edi, %edi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/socket.cpp
// Function: Socket::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
int Socket::connect (string host, int port)
{
    /* Creating the socket. */
    if ((socketFD = socket (AF_INET, SOCK_STREAM, 0)) < 0)
    {
        int errsv = errno;
        std::cerr << "Cannot Create Socket, Error ";
        std::cerr << errsv << "\n";
        exit (1);
    }
    /* Determining server's IP address. */
    stringstream s1;
    s1 << port;
    int status;
    addrinfo hints;
    addrinfo* servinfo;
    memset (&hints, 0, sizeof (hints));
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;
    if ((status = getaddrinfo (host.c_str (), s1.str ().c_str (), &hints,
                               &servinfo)) != 0)
        return -1;

    /* Connecting to the server. */
    return ::connect (socketFD, servinfo->ai_addr, servinfo->ai_addrlen);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x1f0, %rsp            # imm = 0x1F0
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2080
movl %eax, (%rbx)
testl %eax, %eax
js 0x66b8
leaq 0x68(%rsp), %rdi
callq 0x2190
leaq 0x78(%rsp), %rdi
movl %ebp, %esi
callq 0x23b0
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x50(%rsp)
movabsq $0x100000002, %rax      # imm = 0x100000002
movq %rax, 0x34(%rsp)
movq (%r14), %r14
leaq 0x80(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x2390
movq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r14, %rdi
callq 0x2330
movl %eax, %r14d
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x666d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2270
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %r14d, %r14d
jne 0x668c
movl (%rbx), %edi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
movl 0x10(%rax), %edx
callq 0x21f0
movl %eax, %ebp
movq 0x5925(%rip), %rsi      # 0xbfb8
leaq 0x68(%rsp), %rdi
callq 0x21c0
leaq 0xe8(%rsp), %rdi
callq 0x20d0
movl %ebp, %eax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbx
popq %r14
popq %rbp
retq
callq 0x2050
movl (%rax), %ebx
movq 0x592a(%rip), %r14      # 0xbff0
leaq 0x2cbc(%rip), %rsi      # 0x9389
movq %r14, %rdi
callq 0x2250
movq %r14, %rdi
movl %ebx, %esi
callq 0x23b0
leaq 0x2b0e(%rip), %rsi      # 0x91f4
movq %rax, %rdi
callq 0x2250
movl $0x1, %edi
callq 0x22f0
jmp 0x671c
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x671f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x671f
jmp 0x671c
movq %rax, %rbx
movq 0x5892(%rip), %rsi      # 0xbfb8
leaq 0x68(%rsp), %rdi
callq 0x21c0
leaq 0xe8(%rsp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x23c0
nop
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/socket.cpp
// Function: Socket::recv[abi:cxx11](unsigned long)
string Socket::recv (size_t len)
{
    char* recv_buf = new char[len + 1];
    int recv_len = ::recv (socketFD, recv_buf, len, 0);
    if (recv_len < 0)
        return string ("");
    recv_buf[recv_len] = '\0';
    return string (recv_buf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x1(%rdx), %rdi
callq 0x2030
movq %rax, %r14
movl (%r12), %edi
movq %rax, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x20c0
testl %eax, %eax
js 0x67bd
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%r14,%rax)
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x2100
movq %r14, %rdx
addq %rax, %rdx
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x67d1
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2a2a(%rip), %rdx      # 0x91f5
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x5d0e
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/socket.cpp
// Function: Socket::bind(int)
int Socket::bind (int port)
{
    /* Creating the socket. */
    if ((socketFD = socket (AF_INET, SOCK_STREAM, 0)) < 0)
    {
        int errsv = errno;
        std::cerr << "Cannot Create Socket, Error ";
        std::cerr << errsv << "\n";
        exit (1);
    }
    sockaddr_in myaddr;
    memset ((char*)&myaddr, 0, sizeof(myaddr));
    myaddr.sin_family = AF_INET;
    myaddr.sin_addr.s_addr = htonl (INADDR_ANY);
    myaddr.sin_port = htons (port);
    return ::bind (socketFD, (sockaddr *)&myaddr, sizeof (myaddr));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2080
movl %eax, (%r14)
testl %eax, %eax
js 0x6849
leaq 0x8(%rsp), %rsi
movq $0x0, 0x8(%rsi)
movw $0x2, (%rsi)
movl $0x0, 0x4(%rsi)
rolw $0x8, %bx
movw %bx, 0x2(%rsi)
movl %eax, %edi
movl $0x10, %edx
callq 0x2060
addq $0x18, %rsp
popq %rbx
popq %r14
retq
callq 0x2050
movl (%rax), %ebx
movq 0x5799(%rip), %r14      # 0xbff0
leaq 0x2b2b(%rip), %rsi      # 0x9389
movq %r14, %rdi
callq 0x2250
movq %r14, %rdi
movl %ebx, %esi
callq 0x23b0
leaq 0x297d(%rip), %rsi      # 0x91f4
movq %rax, %rdi
callq 0x2250
movl $0x1, %edi
callq 0x22f0
nop
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/socket.cpp
// Function: Socket::getSourceAddr[abi:cxx11]()
string Socket::getSourceAddr ()
{
    char src[INET_ADDRSTRLEN];
    sockaddr_storage tmp;
    socklen_t addr_size = sizeof (sockaddr);
    getsockname (socketFD, (sockaddr*)&tmp, &addr_size);
    sockaddr_in* src_addr = (sockaddr_in*)&tmp;
    inet_ntop (AF_INET, &src_addr->sin_addr, src, sizeof (src));
    return string (src);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0xc(%rsp), %rdx
movl $0x10, (%rdx)
movl (%rsi), %edi
leaq 0x28(%rsp), %rsi
callq 0x2220
leaq 0x2c(%rsp), %rsi
leaq 0x10(%rsp), %r14
movl $0x2, %edi
movq %r14, %rdx
movl $0x10, %ecx
callq 0x22b0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x2100
leaq (%rsp,%rax), %rdx
addq $0x10, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5d0e
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/socket.cpp
// Function: Socket::enableBlocking()
int Socket::enableBlocking ()
{
    if (socketFD < 0 && blockingEnabled)
        return -1;

    int flags;
    if ((flags = fcntl (socketFD, F_GETFL, 0)) < 0)
        return -1;

    int rval = fcntl (socketFD, F_SETFL, flags | O_NONBLOCK);
    if (rval < 0)
        return rval;
    else
        blockingEnabled = false;

    return rval;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
testl %edi, %edi
jns 0x6a2f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x0, 0x4(%rbx)
jne 0x6a65
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2140
testl %eax, %eax
js 0x6a60
movl (%rbx), %edi
orl $0x800, %eax            # imm = 0x800
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x2140
testl %eax, %eax
js 0x6a65
movb $0x0, 0x4(%rbx)
jmp 0x6a65
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/socket.cpp
// Function: Socket::disableBlocking()
int Socket::disableBlocking ()
{
    if (socketFD < 0 && (!blockingEnabled))
        return -1;

    int flags;
    if ((flags = fcntl (socketFD, F_GETFL, 0)) < 0)
        return -1;

    int rval = fcntl (socketFD, F_SETFL, flags & (~O_NONBLOCK));
    if (rval < 0)
        return rval;
    else
        blockingEnabled = true;

    return rval;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
testl %edi, %edi
jns 0x6a7d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x1, 0x4(%rbx)
jne 0x6ab3
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2140
testl %eax, %eax
js 0x6aae
movl (%rbx), %edi
andl $0x7ffff7ff, %eax       # imm = 0x7FFFF7FF
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x2140
testl %eax, %eax
js 0x6ab3
movb $0x1, 0x4(%rbx)
jmp 0x6ab3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/message.cpp
// Function: split(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, char, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&)
void split(const std::string& line, char delim, std::vector<std::string>& val) {
    std::string::size_type i = 0;
    std::string::size_type j = line.find (delim);

    while (j != std::string::npos)
    {
        val.push_back (line.substr (i, j-i));
        i = ++j;
        j = line.find (delim, j);

        if (j == std::string::npos)
            val.push_back (line.substr (i, line.length ()));
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
xorl %edx, %edx
callq 0x2340
cmpq $-0x1, %rax
je 0x6b83
movq %rax, %r15
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
movsbl %bpl, %ebp
movq %r15, %rcx
subq %r13, %rcx
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2290
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7022
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6b29
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2270
movq %r15, %r13
incq %r13
movq %r14, %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0x2340
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x6aee
movq 0x8(%r14), %rcx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2290
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7022
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6b83
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2270
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6b94
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6bb3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2270
movq %rbx, %rdi
callq 0x23c0
nop
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/message.cpp
// Function: Message::parseMessage()
void Message::parseMessage ()
{
    std::vector<std::string> m_parsed;
    split (message_str, DELIM, m_parsed);
    this->message = messageIndex (m_parsed[0]);
    this->transaction_id = std::stoi (m_parsed[1]);
    this->site_id = std::stoi (m_parsed[2]);
    this->failed_id = std::stoi (m_parsed[3]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
addq $0x10, %rdi
movl $0x2c, %esi
callq 0x6ab8
movq 0x10(%rsp), %rax
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x5c78
leaq 0x28(%rsp), %rbx
movq %rbx, %rsi
callq 0x6f60
movl %eax, (%r14)
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0x6cd1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2270
movq 0x10(%rsp), %rax
movq 0x20(%rax), %r15
callq 0x2050
movq %rax, %rbx
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x2350
cmpq %r15, (%r12)
je 0x6deb
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x6df7
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x6df7
testl %ecx, %ecx
jne 0x6d26
movl %ebp, (%rbx)
movl %eax, 0x4(%r14)
movq 0x10(%rsp), %rax
movq 0x40(%rax), %r15
movl (%rbx), %ebp
movl $0x0, (%rbx)
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x2350
cmpq %r15, (%r12)
je 0x6e03
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x6e0f
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x6e0f
testl %ecx, %ecx
jne 0x6d85
movl %ebp, (%rbx)
movl %eax, 0x8(%r14)
movq 0x10(%rsp), %rax
movq 0x60(%rax), %r15
movl (%rbx), %ebp
movl $0x0, (%rbx)
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x2350
cmpq %r15, (%r12)
je 0x6e1b
leaq -0x80000000(%rax), %rcx
cmpq %r13, %rcx
jb 0x6e27
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x6e27
testl %ecx, %ecx
jne 0x6dce
movl %ebp, (%rbx)
movl %eax, 0xc(%r14)
leaq 0x10(%rsp), %rdi
callq 0x6fc4
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2567(%rip), %rdi      # 0x9359
callq 0x2160
leaq 0x255b(%rip), %rdi      # 0x9359
callq 0x2360
leaq 0x254f(%rip), %rdi      # 0x9359
callq 0x2160
leaq 0x2543(%rip), %rdi      # 0x9359
callq 0x2360
leaq 0x2537(%rip), %rdi      # 0x9359
callq 0x2160
leaq 0x252b(%rip), %rdi      # 0x9359
callq 0x2360
jmp 0x6e37
jmp 0x6e37
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x6e46
movl %ebp, (%rbx)
jmp 0x6e46
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x6fc4
movq %r14, %rdi
callq 0x23c0
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/message.cpp
// Function: Message::createMessage[abi:cxx11]()
std::string Message::createMessage ()
{
    std::stringstream s;
    s << message_strings[message] << DELIM << transaction_id;
    s << DELIM << site_id << DELIM << failed_id;
    return s.str ();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2190
leaq 0x18(%rsp), %r15
movl (%r14), %eax
shlq $0x5, %rax
leaq 0x53b9(%rip), %rcx      # 0xc240
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r15, %rdi
callq 0x22d0
leaq 0x7(%rsp), %rsi
movb $0x2c, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x22d0
movl 0x4(%r14), %esi
movq %rax, %rdi
callq 0x23b0
leaq 0x7(%rsp), %rsi
movb $0x2c, (%rsi)
movl $0x1, %edx
movq %r15, %rdi
callq 0x22d0
movl 0x8(%r14), %esi
movq %rax, %rdi
callq 0x23b0
leaq 0x7(%rsp), %rsi
movb $0x2c, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x22d0
movl 0xc(%r14), %esi
movq %rax, %rdi
callq 0x23b0
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x2390
movq 0x50a9(%rip), %rsi      # 0xbfb8
leaq 0x8(%rsp), %rdi
callq 0x21c0
leaq 0x88(%rsp), %rdi
callq 0x20d0
movq %rbx, %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x5078(%rip), %rsi      # 0xbfb8
leaq 0x8(%rsp), %rdi
callq 0x21c0
leaq 0x88(%rsp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x23c0
nop
// File: /workspace/github_cpp_makefile_star2_O3/rohitrangan[P]3PC/src/message.cpp
// Function: Message::messageIndex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
message_id Message::messageIndex (std::string message_str)
{
    for (int i = 0; i < NUM_MESSAGES; ++i)
    {
        if (message_strings[i] == message_str)
            return (message_id) i;
    }
    return ERROR;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq 0x8(%rsi), %r14
leaq 0x52d2(%rip), %r12      # 0xc248
xorl %r15d, %r15d
cmpq %r14, (%r12)
jne 0x6f98
testq %r14, %r14
je 0x6fab
movq (%rbx), %rsi
movq -0x8(%r12), %rdi
movq %r14, %rdx
callq 0x2280
testl %eax, %eax
je 0x6fab
incq %r15
addq $0x20, %r12
cmpq $0xa, %r15
jne 0x6f79
movl $0xa, %r15d
cmpl $0x9, %r15d
movl $0x9, %eax
cmovbl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/amukherj[P]concurrencyts/./barrier.h
// Function: concurrencyts::barrier_base<concurrencyts::flex_barrier>::arrive_and_wait()
void arrive_and_wait() {
    std::unique_lock<std::mutex> ul{lock};
    allow.wait(ul, [this]()->bool { return count > 0; });
  
    if (--count == 0) {
      ul.unlock();

      auto ffunc = static_cast<T*>(this)->final_func();
      if (ffunc) {
        // run the completion block
        auto tmp_count = ffunc();
        if (tmp_count >= 0) {
          // readjust max_count for next phase of barrier.
          max_count = tmp_count;
        }
      }

      // release all waiting threads
      done.notify_all();
    } else {
      done.wait(ul, [this]()->bool { return count == 0; });
      ul.unlock();
    }
  
    ul.lock();
    if (++released_count == max_count) {
      count = max_count;
      released_count = 0;
      ul.unlock();
      // allow all waiting threads
      allow.notify_all();
    }
  }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x8(%rdi), %rax
leaq 0x8(%rsp), %rbx
movq %rax, (%rbx)
movb $0x0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x280c
movb $0x1, 0x8(%rbx)
leaq 0x30(%r14), %rbx
movq 0x90(%r14), %rax
testq %rax, %rax
jne 0x2708
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2050
movq 0x90(%r14), %rax
testq %rax, %rax
je 0x26f1
decq %rax
movq %rax, 0x90(%r14)
je 0x273e
leaq 0x60(%r14), %r15
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2050
cmpq $0x0, 0x90(%r14)
jne 0x271d
leaq 0x8(%rsp), %rdi
callq 0x27e4
jmp 0x2768
leaq 0x8(%rsp), %rdi
callq 0x27e4
movq 0xa0(%r14), %rax
testq %rax, %rax
je 0x275f
callq *%rax
testl %eax, %eax
js 0x275f
movl %eax, %eax
movq %rax, (%r14)
leaq 0x60(%r14), %rdi
callq 0x2130
leaq 0x8(%rsp), %rdi
callq 0x280c
movq 0x98(%r14), %rax
incq %rax
movq %rax, 0x98(%r14)
cmpq (%r14), %rax
jne 0x27ac
movq %rax, 0x90(%r14)
movq $0x0, 0x98(%r14)
leaq 0x8(%rsp), %rdi
callq 0x27e4
movq %rbx, %rdi
callq 0x2130
leaq 0x8(%rsp), %rdi
callq 0x2848
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x27c4
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2848
movq %rbx, %rdi
callq 0x2170
// File: /workspace/github_cpp_makefile_star2_O3/ArashPartow[P]exprtk-extras/exprtk_vector_benchmark.cpp
// Function: main
int main(int argc, char* argv[])
{
   const std::size_t vec_size  = ((argc >= 2) ? atoi(argv[1]) : 100000);
   const std::string file_name = ((argc >  3) ? argv[2] : ""          );

   switch (argc)
   {
      case 2 : run_benchmark     <numeric_type>(vec_size          ); break;
      case 3 : run_file_benchmark<numeric_type>(vec_size,file_name); break;
   }

   return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl %edi, %ebx
cmpl $0x1, %edi
jle 0x11b578
movq %rsi, %r14
movq 0x8(%rsi), %rdi
callq 0x116190
cltq
movq %rax, 0x10(%rsp)
cmpl $0x4, %ebx
jb 0x11b581
movq 0x10(%r14), %rsi
jmp 0x11b588
movq $0x186a0, 0x10(%rsp)    # imm = 0x186A0
leaq 0x19773f(%rip), %rsi    # 0x2b2cc7
leaq 0x18(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x11b6a6
cmpl $0x3, %ebx
je 0x11b5ad
cmpl $0x2, %ebx
jne 0x11b5bc
leaq 0x10(%rsp), %rdi
callq 0x11b6e3
jmp 0x11b5bc
leaq 0x10(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x11b79a
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11b5d7
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x1160c0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11b5ff
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x1160c0
movq %rbx, %rdi
callq 0x116330
// File: /workspace/github_cpp_makefile_star2_O3/ArashPartow[P]exprtk-extras/exprtk_vector_benchmark.cpp
// Function: void run_benchmark<double>(unsigned long const&)
void run_benchmark(const std::size_t& vec_size)
{
   T total_time = 0.0;

   for (std::size_t i = 0; i < global_expression_list_size; ++i)
   {
      total_time +=
      run_expression_benchmark<T>(vec_size,
                                  global_expression_list[i].e,
                                  global_expression_list[i].cost);
   }

   unsigned long long total_flops = 0;

   for (std::size_t i = 0; i < global_expression_list_size; ++i)
   {
      total_flops += global_expression_list[i].cost;
   }

   total_flops *= (rounds * vec_size);

   printf("Total Time:%10.7f FLOP: %llu Perf: %7.4fGFLOPS\n",
          total_time,
          total_flops,
          total_flops / (1e9 * total_time));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
xorpd %xmm2, %xmm2
movl $0x28, %r15d
leaq 0x2f8710(%rip), %r14    # 0x413e10
movsd %xmm2, 0x8(%rsp)
movq (%rbx), %rdi
leaq 0x8(%r14), %rsi
movq %r14, %rdx
callq 0x11ba87
movsd 0x8(%rsp), %xmm2
addsd %xmm0, %xmm2
addq $0x28, %r14
decq %r15
jne 0x11b700
xorl %eax, %eax
leaq 0x2f86df(%rip), %rdx    # 0x413e10
xorl %ecx, %ecx
addq (%rax,%rdx), %rcx
addq $0x28, %rax
cmpq $0x640, %rax            # imm = 0x640
jne 0x11b733
imulq (%rbx), %rcx
imulq $0x7d0, %rcx, %rsi      # imm = 0x7D0
movq %rsi, %xmm0
punpckldq 0x1928b5(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1928bd(%rip), %xmm0   # 0x2ae020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x192969(%rip), %xmm0   # 0x2ae0e0
mulsd %xmm2, %xmm0
divsd %xmm0, %xmm1
leaq 0x197512(%rip), %rdi    # 0x2b2c98
movapd %xmm2, %xmm0
movb $0x2, %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x116080
// File: /workspace/github_cpp_makefile_star2_O3/ArashPartow[P]exprtk-extras/exprtk_vector_benchmark.cpp
// Function: void run_file_benchmark<double>(unsigned long const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void run_file_benchmark(const std::size_t& vec_size, const std::string& file_name)
{
   std::ifstream stream(file_name.c_str());

   if (!stream)
   {
      printf("run_file_benchmark() - Failed to open file: %s\n",
             file_name.c_str());
      return;
   }

   std::string line;
   std::vector<std::string> expr_list;

   while (std::getline(stream, line))
   {
      if (line.empty())
         continue;
      else if ('#' == line[0])
         continue;

      expr_list.push_back(line);
   }

   T total_time = T(0);

   for (std::size_t i = 0; i < expr_list.size(); ++i)
   {
      total_time += run_expression_benchmark<T>(vec_size,expr_list[i],0);
   }

   printf("Total Time:%10.7f\n", total_time);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x250, %rsp            # imm = 0x250
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rsi
leaq 0x48(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x116050
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
je 0x11b7e9
movq (%r14), %rsi
leaq 0x19c21a(%rip), %rdi    # 0x2b79f7
xorl %eax, %eax
callq 0x116080
jmp 0x11b901
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
xorl %ecx, %ecx
movq %rcx, -0x8(%r13)
movb $0x0, (%r13)
movq %rsp, %r14
movq %rcx, 0x10(%r14)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r14)
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq (%rsp,%rax), %rdi
addq $0x48, %rdi
movl $0xa, %esi
callq 0x116520
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x116030
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x11b86d
cmpq $0x0, 0x30(%rsp)
je 0x11b862
movq 0x28(%rsp), %rax
cmpb $0x23, (%rax)
je 0x11b862
movq %r14, %rdi
movq %r12, %rsi
callq 0x277524
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
jmp 0x11b817
movq (%rsp), %rsi
cmpq %rsi, 0x8(%rsp)
je 0x11b8d0
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
leaq 0x20(%rsp), %r14
xorl %r12d, %r12d
movsd %xmm0, 0x18(%rsp)
movq (%rbx), %rdi
addq %r15, %rsi
movq $0x0, 0x20(%rsp)
movq %r14, %rdx
callq 0x11ba87
movsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
incq %r12
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
addq $0x20, %r15
cmpq %rax, %r12
jb 0x11b887
jmp 0x11b8d4
xorpd %xmm0, %xmm0
leaq 0x19c14c(%rip), %rdi    # 0x2b7a27
movb $0x1, %al
callq 0x116080
movq %rsp, %rdi
callq 0x1864e0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11b901
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x1160c0
leaq 0x48(%rsp), %rdi
callq 0x116040
addq $0x250, %rsp            # imm = 0x250
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x11b91e
movq %rax, %rbx
movq %rsp, %rdi
callq 0x1864e0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11b940
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x1160c0
leaq 0x48(%rsp), %rdi
callq 0x116040
movq %rbx, %rdi
callq 0x116330
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_mem_ram.cpp
// Function: mips_mem_create_ram
mips_mem_h mips_mem_create_ram(
                                          uint32_t cbMem	//!< Total number of bytes of ram
){
    if(cbMem>0x20000000){
        return 0; // No more than 512MB of RAM
    }
    
    uint8_t *data=(uint8_t*)malloc(cbMem);
    if(data==0)
        return 0;
    
    struct mips_mem_provider *mem=(struct mips_mem_provider*)malloc(sizeof(struct mips_mem_provider));
    if(mem==0){
        free(data);
        return 0;
    }
    
    mem->length=cbMem;
    mem->data=data;
    
    return mem;
}

// Assembly:
cmpl $0x20000000, %edi       # imm = 0x20000000
jbe 0x4a9f
xorl %eax, %eax
retq
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl %edi, %edi
callq 0x3290
testq %rax, %rax
je 0x4ad3
movq %rax, %r14
movl $0x10, %edi
callq 0x3290
testq %rax, %rax
je 0x4acb
movl %ebx, (%rax)
movq %r14, 0x8(%rax)
jmp 0x4ad5
movq %r14, %rdi
callq 0x3230
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/shared/mips_mem_ram.cpp
// Function: mips_mem_read_write(bool, mips_mem_provider*, unsigned int, unsigned int, unsigned char*)
static mips_error mips_mem_read_write(
                                      bool write,
                                      mips_mem_h mem,
                                      uint32_t address,
                                      uint32_t length,
                                      uint8_t *dataOut
                                      )
{
    if(mem==0){
        return mips_ErrorInvalidHandle;
    }
    
    if( (length!=1) && (length!=2) && (length!=4) ){
        return mips_ExceptionInvalidLength;
    }
    
    if(0 != (address % length) ){
        return mips_ExceptionInvalidAlignment;
    }
    if(((address+length) > mem->length) || (address > (UINT32_MAX - length))){	// A subtle bug here, maybe?
        return mips_ExceptionInvalidAddress;
    }
    
    if(write){
        for(unsigned i=0; i<length; i++){
            mem->data[address+i]=dataOut[i];
        }
    }else{
        for(unsigned i=0; i<length; i++){
            dataOut[i]=mem->data[address+i];
        }
    }
    return mips_Success;
}

// Assembly:
testq %rsi, %rsi
je 0x4b18
movl $0x2001, %eax           # imm = 0x2001
cmpl $0x4, %ecx
ja 0x4b17
movl %edx, %r9d
movl $0x16, %edx
btl %ecx, %edx
jae 0x4b17
movl %r9d, %eax
xorl %edx, %edx
divl %ecx
movl $0x2003, %eax           # imm = 0x2003
testl %edx, %edx
je 0x4b1e
retq
movl $0x1002, %eax           # imm = 0x1002
retq
movl %ecx, %edx
movl $0x2002, %eax           # imm = 0x2002
addl %r9d, %edx
jb 0x4b17
cmpl (%rsi), %edx
ja 0x4b17
movl %ecx, %ecx
movl %r9d, %edx
xorl %eax, %eax
testb %dil, %dil
je 0x4b56
xorl %edi, %edi
movb (%r8,%rdi), %r9b
movq 0x8(%rsi), %r10
leal (%rdx,%rdi), %r11d
movb %r9b, (%r10,%r11)
incq %rdi
cmpq %rdi, %rcx
jne 0x4b3c
jmp 0x4b17
xorl %edi, %edi
movq 0x8(%rsi), %r9
leal (%rdx,%rdi), %r10d
movb (%r9,%r10), %r9b
movb %r9b, (%r8,%rdi)
incq %rdi
cmpq %rdi, %rcx
jne 0x4b58
jmp 0x4b17
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: mips_cpu_create
mips_cpu_h mips_cpu_create(mips_mem_h mem){
	if (mem==0)
		return NULL;

	mips_cpu_h state = new mips_cpu_impl;
	state->hi = 0;
	state->lo = 0;
	state->pc = 0;
	state->pcN = 4;
	state->mem=mem;
	for (unsigned i = 0; i < 32; ++i)
		state->regs[i]=0;

	return state;
}

// Assembly:
testq %rdi, %rdi
je 0x4bf0
pushq %rbx
movq %rdi, %rbx
movl $0xa8, %edi
callq 0x31d0
movaps 0x5ef2(%rip), %xmm0     # 0xaab0
movups %xmm0, (%rax)
movq %rbx, 0xa0(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x60(%rax)
movups %xmm0, 0x70(%rax)
movups %xmm0, 0x80(%rax)
popq %rbx
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: mips_cpu_set_register
mips_error mips_cpu_set_register(mips_cpu_h state, unsigned index, uint32_t value){
	if(state==0)
		return mips_ErrorInvalidHandle;

	if(index>31)
		return mips_ErrorInvalidArgument;

	if(index!=0)
		state->regs[index]=value;

	return mips_Success;
}

// Assembly:
testq %rdi, %rdi
je 0x4c6d
movl $0x1001, %eax           # imm = 0x1001
cmpl $0x1f, %esi
ja 0x4c6c
xorl %eax, %eax
testl %esi, %esi
je 0x4c6c
movl %esi, %ecx
movl %edx, 0x10(%rdi,%rcx,4)
retq
movl $0x1002, %eax           # imm = 0x1002
retq
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: mips_cpu_step
mips_error mips_cpu_step(mips_cpu_h state){
	if(state==0)
		return mips_ErrorInvalidHandle;

	uint32_t* instruction_data = new uint32_t[8];
	string instruction;
	mips_error err;
	uint32_t mem_value;
	uint8_t dataOut[4];

	//FETCH
	if (state->pc % 4 == 0){
		err = mips_mem_read(state->mem, state->pc, 4, dataOut);
		mem_value = dataOut[0] | (uint32_t(dataOut[1]) << 8) | (uint32_t(dataOut[2]) << 16) | (uint32_t(dataOut[3]) << 24);
	} else {
		err = mips_ExceptionInvalidAlignment;
	}

	//DECODE
	if (err == mips_Success)
		err = mips_decode(mem_value, instruction_data);

	//EXECUTE
	if (err == mips_Success)
		err = mips_execute(state, state->mem, state->hi, state->lo, instruction_data, instruction, state->pcN, state->pc);

	//IF SUCCESS increase PC to new value and not JUMP or BRANCH
	if (err == mips_Success){
		state->pc = state->pcN;
		state->pcN = state->pcN + 4;
	}
	//IF JUMP/BRANCH - PC, PCN adjusted in execution
	if (err == mips_ExceptionBreak)
		err = mips_Success;

	//DEBUG
	switch(state->level){
		case 1:
			debug_level_1(state, instruction);
		break;

		case 2:
			debug_level_2(state, instruction);
		break;

		case 3:
			debug_level_3(state, instruction, state->dest);
		break;

		default:
		break;
	}

	delete [] instruction_data;
	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, 0x8(%rsp)
testq %rdi, %rdi
je 0x4d7c
movq %rdi, %r14
movl $0x20, %edi
callq 0x3030
movq %rax, %rbx
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
movl (%r14), %esi
movl $0x2003, %ebp           # imm = 0x2003
testb $0x3, %sil
jne 0x4d55
movq 0xa0(%r14), %rdi
leaq 0x10(%rsp), %rcx
movl $0x4, %edx
callq 0x4add
movl 0x10(%rsp), %ecx
movl %ecx, 0x14(%rsp)
testl %eax, %eax
jne 0x4d4b
leaq 0x14(%rsp), %rdi
movq %rbx, %rsi
callq 0x522c
testl %eax, %eax
jne 0x4d4b
movq 0xa0(%r14), %rsi
leaq 0x4(%r14), %rdx
leaq 0x8(%r14), %rcx
leaq 0xc(%r14), %rax
leaq 0x18(%rsp), %r9
movq %r14, %rdi
movq %rbx, %r8
pushq %r14
pushq %rax
callq 0x5394
addq $0x10, %rsp
testl %eax, %eax
je 0x4dd6
xorl %ebp, %ebp
cmpl $0x2000, %eax           # imm = 0x2000
cmovnel %eax, %ebp
movl 0x90(%r14), %eax
cmpl $0x3, %eax
je 0x4d94
cmpl $0x2, %eax
je 0x4d83
cmpl $0x1, %eax
jne 0x4daa
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x4e0d
jmp 0x4daa
movl $0x1002, %ebp           # imm = 0x1002
jmp 0x4dc9
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x4eef
jmp 0x4daa
movq 0x98(%r14), %rdx
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5127
movq %rbx, %rdi
callq 0x3280
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x4dc9
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x31e0
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl 0xc(%r14), %eax
movl %eax, (%r14)
addl $0x4, %eax
movl %eax, 0xc(%r14)
xorl %ebp, %ebp
jmp 0x4d55
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x4e05
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x31e0
movq %rbx, %rdi
callq 0x3330
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: debug_level_2(mips_cpu_impl* const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void debug_level_2(const mips_cpu_h& state, const string& instruction){
	cout<<endl<<"Executed instruction: "<<instruction<<endl;
	cout<<"Next PC:="<<state->pc<<endl;
	cout<<"HI: "<<state->hi<<" LO: "<<state->lo<<endl;
	for (int i = 0; i < 32; ++i){
		if (i % 4 == 0)
			cout<<endl;
		cout<<"R["<<i<<"]"<<":= "<<state->regs[i]<<"\t";
	}
	cout<<endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r12
movq 0xa0c1(%rip), %rbx      # 0xefc8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
movq %rax, %r15
leaq 0x5b88(%rip), %rsi      # 0xaac0
movl $0x16, %edx
movq %rax, %rdi
callq 0x3210
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r15, %rdi
callq 0x3210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
leaq 0x5b52(%rip), %rsi      # 0xaad7
movl $0x9, %edx
movq %rbx, %rdi
callq 0x3210
movq (%r12), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x3120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
leaq 0x5b10(%rip), %rsi      # 0xaae1
movl $0x4, %edx
movq %rbx, %rdi
callq 0x3210
movq (%r12), %rax
movl 0x4(%rax), %esi
movq %rbx, %rdi
callq 0x3120
movq %rax, %r14
leaq 0x5aef(%rip), %rsi      # 0xaae6
movl $0x5, %edx
movq %rax, %rdi
callq 0x3210
movq %r12, %r13
movq (%r12), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
callq 0x3120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
xorl %r15d, %r15d
leaq 0x5aa4(%rip), %rbp      # 0xaaee
leaq 0x5ae7(%rip), %r14      # 0xab38
testb $0x3, %r15b
jne 0x507e
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3130
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x5c43(%rip), %rsi      # 0xacd0
callq 0x3210
movq %rbx, %rdi
movl %r15d, %esi
callq 0x3310
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5a3d(%rip), %rsi      # 0xaaec
callq 0x3210
movl $0x3, %edx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3210
movq (%r13), %rax
movl 0x10(%rax,%r15,4), %esi
movq %r12, %rdi
callq 0x3120
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x3210
incq %r15
cmpq $0x20, %r15
jne 0x5051
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3130
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu.cpp
// Function: debug_level_3(mips_cpu_impl* const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, _IO_FILE*)
void debug_level_3(const mips_cpu_h& state, const string& instruction, FILE* file){
	if (file == NULL) perror ("Error opening file");
	fprintf(state->dest,"Executed instruction: %s", instruction.c_str());
	fprintf(state->dest,"Next PC:= %i \n", state->pc);
	for (int i = 0; i < 32; ++i){
		if (i % 4 == 0)
			fprintf(state->dest,"\n");
		fprintf(state->dest,"R[%i]:= %i \t",i, state->regs[i]);
	}
	cout<<endl;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
je 0x51ec
movq (%rbx), %rax
movq 0x98(%rax), %rdi
movq (%r14), %rdx
leaq 0x59b6(%rip), %rsi      # 0xab05
xorl %eax, %eax
callq 0x32a0
movq (%rbx), %rax
movq 0x98(%rax), %rdi
movl (%rax), %edx
leaq 0x59b5(%rip), %rsi      # 0xab1e
xorl %eax, %eax
callq 0x32a0
leaq 0x59b6(%rip), %r14      # 0xab2d
xorl %r15d, %r15d
testb $0x3, %r15b
jne 0x5194
movq (%rbx), %rax
movq 0x98(%rax), %rsi
movl $0xa, %edi
callq 0x3260
movq (%rbx), %rax
movq 0x98(%rax), %rdi
movl 0x10(%rax,%r15,4), %ecx
movq %r14, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x32a0
incq %r15
cmpq $0x20, %r15
jne 0x517a
movq 0x9e08(%rip), %rbx      # 0xefc8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3130
leaq 0x58ff(%rip), %rdi      # 0xaaf2
callq 0x31a0
jmp 0x513b
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_decode.cpp
// Function: mips_decode(unsigned int const&, unsigned int*)
mips_error mips_decode(const uint32_t& instruction, uint32_t* instruction_data){
	uint32_t opcode = (instruction >> 2 ) & 0x3F;
	if (opcode==0)
		return mips_decode_R(instruction, instruction_data);
	if ((opcode==2) || (opcode==3) || (opcode==26))
		return mips_decode_J(instruction, instruction_data);
	return mips_decode_I(instruction, instruction_data);
}

// Assembly:
pushq %rax
movl (%rdi), %ecx
movl %ecx, %eax
shrl $0x2, %eax
andl $0x3f, %eax
je 0x5293
andl $0xf8, %ecx
cmpl $0x8, %ecx
setne %cl
cmpl $0x1a, %eax
setne %dl
testb %dl, %cl
jne 0x529a
movl %eax, (%rsi)
movl (%rdi), %eax
movl %eax, %ecx
andl $0x30, %ecx
shll $0x16, %ecx
movl %eax, %edx
shrl $0x18, %edx
orl %ecx, %edx
movl %eax, %ecx
shrl $0x8, %ecx
andl $0xff00, %ecx           # imm = 0xFF00
orl %edx, %ecx
shll $0x8, %eax
andl $0xff0000, %eax         # imm = 0xFF0000
orl %ecx, %eax
movl %eax, 0x4(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, 0x18(%rsi)
jmp 0x529f
callq 0x52a3
jmp 0x529f
callq 0x534a
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_cpp_makefile_star2_O3/martinferianc[P]CPUSimulator-EIE2/src/mips_cpu_execute.cpp
// Function: mips_execute(mips_cpu_impl*, mips_mem_provider*, unsigned int&, unsigned int&, unsigned int const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned int&, unsigned int&)
mips_error mips_execute(mips_cpu_h state, mips_mem_h mem, uint32_t& hi, uint32_t& lo, const uint32_t* instruction_data, string& instruction, uint32_t& pcN, uint32_t& pc){
	uint32_t type = instruction_data[7];
	switch (type) {
		case 0: return mips_execute_R(state, hi, lo, instruction_data, instruction, pcN, pc);
		case 1: return mips_execute_I(state, mem, instruction_data, instruction, pcN, pc);
		case 2: return mips_execute_J(state, instruction_data, instruction, pcN, pc);
	}
	return mips_InternalError;
}

// Assembly:
pushq %rax
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %rax
movl 0x1c(%r8), %r11d
cmpl $0x2, %r11d
je 0x53e0
cmpl $0x1, %r11d
je 0x53ce
testl %r11d, %r11d
jne 0x53f2
movq %r10, (%rsp)
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
movq %r9, %r8
movq %rax, %r9
callq 0x53f9
jmp 0x53f7
movq %r8, %rdx
movq %r9, %rcx
movq %rax, %r8
movq %r10, %r9
popq %rax
jmp 0x5d05
movq %r8, %rsi
movq %r9, %rdx
movq %rax, %rcx
movq %r10, %r8
popq %rax
jmp 0x6533
movl $0x3000, %eax           # imm = 0x3000
popq %rcx
retq