LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/src/Mid0002.cpp
// Function: Mid_0002::ParseRevision3()
void Mid_0002::ParseRevision3()
{
	int index;
	ParseRevision2();
	OutputStream >> std::setw(Index_size) >> index;
	OutputStream >> std::setw(Open_Protocol_version_size) >> Open_Protocol_version;
	OutputStream >> std::setw(Index_size) >> index;
	OutputStream >> std::setw(Controller_software_version_size) >> Controller_software_version;
	OutputStream >> std::setw(Index_size) >> index;
	OutputStream >> std::setw(Tool_software_version_size) >> Tool_software_version;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x6320
leaq 0x190(%rbx), %r14
movq 0x190(%rbx), %rax
movq -0x18(%rax), %rax
pushq $0x2
popq %r12
movq %r12, 0x1a0(%rbx,%rax)
leaq -0x2c(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x62c0
movq 0x190(%rbx), %rax
movq -0x18(%rax), %rax
pushq $0x13
popq %r13
movq %r13, 0x1a0(%rbx,%rax)
leaq 0x378(%rbx), %rsi
movq %r14, %rdi
callq 0x6520
movq 0x190(%rbx), %rax
movq -0x18(%rax), %rax
movq %r12, 0x1a0(%rbx,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x62c0
movq 0x190(%rbx), %rax
movq -0x18(%rax), %rax
movq %r13, 0x1a0(%rbx,%rax)
leaq 0x398(%rbx), %rsi
movq %r14, %rdi
callq 0x6520
movq 0x190(%rbx), %rax
movq -0x18(%rax), %rax
movq %r12, 0x1a0(%rbx,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x62c0
movq 0x190(%rbx), %rax
movq -0x18(%rax), %rax
movq %r13, 0x1a0(%rbx,%rax)
addq $0x3b8, %rbx            # imm = 0x3B8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6520
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/src/Mid0002.cpp
// Function: Mid_0002::UnPackMid0002()
void Mid_0002::UnPackMid0002()
{
	Unpack();

	switch(Revision)
	{
		default:
		case MID_Revision::Revision1:
			 ParseRevision1();
			 break;
		case MID_Revision::Revision2:
			 ParseRevision2();
			 break;
		case MID_Revision::Revision3:
			 ParseRevision3();
			 break;
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x18(%rax)
movl 0x320(%rbx), %eax
movq %rbx, %rdi
addq $0x8, %rsp
cmpl $0x2, %eax
je 0x8597
cmpl $0x3, %eax
jne 0x859e
popq %rbx
popq %rbp
jmp 0x6550
popq %rbx
popq %rbp
jmp 0x6320
popq %rbx
popq %rbp
jmp 0x6650
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/src/Mid0004.cpp
// Function: Mid_0004::BuildMid0004()
void Mid_0004::BuildMid0004()
{
	Length += Number_Size;
	Length += Error_Size;
	Packup();

	OutputStream << std::setw(Number_Size) << std::setfill('0') << Number;
	OutputStream << std::setw(Error_Size) << std::setfill('0') << Error;
	OutputStream << '\0';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
addl $0x6, 0x318(%rdi)
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0x1a0(%rbx), %r14
movq 0x1a0(%rbx), %rax
movq -0x18(%rax), %rax
movq $0x4, 0x1b0(%rbx,%rax)
pushq $0x30
popq %r15
movq %r14, %rdi
movl %r15d, %esi
callq 0x6670
movl 0x330(%rbx), %esi
movq %rax, %rdi
callq 0x6700
movq 0x1a0(%rbx), %rax
movq -0x18(%rax), %rax
movq $0x2, 0x1b0(%rbx,%rax)
movq %r14, %rdi
movl %r15d, %esi
callq 0x6670
movl 0x334(%rbx), %esi
movq %rax, %rdi
callq 0x6700
movq %r14, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x64c0
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/src/MessageID.h
// Function: operator>>(std::istream&, MID_Error&)
inline std::istream & operator>>(std::istream & stream, MID_Error& error )
{
	unsigned placeholder = 0;
	if(stream >> placeholder)
		error = static_cast<MID_Error>(placeholder);
    return stream;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x14(%rbp), %rsi
andl $0x0, (%rsi)
callq 0x6730
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x8788
movl -0x14(%rbp), %eax
movl %eax, (%r14)
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/src/Mid0005.cpp
// Function: Mid_0005::BuildMid0005()
void Mid_0005::BuildMid0005()
{
	Length += Number_Size;
	Packup();

	OutputStream << std::setw(Number_Size) << std::setfill('0') << Number;
	OutputStream << '\0';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
addl $0x4, 0x318(%rdi)
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0x1a0(%rbx), %r14
movq 0x1a0(%rbx), %rax
movq -0x18(%rax), %rax
movq $0x4, 0x1b0(%rbx,%rax)
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x6670
movl 0x330(%rbx), %esi
movq %rax, %rdi
callq 0x6700
movq %r14, %rdi
xorl %esi, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x64c0
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/Timer/Timer.cpp
// Function: Timer::Timer(int, int, bool)
Timer::Timer(int _seconds, int _milliseconds, bool singleshot)
{
	timerSpecs.it_value.tv_sec = seconds = _seconds;
	milliseconds =_milliseconds;
	timerSpecs.it_value.tv_nsec = MILLISECONDS_TO_NANOSECONDS * milliseconds;

	if(singleshot)
	{
		timerSpecs.it_interval.tv_sec = 0;
		timerSpecs.it_interval.tv_nsec = 0;
	}
	else
	{
		timerSpecs.it_interval.tv_sec = timerSpecs.it_value.tv_sec;
		timerSpecs.it_interval.tv_nsec = timerSpecs.it_value.tv_nsec;
	}

	sigemptyset(&SignalAction.sa_mask);
	SignalAction.sa_flags = SA_SIGINFO;
	SignalAction.sa_sigaction = Timer::signal_handler;
	memset(&signalEvent, 0, sizeof(signalEvent));
	signalEvent.sigev_notify = SIGEV_SIGNAL;
	signalEvent.sigev_value.sival_ptr = (void*) this;
	signalEvent.sigev_signo = SIGALRM;


	if (timer_create(CLOCK_REALTIME, &signalEvent, &timerID)!= 0)
	{
		perror("Could not creat the timer");
	}

	if (sigaction(SIGALRM, &SignalAction, NULL))
	{
		perror("Could not install new signal handler");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x5617(%rip), %rax      # 0xdfe0
addq $0x10, %rax
movq %rax, (%rdi)
movl %esi, 0x8(%rdi)
movslq %esi, %rax
movq %rax, 0x180(%rdi)
movl %edx, 0xc(%rdi)
imull $0xf4240, %edx, %edx    # imm = 0xF4240
movslq %edx, %rdx
movq %rdx, 0x188(%rdi)
xorl %esi, %esi
testl %ecx, %ecx
cmovneq %rsi, %rax
cmovneq %rsi, %rdx
movq %rax, 0x170(%rdi)
movq %rdx, 0x178(%rdi)
leaq 0xd8(%rdi), %r14
addq $0xe0, %rdi
callq 0x6500
movl $0x4, 0x160(%rbx)
movq 0x554a(%rip), %rax      # 0xdf78
movq %rax, 0xd8(%rbx)
leaq 0x98(%rbx), %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rbx)
movups %xmm0, 0xb0(%rbx)
andq $0x0, 0xd0(%rbx)
movups %xmm0, 0xc0(%rbx)
movq %rbx, 0x98(%rbx)
movl $0xe, 0xa0(%rbx)
addq $0x10, %rbx
xorl %edi, %edi
movq %rbx, %rdx
callq 0x60c0
testl %eax, %eax
jne 0x8a95
pushq $0xe
popq %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x6510
testl %eax, %eax
jne 0x8aa3
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1668(%rip), %rdi      # 0xa104
callq 0x63c0
jmp 0x8a7f
leaq 0x1674(%rip), %rdi      # 0xa11e
popq %rbx
popq %r14
popq %rbp
jmp 0x63c0
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/Timer/Timer.cpp
// Function: Timer::init(int, int, bool)
void Timer::init(int seconds, int milliseconds, bool singleshot)
{
	timerSpecs.it_value.tv_sec = seconds;
	timerSpecs.it_value.tv_nsec = MILLISECONDS_TO_NANOSECONDS * milliseconds;

	if(singleshot)
	{
		timerSpecs.it_interval.tv_sec = 0;
		timerSpecs.it_interval.tv_nsec = 0;
	}
	else
	{
		timerSpecs.it_interval.tv_sec = timerSpecs.it_value.tv_sec;
		timerSpecs.it_interval.tv_nsec = timerSpecs.it_value.tv_nsec;
	}

	sigemptyset(&SignalAction.sa_mask);
	SignalAction.sa_flags = SA_SIGINFO;
	SignalAction.sa_sigaction = Timer::signal_handler;
	memset(&signalEvent, 0, sizeof(signalEvent));
	signalEvent.sigev_notify = SIGEV_SIGNAL;
	signalEvent.sigev_value.sival_ptr = (void*) this;
	signalEvent.sigev_signo = SIGALRM;


	if (timer_create(CLOCK_REALTIME, &signalEvent, &timerID)!= 0)
	{
		perror("Could not creat the timer");
	}

	if (sigaction(SIGALRM, &SignalAction, NULL))
	{
		perror("Could not install new signal handler");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movslq %esi, %rax
movq %rax, 0x180(%rdi)
imull $0xf4240, %edx, %edx    # imm = 0xF4240
movslq %edx, %rdx
movq %rdx, 0x188(%rdi)
xorl %esi, %esi
testl %ecx, %ecx
cmovneq %rsi, %rax
cmovneq %rsi, %rdx
movq %rax, 0x170(%rdi)
movq %rdx, 0x178(%rdi)
leaq 0xd8(%rdi), %rbx
addq $0xe0, %rdi
callq 0x6500
movl $0x4, 0x160(%r14)
movq 0x541b(%rip), %rax      # 0xdf78
movq %rax, 0xd8(%r14)
leaq 0x98(%r14), %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%r14)
movups %xmm0, 0xb0(%r14)
andq $0x0, 0xd0(%r14)
movups %xmm0, 0xc0(%r14)
movq %r14, 0x98(%r14)
movl $0xe, 0xa0(%r14)
addq $0x10, %r14
xorl %edi, %edi
movq %r14, %rdx
callq 0x60c0
testl %eax, %eax
jne 0x8bc8
pushq $0xe
popq %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x6510
testl %eax, %eax
jne 0x8bd6
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1535(%rip), %rdi      # 0xa104
callq 0x63c0
jmp 0x8bb2
leaq 0x1541(%rip), %rdi      # 0xa11e
popq %rbx
popq %r14
popq %rbp
jmp 0x63c0
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::Client(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned short)
Client::Client(string _ip_address,unsigned short _port) {

	ip_address = _ip_address;
	port = _port;
	client_fd = -1;
	status = Connection_Status::UNKNOWN;
	retries = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rdi, %rbx
movq 0x5371(%rip), %rax      # 0xdfc8
addq $0x10, %rax
movq %rax, (%rdi)
leaq 0x18(%rdi), %r15
leaq 0x28(%rdi), %rax
movq %rax, 0x18(%rdi)
andq $0x0, 0x20(%rdi)
movb $0x0, 0x28(%rdi)
movq %r15, %rdi
callq 0x6270
movw %r14w, 0x38(%rbx)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0x6200
movq %rbx, %rdi
callq 0x6740
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::Client()
Client::Client() {

	ip_address = "";
	port = 0;
	client_fd = -1;
	status = Connection_Status::UNKNOWN;
	retries = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x5307(%rip), %rax      # 0xdfc8
addq $0x10, %rax
movq %rax, (%rdi)
leaq 0x18(%rdi), %r14
leaq 0x28(%rdi), %rax
movq %rax, 0x18(%rdi)
andq $0x0, 0x20(%rdi)
movb $0x0, 0x28(%rdi)
leaq 0x15f7(%rip), %rsi      # 0xa2db
movq %r14, %rdi
callq 0x67f0
andw $0x0, 0x38(%rbx)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
movq %rbx, %rdi
callq 0x6740
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::Accept(int)
Error Client::Accept(int _server_fd){
	struct sockaddr in_addr;
	socklen_t in_len;
	int local_client_fd;
	char port_buffer[32];
	char ip_buffer[32];
	Error error_state = Error::NONE;

	DEBUG("Accepting, Server FD: %d\n ",_server_fd);
	in_len = sizeof( in_addr);
	local_client_fd = accept (_server_fd, &in_addr, &in_len);
	if (local_client_fd == -1)
	{
		if ((errno == EAGAIN) || (errno == EWOULDBLOCK))  /* We have processed all incoming connections. */
		{
			status = Connection_Status::UNKNOWN;
			error_state = Error::ACCEPT_DONE;
			client_fd = -1;
		}
		else
		{
			perror ("accept");
			status = Connection_Status::DISCONNECTED;
			error_state = Error::ACCEPT;
			client_fd = -1;
		}
	}
	else
	{
		client_fd = local_client_fd;
		status = Connection_Status::CONNECTED;
		retries = 0;

		DEBUG("Accepted connections, client FD: %d\n ",client_fd);

        int nameinfo = getnameinfo (&in_addr, in_len, ip_buffer, sizeof(ip_buffer), port_buffer, sizeof(port_buffer), NI_NUMERICHOST | NI_NUMERICSERV);
		if (nameinfo == 0)
		{
			ip_address = string(ip_buffer);
			port = atoi(port_buffer);
			DEBUG("Client Ip:%s:%d \n ",ip_address.c_str(), port);
		}

		if(setBlockingMode(Blocking_Mode::NonBlock) != Error::NONE)
		{
			perror("Nonblock failed.");
			status = Connection_Status::DISCONNECTED;
		}
	}

	return error_state;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x140a(%rip), %rdi      # 0xa161
xorl %eax, %eax
callq 0x6050
leaq -0x18(%rbp), %rdx
movl $0x10, (%rdx)
leaq -0x28(%rbp), %rsi
movl %r14d, %edi
callq 0x6170
cmpl $-0x1, %eax
je 0x8e33
movl %eax, 0xc(%rbx)
movl $0x1, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
leaq 0x13f1(%rip), %rdi      # 0xa183
movl %eax, %esi
xorl %eax, %eax
callq 0x6050
movl -0x18(%rbp), %esi
movl $0x3, (%rsp)
leaq -0x28(%rbp), %rdi
leaq -0x50(%rbp), %rdx
leaq -0x70(%rbp), %r8
pushq $0x20
popq %rcx
movl %ecx, %r9d
callq 0x62e0
testl %eax, %eax
jne 0x8e0d
leaq -0x90(%rbp), %r14
leaq -0x50(%rbp), %rsi
leaq -0x11(%rbp), %rdx
movq %r14, %rdi
callq 0x61e0
leaq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0x64d0
movq %r14, %rdi
callq 0x6200
leaq -0x70(%rbp), %rdi
callq 0x6660
movw %ax, 0x38(%rbx)
movq 0x18(%rbx), %rsi
movzwl %ax, %edx
leaq 0x13a3(%rip), %rdi      # 0xa1a9
xorl %eax, %eax
callq 0x6050
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x67a0
pushq $0x2
popq %r14
cmpl $0x2, %eax
je 0x8e4f
leaq 0x150b(%rip), %rdi      # 0xa333
callq 0x63c0
orl $-0x1, 0x8(%rbx)
jmp 0x8e4f
callq 0x6040
cmpl $0xb, (%rax)
jne 0x8e5e
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x8(%rbx)
pushq $0x10
popq %r14
movl %r14d, %eax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1317(%rip), %rdi      # 0xa17c
callq 0x63c0
orq $-0x1, 0x8(%rbx)
pushq $0x9
jmp 0x8e4d
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::setBlockingMode(Blocking_Mode)
Error Client::setBlockingMode(Blocking_Mode mode)
{
	Error status = Error::UNKNOWN;
	int old_flags = fcntl(client_fd,F_GETFL, 0);

	if(old_flags < 0 )
	{
		perror("failed to read old flags.");
		status = Error::FCNTL_GET;
	}
	else
	{
		if(mode == Blocking_Mode::NonBlock)
		{
			old_flags |= O_NONBLOCK;
		}
		else
		{
			old_flags &= ~O_NONBLOCK;
		}

		old_flags = fcntl(client_fd,F_SETFL, old_flags);
		if(old_flags < 0 )
		{
			perror("failed to set non-block flags.");
			status = Error::FCNTL_SET;
		}
		else
		{
			status = Error::NONE;
		}
	}

	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %r14
movl 0xc(%rdi), %edi
pushq $0x3
popq %rbx
movl %ebx, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x6290
testl %eax, %eax
js 0x8ed1
movl %eax, %ecx
orl $0x800, %ecx            # imm = 0x800
andl $0x7ffff7ff, %eax       # imm = 0x7FFFF7FF
cmpl $0x1, %r15d
cmovel %ecx, %eax
movl 0xc(%r14), %edi
pushq $0x4
popq %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6290
testl %eax, %eax
js 0x8edd
pushq $0x2
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4
popq %rbx
leaq 0x1388(%rip), %rdi      # 0xa263
jmp 0x8ee4
leaq 0x1399(%rip), %rdi      # 0xa27d
callq 0x63c0
jmp 0x8ec4
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::Disconnect()
Connection_Status Client::Disconnect()
{
	status = Connection_Status::UNKNOWN;

	    if (client_fd >= 0)
	    {
	        close(client_fd);
	        client_fd = -1;
	        status = Connection_Status::DISCONNECTED;
	    }

	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
andl $0x0, 0x8(%rdi)
movl 0xc(%rdi), %edi
testl %edi, %edi
js 0x914b
callq 0x6810
orq $-0x1, 0x8(%rbx)
pushq $-0x1
popq %rax
jmp 0x914d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::EventRead(std::vector<char, std::allocator<char>>&)
Error Client::EventRead(vector<char>& buffer)
{
	Error error_state = Error::UNKNOWN;
	int event_fd, epoll_status;
	struct epoll_event event;
	struct epoll_event events[MAX_EVENTS];

	event_fd = epoll_create1(0);
	if (event_fd == -1)
	{
		perror ("epoll_create");
		error_state = Error::EPOLL_CREATE;
	}
	else
	{
		event.data.fd = client_fd;
		event.events = EPOLLIN | EPOLLET | EPOLLRDHUP;

		epoll_status = epoll_ctl (event_fd, EPOLL_CTL_ADD, client_fd, &event);
		if (epoll_status == -1)
		{
			perror ("epoll_create");
			error_state = Error::EPOLL_CTL;
		}
		else
		{
		    int epoll_events = epoll_wait (event_fd, events, MAX_EVENTS, 1000);
		    for (int i = 0; i < epoll_events; i++)
			{
				if((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN ))) /*Epoll error occured*/
				{
				  perror("epoll wait error\n");
				  error_state = Error::EPOLL_WAIT;
				  close (events[i].data.fd);
				}
				else if(events[i].events & EPOLLRDHUP)
				{
					perror("epoll event Client has hung up.\n");
					error_state = Error::EPOLL_CLOSE;
				}
				else if(client_fd == events[i].data.fd)
				{
					error_state = Read(buffer);
				}
			}
		}
	}

	return error_state;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %edi, %edi
callq 0x6570
cmpl $-0x1, %eax
je 0x923e
movl %eax, %r15d
movl 0xc(%r14), %edx
leaq -0x34(%rbp), %rcx
movl %edx, 0x4(%rcx)
movl $0x80002001, (%rcx)     # imm = 0x80002001
pushq $0x1
popq %rsi
movl %eax, %edi
callq 0x65b0
cmpl $-0x1, %eax
je 0x924e
leaq -0x100(%rbp), %rsi
pushq $0x10
popq %rdx
movl %r15d, %edi
movl $0x3e8, %ecx            # imm = 0x3E8
callq 0x6220
xorl %r13d, %r13d
testl %eax, %eax
cmovlel %r13d, %eax
imulq $0xc, %rax, %r15
pushq $0xd
popq %r12
xorl %eax, %eax
cmpq %r13, %r15
je 0x925d
movl -0x100(%rbp,%r13), %ecx
movl %ecx, %edx
andl $0x19, %edx
cmpl $0x1, %edx
jne 0x920f
btl $0xd, %ecx
jb 0x922d
movl 0xc(%r14), %ecx
cmpl -0xfc(%rbp,%r13), %ecx
jne 0x9209
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6250
addq $0xc, %r13
jmp 0x91cf
leaq 0x1093(%rip), %rdi      # 0xa2a9
callq 0x63c0
movl -0xfc(%rbp,%r13), %edi
callq 0x6810
movl %r12d, %eax
jmp 0x9209
leaq 0x1087(%rip), %rdi      # 0xa2bb
callq 0x63c0
pushq $0xf
popq %rax
jmp 0x9209
leaq 0x1057(%rip), %rdi      # 0xa29c
callq 0x63c0
pushq $0xb
jmp 0x925c
leaq 0x1047(%rip), %rdi      # 0xa29c
callq 0x63c0
pushq $0xc
popq %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::Read(std::vector<char, std::allocator<char>>&)
Error Client::Read(vector<char>& buffer)
{
	Error status = Error::UNKNOWN;
	int read_bytes = 0;
	char read_buffer[MAX_PACKET_LENGTH];

	read_bytes = read(client_fd, read_buffer, MAX_PACKET_LENGTH);
	if(read_bytes > 0)
	{
		buffer.resize(read_bytes);
		std::copy ( read_buffer, read_buffer + read_bytes, buffer.begin() );
		status = Error::NONE;
	}
	else
	{
		perror("failed to Read.");
		status = Error::READ;
	}

	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2718, %rsp           # imm = 0x2718
movq %rsi, %rbx
movl 0xc(%rdi), %edi
leaq -0x2730(%rbp), %rsi
movl $0x2710, %edx           # imm = 0x2710
callq 0x6600
movq %rax, %r14
testl %r14d, %r14d
jle 0x92e1
movq %r14, %rsi
andq $0x7fffffff, %rsi       # imm = 0x7FFFFFFF
movq %rbx, %rdi
callq 0x6710
pushq $0x2
popq %r15
andq $0x7fffffff, %r14       # imm = 0x7FFFFFFF
je 0x92d0
movq (%rbx), %rdi
leaq -0x2730(%rbp), %rsi
movq %r14, %rdx
callq 0x63a0
movl %r15d, %eax
addq $0x2718, %rsp           # imm = 0x2718
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0xff4(%rip), %rdi       # 0xa2dc
callq 0x63c0
pushq $0x5
popq %r15
jmp 0x92d0
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Client.cpp
// Function: Client::Write(std::vector<char, std::allocator<char>>)
Error Client::Write(vector<char>  buffer)
{
	Error status = Error::UNKNOWN;
	int written_bytes = 0;
	char write_buffer[MAX_PACKET_LENGTH];
	int size = 0;

	for(unsigned int i = 0; i < buffer.size(); i ++)
	{
		write_buffer[i] = buffer[i];
	}

	written_bytes = write(client_fd, write_buffer, size);

	if(written_bytes > 0)
	{
		status = Error::NONE;
	}
	else
	{
		perror("failed to Write.");
		status = Error::WRITE;
	}

	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2710, %rsp           # imm = 0x2710
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
subq %rax, %rcx
xorl %edx, %edx
movl %edx, %edx
cmpq %rdx, %rcx
jbe 0x9322
movb (%rax,%rdx), %sil
movb %sil, -0x2710(%rbp,%rdx)
incl %edx
jmp 0x930b
movl 0xc(%rdi), %edi
leaq -0x2710(%rbp), %rsi
xorl %edx, %edx
callq 0x61a0
testl %eax, %eax
jle 0x9343
pushq $0x2
popq %rax
addq $0x2710, %rsp           # imm = 0x2710
popq %rbp
retq
leaq 0xfa2(%rip), %rdi       # 0xa2ec
callq 0x63c0
pushq $0x6
jmp 0x9339
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Server.cpp
// Function: Server::setBlockingMode(Blocking_Mode)
Error Server::setBlockingMode(Blocking_Mode mode)
{
	error_state = Error::UNKNOWN;
	int old_flags = fcntl(server_fd,F_GETFL, 0);

	if(old_flags < 0 )
	{
		perror("failed to read old flags.");
		error_state = Error::FCNTL_GET;
	}
	else
	{
		if(mode == Blocking_Mode::NonBlock)
		{
			old_flags |= O_NONBLOCK;
		}
		else
		{
			old_flags &= ~O_NONBLOCK;
		}

		old_flags = fcntl(server_fd,F_SETFL, old_flags);
		if(old_flags < 0 )
		{
			perror("failed to set non-block flags.");
			error_state = Error::FCNTL_SET;
		}
		else
		{
			error_state = Error::NONE;
		}
	}

	return error_state;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %rbx
andl $0x0, 0x1b4(%rdi)
movl 0x1a8(%rdi), %edi
pushq $0x3
popq %r14
movl %r14d, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x6290
testl %eax, %eax
js 0x9818
movl %eax, %ecx
orl $0x800, %ecx            # imm = 0x800
andl $0x7ffff7ff, %eax       # imm = 0x7FFFF7FF
cmpl $0x1, %r15d
cmovel %ecx, %eax
movl 0x1a8(%rbx), %edi
pushq $0x4
popq %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x6290
testl %eax, %eax
js 0x9825
pushq $0x2
popq %r14
movl %r14d, 0x1b4(%rbx)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4
popq %r14
leaq 0xa40(%rip), %rdi       # 0xa263
jmp 0x982c
leaq 0xa51(%rip), %rdi       # 0xa27d
callq 0x63c0
jmp 0x9803
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Server.cpp
// Function: Server::~Server()
Server::~Server() {

	if(server_fd > 0)
		close(server_fd);

	for(int i = 0;i < MAX_CONNECTIONS; i++)
	{
		client_list[i].Disconnect();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x4758(%rip), %rax      # 0xdfa0
addq $0x10, %rax
movq %rax, (%rdi)
movl 0x1a8(%rdi), %edi
testl %edi, %edi
jle 0x985e
callq 0x6810
leaq 0x10(%rbx), %r14
pushq $0x10
popq %r15
cmpq $0x190, %r15            # imm = 0x190
je 0x987e
leaq (%rbx,%r15), %rdi
callq 0x6790
addq $0x40, %r15
jmp 0x9866
leaq 0x288(%rbx), %rdi
callq 0x6770
addq $0x190, %rbx            # imm = 0x190
movq %rbx, %rdi
callq 0x67c0
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6100
jmp 0x98ad
movq %rax, %rdi
callq 0x7939
nop
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Server.cpp
// Function: Server::AddClientToEvent(Client)
Error Server::AddClientToEvent(Client client)
{
	error_state = Error::UNKNOWN;
	int epoll_status;
	struct epoll_event event;

	event.data.fd = client.get_fd();
	event.events = EPOLLIN | EPOLLET | EPOLLRDHUP;

	epoll_status = epoll_ctl(event_fd, EPOLL_CTL_ADD, event.data.fd, &event);

	if (epoll_status == -1)
	{
		perror ("epoll_create");
		error_state = Error::EPOLL_CTL;
	}
	else
	{
		error_state = Error::NONE;
	}

	return error_state;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
andl $0x0, 0x1b4(%rdi)
movl 0xc(%rsi), %edx
leaq -0x14(%rbp), %rcx
movl %edx, 0x4(%rcx)
movl $0x80002001, (%rcx)     # imm = 0x80002001
movl 0x1b8(%rdi), %edi
pushq $0x1
popq %rsi
callq 0x65b0
cmpl $-0x1, %eax
je 0x9b06
pushq $0x2
popq %rax
movl %eax, 0x1b4(%rbx)
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0x78f(%rip), %rdi       # 0xa29c
callq 0x63c0
pushq $0xc
jmp 0x9af8
// File: /workspace/github_cpp_makefile_star2_O2/Neuromancer2701[P]OpenTool/lib/sockets/Server.cpp
// Function: Server::isClient(int, Client&)
bool Server::isClient(int fd, Client& client)
{
	bool found = false;
	for(auto local:client_list)
	{
		if(local.get_fd() == fd)
		{
			client = local;
			found = true;
		}
	}

	return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, -0x30(%rbp)
movl %esi, %r14d
movq %rdi, %r15
pushq $0x10
popq %rbx
xorl %r12d, %r12d
leaq -0x70(%rbp), %r13
cmpq $0x190, %rbx            # imm = 0x190
je 0x9b73
leaq (%r15,%rbx), %rsi
movq %r13, %rdi
callq 0x6080
cmpl %r14d, -0x64(%rbp)
jne 0x9b65
movb $0x1, %r12b
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x6140
movq %r13, %rdi
callq 0x60f0
addq $0x40, %rbx
jmp 0x9b3b
andb $0x1, %r12b
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x60f0
movq %rbx, %rdi
callq 0x6740
nop
// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH13_CopyControl/examples/HasPtrValueLike.cc
// Function: HasPtr::operator=(HasPtr const&)
HasPtr& HasPtr::operator=(const HasPtr& rhs)
{
	auto newp = new string(*rhs.ps);  // copy the underlying string
	delete ps;       // free the old memory
	ps = newp;       // copy data from rhs into this object
	i = rhs.i;
	return *this;    // return this object
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x20
popq %rdi
callq 0x1050
movq %rax, %r15
movq (%r14), %rsi
movq %rax, %rdi
callq 0x1070
movq (%rbx), %r12
testq %r12, %r12
je 0x11c3
movq %r12, %rdi
callq 0x1040
pushq $0x20
popq %rsi
movq %r12, %rdi
callq 0x1060
movq %r15, (%rbx)
movl 0x8(%r14), %eax
movl %eax, 0x8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x1060
movq %rbx, %rdi
callq 0x1080
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/proxyclient.cpp
// Function: sendMessage(int, unsigned char const*, unsigned long, ClientContext*, int)
ssize_t sendMessage(int sockFd, const uint8_t *src, size_t nbyte, ClientContext *ctx, int msgType = 4) {
    static InnerMsg innerMsg;
    memset(&innerMsg, 0, sizeof(innerMsg));
    ctx->cSeq++;
    innerMsg.cSeq = ctx->cSeq;
    innerMsg.sSeq = ctx->sSeq;
    innerMsg.msgType = msgType;
    if (nbyte > sizeof(innerMsg.data)) {
        LogHelper::log(Error, "Failed to send data, nbyte too large, nbyte: %lu", nbyte);
        return -1;
    }
    innerMsg.dataLength = nbyte;
    memcpy(innerMsg.data, src, nbyte);
    ssize_t sendCode = sendTSPacket(sockFd, &innerMsg, constants::serverNonBlocking);
    if (sendCode < 0) {
        LogHelper::log(Error, "Fail to send data");
        return sendCode;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %r8d, %r15d
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %ebp
leaq 0x188d9(%rip), %rdi     # 0x1b250
movl $0x10000, %edx          # imm = 0x10000
xorl %esi, %esi
callq 0x2140
movq (%r12), %rax
incq %rax
movq %rax, (%r12)
movq %rax, 0x188bb(%rip)     # 0x1b250
movq 0x8(%r12), %rax
movq %rax, 0x188b7(%rip)     # 0x1b258
movw %r15w, 0x188b7(%rip)    # 0x1b260
cmpq $0xffed, %rbx           # imm = 0xFFED
jb 0x29ca
leaq 0x3798(%rip), %rsi      # 0x6151
xorl %edi, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x26e8
pushq $-0x1
popq %rbx
jmp 0x2a13
movw %bx, 0x18891(%rip)      # 0x1b262
leaq 0x18878(%rip), %r15     # 0x1b250
leaq 0x18885(%rip), %rdi     # 0x1b264
movq %r14, %rsi
movq %rbx, %rdx
callq 0x21a0
pushq $0x1
popq %rdx
movl %ebp, %edi
movq %r15, %rsi
callq 0x4a43
testq %rax, %rax
js 0x2a00
xorl %ebx, %ebx
jmp 0x2a13
movq %rax, %rbx
leaq 0x3778(%rip), %rsi      # 0x6182
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/proxyclient.cpp
// Function: sendRequestMsg(int, int, unsigned char const*, unsigned long, ClientContext*)
ssize_t sendRequestMsg(int serverFd, int localFd, const uint8_t *src, size_t nbyte, ClientContext *ctx) {
    static uint8_t msgBuffer[constants::AES_MAX_DATA_LENGTH];
    memset(msgBuffer, 0, sizeof(msgBuffer));
    hton_copy4bytes(msgBuffer, &localFd);
    if (sizeof(msgBuffer) < nbyte + 4) {
        LogHelper::log(Warn, "Failed to send request msg, nbyte greater than buffersize + 4");
        return -1;
    }
    memcpy(msgBuffer + 4, src, nbyte);
    ssize_t sendCode = sendMessage(serverFd, msgBuffer, nbyte + 4, ctx, 8);
    if (sendCode < 0) {
        LogHelper::log(Error, "Failed to send request msg");
        return sendCode;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %r12d
movl %edi, %ebp
leaq 0x28814(%rip), %rdi     # 0x2b250
movl $0xffcc, %edx           # imm = 0xFFCC
xorl %esi, %esi
callq 0x2140
bswapl %r12d
movl %r12d, 0x287fe(%rip)    # 0x2b250
leaq 0x4(%r14), %r12
cmpq $0xffcd, %r12           # imm = 0xFFCD
jb 0x2a75
leaq 0x372e(%rip), %rsi      # 0x6194
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x26e8
pushq $-0x1
popq %rbx
jmp 0x2abb
leaq 0x287d8(%rip), %rdi     # 0x2b254
movq %r15, %rsi
movq %r14, %rdx
callq 0x21a0
leaq 0x287c2(%rip), %rsi     # 0x2b250
pushq $0x8
popq %r8
movl %ebp, %edi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x295a
testq %rax, %rax
js 0x2aa8
xorl %ebx, %ebx
jmp 0x2abb
movq %rax, %rbx
leaq 0x3720(%rip), %rsi      # 0x61d2
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/proxyclient.cpp
// Function: recvMessage(int, unsigned char*, unsigned long, ClientContext*, unsigned char*)
ssize_t recvMessage(int sockFd, uint8_t *dst, size_t bufferSize, ClientContext *ctx, uint8_t *msgTypePtr = NULL) {
    static InnerMsg innerMsg;
    memset(&innerMsg, 0, sizeof(innerMsg));

    ssize_t recvCode = recvTSPacket(sockFd, &innerMsg, constants::serverNonBlocking);
    if (recvCode < 0) {
        LogHelper::log(Error, "Fail to recv data");
        return recvCode;
    }
    if (innerMsg.sSeq != ctx->sSeq + 1) {
        LogHelper::log(Error, "Fail to recv data, seq error, sSeq: %llu, expected: %llu", innerMsg.sSeq, ctx->sSeq + 1);
        return -2;
    }
    if (innerMsg.msgType != 5 && innerMsg.msgType != 7 && innerMsg.msgType != 9) {
        LogHelper::log(Error, "Fail to recv data, msgType error, recv type :%d", innerMsg.msgType);
        return -3;
    }
    if (msgTypePtr != NULL)
        *msgTypePtr = innerMsg.msgType;
    if (innerMsg.dataLength > bufferSize) {
        LogHelper::log(Error, "Fail to recv data, bufferSize not enought, bufferSize :%lu, expected: %lu", bufferSize, innerMsg.dataLength);
        return -4;
    }
    memcpy(dst, innerMsg.data, innerMsg.dataLength);
    ctx->sSeq = innerMsg.sSeq;
    return innerMsg.dataLength;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r12
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
leaq 0x38739(%rip), %r13     # 0x3b220
movl $0x10000, %edx          # imm = 0x10000
movq %r13, %rdi
xorl %esi, %esi
callq 0x2140
pushq $0x1
popq %rdx
movl %ebp, %edi
movq %r13, %rsi
callq 0x4bc1
testq %rax, %rax
js 0x2b65
movq 0x38719(%rip), %rdx     # 0x3b228
movq 0x8(%rbx), %rcx
incq %rcx
cmpq %rcx, %rdx
jne 0x2b7a
movzwl 0x3870e(%rip), %edx     # 0x3b230
cmpl $0x9, %edx
ja 0x2bc7
movl $0x2a0, %eax            # imm = 0x2A0
btl %edx, %eax
jae 0x2bc7
testq %r12, %r12
je 0x2b42
movb %dl, (%r12)
movzwl 0x386e9(%rip), %ecx     # 0x3b232
cmpq %r14, %rcx
jbe 0x2ba0
leaq 0x3713(%rip), %rsi      # 0x6268
xorl %edi, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x26e8
pushq $-0x4
jmp 0x2b8c
movq %rax, %r13
leaq 0x367e(%rip), %rsi      # 0x61ed
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
jmp 0x2b8e
leaq 0x367e(%rip), %rsi      # 0x61ff
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
pushq $-0x2
popq %r13
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3868d(%rip), %rsi     # 0x3b234
movq %r15, %rdi
movq %rcx, %rdx
callq 0x21a0
movq 0x3866f(%rip), %rax     # 0x3b228
movq %rax, 0x8(%rbx)
movzwl 0x3866d(%rip), %r13d    # 0x3b232
jmp 0x2b8e
leaq 0x366a(%rip), %rsi      # 0x6238
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
pushq $-0x3
jmp 0x2b8c
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/proxyclient.cpp
// Function: recvReplyMsg(int, unsigned char*, unsigned long, ClientContext*, int*)
int recvReplyMsg(int serverFd, uint8_t *dst, size_t bufferSize, ClientContext *ctx, int *localFdPtr) {
    static uint8_t msgBuffer[constants::MAX_MSG_DATA_LENGTH];
    memset(msgBuffer, 0, sizeof(msgBuffer));
    uint8_t msgType = 0;
    ssize_t recvCode = recvMessage(serverFd, msgBuffer, sizeof(msgBuffer), ctx, &msgType);
    if (msgType != 9) {
        LogHelper::log(Error, "Failed in reply msg, error msg type, get :%d, expected: %d", msgType, 9);
        return -3;
    }
    if (recvCode < 0) {
        LogHelper::log(Error, "Failed to recv reply msg");
        return recvCode;
    }
    if (recvCode > bufferSize + 4) {
        LogHelper::log(Error, "buffer size less than recv msg len + 4, buffersize: %d, msgLen: %d", bufferSize, recvCode);
        return -1;
    }
    if (recvCode < 4) {
        LogHelper::log(Error, "recv msg len less than 4, recv len: %d", recvCode);
        return -2;
    }
    int localFd = 0;
    ntoh_copy4bytes(&localFd, msgBuffer);
    memcpy(dst, msgBuffer + 4, recvCode - 4);
    assert(localFdPtr != NULL);
    *localFdPtr = localFd;
    return recvCode - 4;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x10(%rsp)
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movl %edi, %ebp
leaq 0x48620(%rip), %r13     # 0x4b220
movl $0xffec, %edx           # imm = 0xFFEC
movq %r13, %rdi
xorl %esi, %esi
callq 0x2140
leaq 0xf(%rsp), %r14
movb $0x0, (%r14)
movl $0xffec, %edx           # imm = 0xFFEC
movl %ebp, %edi
movq %r13, %rsi
movq %rbx, %rcx
movq %r14, %r8
callq 0x2ac7
movzbl (%r14), %edx
cmpl $0x9, %edx
jne 0x2c62
movq %rax, %rbx
testq %rax, %rax
js 0x2c7a
leaq 0x4(%r12), %rax
cmpq %rax, %rbx
jbe 0x2c8c
leaq 0x36b7(%rip), %rsi      # 0x6306
xorl %edi, %edi
movq %r12, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x26e8
pushq $-0x1
jmp 0x2c77
leaq 0x3649(%rip), %rsi      # 0x62b2
pushq $0x9
popq %rcx
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
pushq $-0x3
popq %rbx
jmp 0x2cd3
leaq 0x366c(%rip), %rsi      # 0x62ed
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
jmp 0x2cd3
cmpq $0x3, %rbx
ja 0x2ca9
leaq 0x36b0(%rip), %rsi      # 0x6349
xorl %edi, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x26e8
pushq $-0x2
jmp 0x2c77
movl 0x48571(%rip), %ebp     # 0x4b220
addq $-0x4, %rbx
leaq 0x4856a(%rip), %rsi     # 0x4b224
movq %r15, %rdi
movq %rbx, %rdx
callq 0x21a0
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x2ce4
bswapl %ebp
movl %ebp, (%rax)
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3685(%rip), %rdi      # 0x6370
leaq 0x3691(%rip), %rsi      # 0x6383
leaq 0x369a(%rip), %rcx      # 0x6393
movl $0xac, %edx
callq 0x2160
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/proxyclient.cpp
// Function: loopSend(int, ClientContext*)
void loopSend(int sockFd, ClientContext *ctx) {
    static char sendBuf[] = "Hello Server!";
    while (true) {
        ssize_t sendCode = sendMessage(sockFd, (const uint8_t *)sendBuf, sizeof(sendBuf), ctx);
        if (sendCode < 0) {
            LogHelper::log(Error, "Fail to send msg to Server, break");
            break;
        }
        LogHelper::log(Debug, "Send hello to server");
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
pushq $0x4
popq %r12
leaq 0x36d8(%rip), %r13      # 0x63f6
pushq $0x3
popq %r14
movq %rsp, %r15
movl %ebp, %edi
leaq 0x84b2(%rip), %rsi      # 0xb1e0
pushq $0xe
popq %rdx
movq %rbx, %rcx
movl %r12d, %r8d
callq 0x295a
testq %rax, %rax
js 0x2d60
movl %r14d, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x26e8
movq $0xa, (%rsp)
movq %r15, %rdi
callq 0x3bd4
jmp 0x2d25
leaq 0x366d(%rip), %rsi      # 0x63d4
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/proxyclient.cpp
// Function: loopRead(int, ClientContext*)
void loopRead(int sockFd, ClientContext *ctx) {
    static char buf[65536];
    while (true) {
        memset(buf, 0, sizeof(buf));
        ssize_t recvCode = recvMessage(sockFd, (uint8_t *)buf, sizeof(buf), ctx, NULL);
        if (recvCode < 0) {
            LogHelper::log(Error, "Fail to recv msg from server, break");
            break;
        }
        LogHelper::log(Debug, "recv msg from server: %s", buf);
        // std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x5847d(%rip), %r14     # 0x5b210
leaq 0x3695(%rip), %r15      # 0x642f
pushq $0x3
popq %r12
movl $0x10000, %edx          # imm = 0x10000
movq %r14, %rdi
xorl %esi, %esi
callq 0x2140
movl $0x10000, %edx          # imm = 0x10000
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x2ac7
testq %rax, %rax
js 0x2dd9
movl %r12d, %edi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x26e8
jmp 0x2d9e
leaq 0x362b(%rip), %rsi      # 0x640b
xorl %edi, %edi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x26e8
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/proxyclient.cpp
// Function: launch_client()
int launch_client() {

    // ignore signal
    signal(SIGPIPE, SIG_IGN);
    const char tempBuf[] = "Hello, test!";
    while (true) {
        ClientContext context;
        if (SocketPlugin::getInstance()->connectSocket(serverAddrStr.c_str(),  serverListenPort, constants::clientNonBlocking) < 0 ) {
            LogHelper::log(Error, "Client Fail to connect to server");
            std::this_thread::sleep_for(std::chrono::milliseconds(200));
            break;
        }
        ssize_t shakeCode = clientHandleShake(&context);
        if (shakeCode < 0) {
            return shakeCode;
        }
        
        LogHelper::log(Debug, "Hand shake success");
        int sockFd = SocketPlugin::getInstance()->getSockFd();
        // std::thread readThread(loopRead, sockFd, &context), writeThread(loopSend, sockFd, &context);
        // readThread.join();
        // writeThread.join();
        std::thread listenThread(startListen, sockFd, &context);
        listenThread.join();

        SocketPlugin::getInstance()->closeSocket();
        // break;
        std::this_thread::sleep_for(std::chrono::milliseconds(20));
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x2250
pushq $0x1
popq %rbx
leaq 0x20(%rsp), %r14
leaq 0x18(%rsp), %r13
leaq 0xc(%rsp), %r15
leaq 0x10(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
callq 0x3b6c
movq 0x778e(%rip), %rsi      # 0xb210
movq %rax, %rdi
movl $0x1bb, %edx            # imm = 0x1BB
movl %ebx, %ecx
callq 0x420c
testl %eax, %eax
js 0x3b19
movq %r14, %rdi
callq 0x27ec
testq %rax, %rax
js 0x3b3f
pushq $0x3
popq %rdi
leaq 0x3055(%rip), %rsi      # 0x6b09
xorl %eax, %eax
callq 0x26e8
callq 0x3b6c
movq %rax, %rdi
callq 0x4290
movl %eax, 0xc(%rsp)
movq %r14, 0x10(%rsp)
movq %r13, %rdi
leaq -0x609(%rip), %rsi      # 0x34d2
movq %r15, %rdx
movq %rbp, %rcx
callq 0x3c2a
movq %r13, %rdi
callq 0x2340
callq 0x3b6c
movq %rax, %rdi
callq 0x424c
movq $0x14, 0x10(%rsp)
movq %rbp, %rdi
callq 0x3bd4
movq %r13, %rdi
callq 0x3caa
jmp 0x3a6e
leaq 0x2fc8(%rip), %rsi      # 0x6ae8
xorl %r12d, %r12d
xorl %edi, %edi
xorl %eax, %eax
callq 0x26e8
leaq 0x18(%rsp), %rdi
movq $0xc8, (%rdi)
callq 0x3bd4
jmp 0x3b42
movq %rax, %r12
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3b56
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3caa
movq %rbx, %rdi
callq 0x2350
nop
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/./Singleton.h
// Function: Singleton<SocketPlugin>::getInstance()
static T* getInstance() {
        if(_instance == nullptr) {
            std::lock_guard<std::mutex> lockGuard(singleMutex);
            if(_instance == nullptr)
                _instance = new T();
        }
        return _instance;
    }

// Assembly:
pushq %rbx
movq 0x87944(%rip), %rax     # 0x8b4b8
testq %rax, %rax
jne 0x3bbb
leaq 0x87940(%rip), %rdi     # 0x8b4c0
callq 0x3d4a
cmpq $0x0, 0x8792b(%rip)     # 0x8b4b8
jne 0x3ba8
pushq $0x10
popq %rdi
callq 0x2220
leaq 0x7182(%rip), %rcx      # 0xad20
movq %rcx, (%rax)
movq %rax, 0x87910(%rip)     # 0x8b4b8
leaq 0x87911(%rip), %rdi     # 0x8b4c0
callq 0x2180
movq 0x878fd(%rip), %rax     # 0x8b4b8
popq %rbx
retq
movq %rax, %rbx
leaq 0x878f9(%rip), %rdi     # 0x8b4c0
callq 0x2180
movq %rbx, %rdi
callq 0x2350
// File: /workspace/github_cpp_makefile_star2_O2/renzibei[P]TSProxy/SocketPlugin.cpp
// Function: SocketPlugin::closeSocket()
int SocketPlugin::closeSocket() {

    int ret = close(this->m_sockfd);
    if(ret == -1) {
        LogHelper::log(Error, "close socket failed", strerror(errno));
    }
    LogHelper::log(Info, "close socket");
    return ret;
}

// Assembly:
pushq %rbx
movl 0x8(%rdi), %edi
callq 0x2390
movl %eax, %ebx
cmpl $-0x1, %eax
jne 0x427b
callq 0x2040
movl (%rax), %edi
callq 0x20e0
leaq 0x2946(%rip), %rsi      # 0x6bb5
xorl %edi, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x26e8
leaq 0x2947(%rip), %rsi      # 0x6bc9
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x26e8
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/gasparfm[P]anapache/anapacheapp.cpp
// Function: AnapacheApp::fixLogFormat(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string AnapacheApp::fixLogFormat(std :: string lf)
{
  if ( (lf.front()=='"') && (lf.back()=='"') )
    lf = lf.substr(1, lf.length()-2);

  lf = GCommon::replace(lf, "\\\"", "\"");
  return lf;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movq (%rdx), %rax
cmpb $0x22, (%rax)
jne 0x434b
movq 0x8(%r14), %rcx
cmpb $0x22, -0x1(%rax,%rcx)
jne 0x434b
addq $-0x2, %rcx
leaq 0x70(%rsp), %r15
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x3370
movq %r14, %rdi
movq %r15, %rsi
callq 0x3420
movq %r15, %rdi
callq 0x35d8
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x3460
leaq 0x4e72(%rip), %rsi      # 0x91d1
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x3d2c
leaq 0x4e5d(%rip), %rsi      # 0x91d2
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x3d2c
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x10(%rsp), %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x7c40
leaq 0x70(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3420
movq %r15, %rdi
callq 0x35d8
leaq 0x10(%rsp), %rdi
callq 0x35d8
leaq 0x30(%rsp), %rdi
callq 0x35d8
leaq 0x50(%rsp), %rdi
callq 0x35d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3430
movq %rbx, %rax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x35d8
jmp 0x4406
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x35d8
jmp 0x4415
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x35d8
movq %rbx, %rdi
callq 0x3530
nop
// File: /workspace/github_cpp_makefile_star2_O2/gasparfm[P]anapache/anapacheapp.cpp
// Function: AnapacheApp::ipCount_Input(long, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&, AnapacheApp::AnalizerOptions)
void AnapacheApp::ipCount_Input(time_t moment, ParsedInput & parsed, AnalizerOptions opts)
{
  auto ipAddress = parsed.find("h");
  if (ipAddress == parsed.end())
    {
      std::cerr << "No IP found on request"<<std::endl;
      return;
    }

  auto fip = ipCount_data.queryCount.find(ipAddress->second);
  if (fip == ipCount_data.queryCount.end())
    ipCount_data.queryCount.insert({ipAddress->second, 1});
  else
    fip->second++;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdx, %r15
movq %rdi, %rbx
leaq 0x4a4e(%rip), %rsi      # 0x9346
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3d2c
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x6988
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x35d8
addq $0x8, %r15
cmpq %r15, %r14
je 0x494c
leaq 0x78(%rbx), %r15
addq $0x40, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x69c6
subq $-0x80, %rbx
cmpq %rbx, %rax
je 0x4969
incq 0x40(%rax)
jmp 0x4996
movq 0x968d(%rip), %rdi      # 0xdfe0
leaq 0x4992(%rip), %rsi      # 0x92ec
callq 0x3330
movq %rax, %rdi
callq 0x3190
jmp 0x4996
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3460
movq $0x1, 0x20(%rbx)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x6a3c
leaq 0x8(%rsp), %rdi
callq 0x35d8
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x49a2
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x35d8
jmp 0x49b4
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3530