LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Parser.hpp
// Function: Parser::extractAddrPort(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::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void extractAddrPort(std::string & url, std::string & hostname, std::string & port)
	{
		// eg: http://people.duke.edu/~bmr23/ece568/
		// url: http://people.duke.edu/~bmr23/ece568/
		// hostname: people.duke.edu
		// port: 80
		if(url.find("http://") == 0)
		{
			// port number
			port = "80";

			// hostname
			int idx = 0;
			int N = url.length();
			int slash = 0;
			for(; idx < N; ++idx)
			{
				slash += url[idx] == '/';
				if(slash == 3) // "http://" has two slash
				{
					break;
				}
			}
			hostname = url.substr(7, idx - 7);
		}

		// eg: github.com:443
		// url: github.com
		// hostname: github.com
		// port: 443
		else
		{
			int idx = url.find_last_of(':');
			hostname = url.substr(0, idx);
			url = url.substr(0, idx);
			port = "443";
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
leaq 0x478a(%rip), %rsi      # 0xa1df
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3540
testq %rax, %rax
je 0x5ad5
pushq $0x3a
popq %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x3530
movslq %eax, %r12
movq %rsp, %r13
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0x3330
movq %r14, %rdi
movq %r13, %rsi
callq 0x3370
movq %r13, %rdi
callq 0x3150
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0x3330
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3370
movq %r14, %rdi
callq 0x3150
leaq 0x471f(%rip), %rsi      # 0xa1ea
movq %r15, %rdi
callq 0x3500
jmp 0x5b3b
leaq 0x470b(%rip), %rsi      # 0xa1e7
movq %r15, %rdi
callq 0x3500
movl 0x8(%rbx), %eax
movq (%rbx), %rcx
testl %eax, %eax
cmovlel %r12d, %eax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x5b11
xorl %esi, %esi
cmpb $0x2f, (%rcx,%rdx)
sete %sil
addl %esi, %r12d
cmpl $0x3, %r12d
je 0x5b0f
incq %rdx
jmp 0x5af2
movl %edx, %eax
addl $-0x7, %eax
movslq %eax, %rcx
movq %rsp, %r15
pushq $0x7
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3330
movq %r14, %rdi
movq %r15, %rsi
callq 0x3370
movq %r15, %rdi
callq 0x3150
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./LRUCache.hpp
// Function: LRUCache::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
Response get(const std::string & url) 
    {
        std::unique_lock<std::mutex> lck(mtx1);

        // url doesn't exist in cache
        if(!existsUrl(url))
        {
            throw ProxyException("Url doesn't exist in cache");
        }

        Response ret = kv[url];
        cache.remove(url);
        cache.push_back(url);
        return ret;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xa4fc(%rip), %rsi      # 0x102d8
leaq 0x8(%rsp), %rdi
callq 0x5cd6
movq %r15, %rdi
movq %r14, %rsi
callq 0x5d66
testb %al, %al
je 0x5e3e
leaq 0x20(%r15), %rdi
movq %r14, %rsi
callq 0x6976
movq %rbx, %rdi
movq %rax, %rsi
callq 0x67fc
addq $0x8, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x68f8
movq %r15, %rdi
movq %r14, %rsi
callq 0x696a
leaq 0x8(%rsp), %rdi
callq 0x5cec
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x4515(%rip), %rsi      # 0xa365
leaq 0x18(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0x9e90(%rip), %rsi      # 0xfd08
leaq -0x861(%rip), %rdx      # 0x561e
movq %rbx, %rdi
callq 0x3490
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x3150
testb %bpl, %bpl
jne 0x5e9e
jmp 0x5eb8
movq %rax, %r14
movq %rbx, %rdi
callq 0x3240
jmp 0x5eb8
movq %rax, %r14
movq %rbx, %rdi
callq 0x3c54
jmp 0x5eb8
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5cec
movq %r14, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::respondCached(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void respondCached(int client_fd, const std::string & url)
	{
		// send response to the client
		Response response = cache.get(url);
		for(const auto & seg : response.content)
		{
			int sent_length = 0;
			int length_to_be_sent = seg.size();
			while(sent_length < length_to_be_sent)
			{
				int len = send(client_fd, &seg.data()[0] + sent_length, length_to_be_sent - sent_length, 0);
				if(len == -1)
				{
					throw ProxyException("Send with cached response error");
				}
				sent_length += len;
			}
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movl %esi, %ebx
leaq 0x250(%rdi), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x5dc2
movq 0x68(%r14), %r15
movq 0x70(%r14), %r14
cmpq %r14, %r15
je 0x5f2f
movl 0x8(%r15), %ebp
subl (%r15), %ebp
xorl %r12d, %r12d
movl %ebp, %eax
subl %r12d, %eax
jle 0x5f29
movslq %r12d, %rsi
addq (%r15), %rsi
movslq %eax, %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x31a0
addl %eax, %r12d
cmpl $-0x1, %eax
jne 0x5f06
jmp 0x5f49
addq $0x18, %r15
jmp 0x5ef7
leaq 0x28(%rsp), %rdi
callq 0x3c54
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x4425(%rip), %rsi      # 0xa380
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0x9d85(%rip), %rsi      # 0xfd08
leaq -0x96c(%rip), %rdx      # 0x561e
movq %rbx, %rdi
callq 0x3490
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x3150
testb %bpl, %bpl
jne 0x5fa9
jmp 0x5fb6
movq %rax, %r14
movq %rbx, %rdi
callq 0x3240
jmp 0x5fb6
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x3c54
movq %r14, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::insertSectionToContent(std::vector<char, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::vector<char> insertSectionToContent(const std::vector<char> & content, const std::string & section)
	{
		int idx = findFirstLine(content); // idx is the index of the '\r' in the first line of response
		std::vector<char> content_to_send(content.begin(), content.begin() + idx);
		for(char c : section) content_to_send.push_back(c);
		content_to_send.insert(content_to_send.end(), content.begin() + idx, content.end());
		return content_to_send;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x7274
movq %r14, 0x10(%rsp)
movq (%r14), %rsi
movslq %eax, %r15
leaq (%rsi,%r15), %rdx
leaq 0xf(%rsp), %rcx
movq %rbx, %rdi
callq 0x72a4
movq (%r12), %r13
movq 0x8(%r12), %rbp
xorl %r14d, %r14d
leaq 0xe(%rsp), %r12
cmpq %r14, %rbp
je 0x60ab
movb (%r13,%r14), %al
movb %al, 0xe(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x72d6
incq %r14
jmp 0x608d
movq 0x8(%rbx), %rsi
movq 0x10(%rsp), %rax
addq (%rax), %r15
movq 0x8(%rax), %rcx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x72f0
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x60da
movq %rax, %r14
movq %rbx, %rdi
callq 0x3dda
movq %r14, %rdi
callq 0x34b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Response.hpp
// Function: Response::Response()
Response() : 
		status_code { -1 },
		no_store { false },
		no_cache { false },
		has_expiration { false },
		cur_time { 0 },
		expiration_time { 0 },
		last_modified { 0 }
		{}

// Assembly:
orl $-0x1, (%rdi)
leaq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
xorl %eax, %eax
movb %al, 0x18(%rdi)
leaq 0x38(%rdi), %rcx
movq %rcx, 0x28(%rdi)
andq $0x0, 0x30(%rdi)
movb %al, 0x38(%rdi)
leaq 0x58(%rdi), %rcx
movq %rcx, 0x48(%rdi)
andq $0x0, 0x50(%rdi)
movb %al, 0x58(%rdi)
xorps %xmm0, %xmm0
andq $0x0, 0x78(%rdi)
movups %xmm0, 0x68(%rdi)
leaq 0xb0(%rdi), %rcx
movq %rcx, 0x80(%rdi)
movq $0x1, 0x88(%rdi)
movups %xmm0, 0x90(%rdi)
movl $0x3f800000, 0xa0(%rdi) # imm = 0x3F800000
leaq 0xe8(%rdi), %rcx
movups %xmm0, 0xa8(%rdi)
andl $0x0, 0xb7(%rdi)
movups %xmm0, 0xc0(%rdi)
andq $0x0, 0xd0(%rdi)
movq %rcx, 0xd8(%rdi)
andq $0x0, 0xe0(%rdi)
movb %al, 0xe8(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::checkStatusCode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool checkStatusCode(const std::string & header)
	{
		int idx = header.find("\r\n");
		int i = 0;
		for(; i + 2 <= idx; ++i)
		{
			if(header[i] == '3' && header[i + 1] == '0' && header[i + 2] == '4')
			{
				return true;
			}
		}
		return false;
	}

// Assembly:
pushq %rbx
movq %rsi, %rbx
leaq 0x2f3a(%rip), %rsi      # 0xa537
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3540
movq (%rbx), %rcx
cltq
pushq $0x2
popq %rdx
cmpq %rax, %rdx
jg 0x762d
cmpb $0x33, -0x2(%rcx,%rdx)
jne 0x7628
cmpb $0x30, -0x1(%rcx,%rdx)
jne 0x7628
cmpb $0x34, (%rcx,%rdx)
je 0x762d
incq %rdx
jmp 0x760f
cmpq %rax, %rdx
setle %al
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::respondClient(int, std::vector<char, std::allocator<char>> const&, int)
bool respondClient(int client_fd, const std::vector<char> & buffer, int received_length)
	{
		int sent_length = 0;
		while(sent_length < received_length)
		{
			int len = send(client_fd, &buffer.data()[0] + sent_length, received_length, 0);	
			if(len == -1)
			{
				return false;
			}
			sent_length += len;
		}
		return true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebx
movq %rdx, %r14
movl %esi, %ebp
movslq %ecx, %r15
xorl %ecx, %ecx
movl %ecx, %r12d
cmpl %ebx, %ecx
jge 0x769e
movslq %r12d, %rsi
addq (%r14), %rsi
movl %ebp, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x31a0
leal (%r12,%rax), %ecx
cmpl $-0x1, %eax
jne 0x767c
cmpl %ebx, %r12d
setge %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Parser.hpp
// Function: Parser::extractContentLength(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int extractContentLength(const std::string & header)
	{
		// start extract content length
		int res = 0;
		int idx = header.find("Content-Length");
		int N = header.length();
		bool digit_found = false;
		for(int i = idx; i < N; ++i)
		{
			char c = header[i];
			if(digit_found && isdigit(c))
			{
				res = res * 10 + (c - '0');
			}
			else if(digit_found && !isdigit(c))
			{
				break;
			}
			else if(!digit_found && isdigit(c))
			{
				digit_found = true;
				res = c - '0';
			}
		}
		return res;
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x21ca(%rip), %rsi      # 0xa46e
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3540
movslq 0x8(%rbx), %rcx
movq (%rbx), %rdx
movslq %eax, %rsi
xorl %eax, %eax
cmpq %rcx, %rsi
jge 0x82f5
movsbl (%rdx,%rsi), %edi
addl $-0x30, %edi
cmpl $0xa, %edi
setb %r8b
testb $0x1, %r14b
je 0x82e7
cmpl $0x9, %edi
ja 0x82f5
imull $0xa, %eax, %eax
addl %eax, %edi
movb $0x1, %r8b
movl %edi, %eax
jmp 0x82ed
cmpl $0xa, %edi
cmovbl %edi, %eax
incq %rsi
movl %r8d, %r14d
jmp 0x82bd
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Response.hpp
// Function: Response::Response(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::vector<char, std::allocator<char>>, std::allocator<std::vector<char, std::allocator<char>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Response(const std::string _url, std::vector<std::vector<char>> buffer, const std::string h) : 
		status_code { -1 },
		url { _url },
		header { h },
		content { buffer },
		no_store { false }, // default can be stored in the cache
		no_cache { false }, // default can be cached in the cache(need to check e-tag)
		has_expiration { false }, // has expiration calculation machanism
		cur_time { time(NULL) },
		expiration_time { 0 },
		last_modified { 0 }
		{}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r12
movq %rdi, %rbx
orl $-0x1, (%rdi)
leaq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movq %rdx, %r15
movb $0x0, 0x18(%rdi)
leaq 0x28(%rdi), %r14
movq %r14, %rdi
callq 0x33d0
leaq 0x48(%rbx), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x33d0
leaq 0x68(%rbx), %rdi
movq %r15, %rsi
callq 0x6dc2
leaq 0xb0(%rbx), %rax
movq %rax, 0x80(%rbx)
movq $0x1, 0x88(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x90(%rbx)
movl $0x3f800000, 0xa0(%rbx) # imm = 0x3F800000
movups %xmm0, 0xa8(%rbx)
andl $0x0, 0xb7(%rbx)
xorl %edi, %edi
callq 0x32e0
movq %rax, 0xc0(%rbx)
leaq 0xe8(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0xc8(%rbx)
movq %rax, 0xd8(%rbx)
andq $0x0, 0xe0(%rbx)
movb $0x0, 0xe8(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %r15
movq %r13, %rdi
callq 0x3150
jmp 0x83d5
movq %rax, %r15
movq %r14, %rdi
callq 0x3150
jmp 0x83e2
movq %rax, %r15
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x3150
movq %r15, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Parser.hpp
// Function: Parser::parseResponse(Response&)
void parseResponse(Response & response)
	{
		extractFirstLine(response);
		extractKV(response);
		extractAttri(response);	
		calcExpiration(response);
		extractLastModified(response);
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x8534
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8610
movq %r14, %rdi
movq %rbx, %rsi
callq 0x884c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x89c8
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x8ad2
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./LRUCache.hpp
// Function: LRUCache::put(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, Response const&)
void put(const std::string & url, const Response & response) 
    {
        std::unique_lock<std::mutex> lck(mtx1);
        if(existsUrl(url))
        {
            cache.remove(url);
            kv[url] = response;
        }
        else
        {
            if(sz == capacity)
            {
                const std::string & url = cache.front(); cache.pop_front();
                kv.erase(url);
            }
            else
            {
                ++sz;
            }
            kv.insert(std::make_pair(url, response));
        }
        cache.push_back(url);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x7e82(%rip), %rsi      # 0x102d8
movq %rsp, %rdi
callq 0x5cd6
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5d66
testb %al, %al
je 0x8492
leaq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x68f8
leaq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x6976
movq %rax, %rdi
movq %r15, %rsi
callq 0x9050
jmp 0x84e7
movl (%r14), %eax
cmpl 0x4(%r14), %eax
jne 0x84ba
leaq 0x8(%r14), %rdi
movq 0x8(%r14), %r12
addq $0x10, %r12
callq 0x910e
leaq 0x20(%r14), %rdi
movq %r12, %rsi
callq 0x966c
jmp 0x84bf
incl %eax
movl %eax, (%r14)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x98c4
leaq 0x20(%r14), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9780
leaq 0x10(%rsp), %rdi
callq 0x9116
addq $0x8, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x696a
movq %rsp, %rdi
callq 0x5cec
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x8520
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x9116
jmp 0x8523
jmp 0x8520
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5cec
movq %rbx, %rdi
callq 0x34b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Parser.hpp
// Function: Parser::extractFirstLine(Response&)
void extractFirstLine(Response & response)
	{
		// first line
		const std::string header = response.header;
		for(char c : header)
		{
			if(c == '\r')
			{
				break;
			}
			else
			{
				response.first_line += c;
			}
		}

		// status code
		// eg: first line: HTTP/1.1 200 OK
		const std::string & first_line = response.first_line;
		int idx1 = first_line.find_first_of(' ');
		int idx2 = first_line.find_last_of(' ');
		response.status_code = std::stoi(first_line.substr(idx1, idx2 - idx1)); // [idx1, idx2)
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
addq $0x48, %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x33d0
movq (%r14), %r15
movq 0x8(%r14), %r12
leaq 0x8(%rbx), %r14
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x8581
movb (%r15,%r13), %al
cmpb $0xd, %al
je 0x8581
movsbl %al, %esi
movq %r14, %rdi
callq 0x32a0
incq %r13
jmp 0x8564
pushq $0x20
popq %rbp
movq %r14, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x33b0
movq %rax, %r15
pushq $-0x1
popq %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0x3530
movslq %r15d, %rdx
subl %edx, %eax
movslq %eax, %rcx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3330
leaq 0x8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x8bb1
movl %eax, (%rbx)
leaq 0x8(%rsp), %rdi
callq 0x3150
leaq 0x28(%rsp), %rdi
callq 0x3150
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3150
jmp 0x85fd
jmp 0x85fa
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x34b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Parser.hpp
// Function: Parser::extractAttri(Response&)
void extractAttri(Response & response)
	{
		std::unordered_map<std::string, std::string> & kv = response.kv; 

		// no-store and no-cache attribute
		if(kv.find("Cache-Control") != kv.end())
		{
			std::string cache_control = kv["Cache-Control"];
			if(cache_control.find("no-store") != -1)
			{
				response.no_store = true;
			}
			if(cache_control.find("no-cache") != -1)
			{
				response.no_cache = true;
			}
		}

		// e-tag
		if(kv.find("ETag") != kv.end())
		{
			response.etag = kv["ETag"];
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
leaq 0x1c88(%rip), %rsi      # 0xa4e7
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x386c
leaq 0x80(%rbx), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9022
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x3150
testq %r15, %r15
je 0x891c
leaq 0x1c48(%rip), %rsi      # 0xa4e7
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x386c
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x98fa
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x33d0
leaq 0x30(%rsp), %rdi
callq 0x3150
leaq 0x1c61(%rip), %rsi      # 0xa53a
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x3540
cmpq $-0x1, %rax
je 0x88f2
movb $0x1, 0xb8(%rbx)
leaq 0x1c4a(%rip), %rsi      # 0xa543
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x3540
cmpq $-0x1, %rax
je 0x8912
movb $0x1, 0xb9(%rbx)
leaq 0x10(%rsp), %rdi
callq 0x3150
leaq 0x1c29(%rip), %rsi      # 0xa54c
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x386c
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9022
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x3150
testq %r15, %r15
je 0x8990
leaq 0x1bf4(%rip), %rsi      # 0xa54c
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x386c
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x98fa
addq $0xd8, %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x31e0
leaq 0x10(%rsp), %rdi
callq 0x3150
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x89a4
jmp 0x89a4
jmp 0x89a9
jmp 0x89a4
jmp 0x89a9
movq %rax, %rbx
jmp 0x89c0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x89bb
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Parser.hpp
// Function: Parser::calcExpiration(Response&)
void calcExpiration(Response & response)
	{
		std::unordered_map<std::string, std::string> & kv = response.kv;
		const time_t & response_time = response.cur_time;

		// get fressness time
		int fressness_time = 0;
		if(kv.find("Cache-Control") != kv.end())
		{
			const std::string & cache_control = kv["Cache-Control"];
			int idx = cache_control.find("max-age");
			if(idx != -1)
			{
				// eg: max-age=1234567
				std::string max_age_s = cache_control.substr(idx + 8);
				fressness_time = std::stoi(max_age_s);
			}
		}

		response.expiration_time = response.cur_time + fressness_time;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
leaq 0x1b0b(%rip), %rsi      # 0xa4e7
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
leaq 0x80(%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x9022
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x3150
testq %r15, %r15
je 0x8a95
leaq 0x1acb(%rip), %rsi      # 0xa4e7
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x98fa
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x3150
leaq 0x1b05(%rip), %rsi      # 0xa551
xorl %r15d, %r15d
movq %r14, %rdi
xorl %edx, %edx
callq 0x3540
cmpl $-0x1, %eax
je 0x8a98
addl $0x8, %eax
movslq %eax, %rdx
leaq 0x8(%rsp), %r15
pushq $-0x1
popq %rcx
movq %r15, %rdi
movq %r14, %rsi
callq 0x3330
pushq $0xa
popq %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x8bb1
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x3150
movslq %ebp, %r15
jmp 0x8a98
xorl %r15d, %r15d
addq 0xc0(%rbx), %r15
movq %r15, 0xc8(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8ab7
jmp 0x8ab7
jmp 0x8ac6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3150
jmp 0x8ac9
movq %rax, %rbx
movq %rbx, %rdi
callq 0x34b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Parser.hpp
// Function: Parser::extractLastModified(Response&)
void extractLastModified(Response & response)
	{
		std::unordered_map<std::string, std::string> & kv = response.kv;
		if(kv.find("Last-Modified") != kv.end())
		{
			const char * time = kv["Last-Modified"].c_str();
			struct tm tm;
			memset(&tm, 0, sizeof(struct tm));
			strptime(time, "%a, %d %b %Y %H:%M:%S %z", &tm);
			response.last_modified = mktime(&tm);
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
leaq 0x1856(%rip), %rsi      # 0xa33b
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x386c
leaq 0x80(%rbx), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x9022
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x3150
testq %r15, %r15
je 0x8b89
leaq 0x181a(%rip), %rsi      # 0xa33b
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x386c
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x98fa
movq (%rax), %r14
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x3150
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
andq $0x0, 0x30(%r15)
leaq 0x19ef(%rip), %rsi      # 0xa559
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x3050
movq %r15, %rdi
callq 0x3210
movq %rax, 0xd0(%rbx)
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x8b97
jmp 0x8ba6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3150
jmp 0x8ba9
movq %rax, %rbx
movq %rbx, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/./Response.hpp
// Function: Response::operator=(Response const&)
Response & operator=(const Response & rhs)
	{
		if(this != &rhs)
		{
			status_code = rhs.status_code;
			first_line = rhs.first_line;
			url = rhs.url;
			header = rhs.header;
			content = rhs.content;
			kv = rhs.kv;
			no_store = rhs.no_store;
			no_cache = rhs.no_cache;
			has_expiration = rhs.has_expiration;
			cur_time = rhs.cur_time;
			expiration_time = rhs.expiration_time;
			last_modified = rhs.last_modified;
			etag = rhs.etag;
		}
		return *this;
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq %rsi, %rdi
je 0x9103
movq %rsi, %r14
movl (%rsi), %eax
movl %eax, (%rbx)
addq $0x8, %rsi
leaq 0x8(%rbx), %rdi
callq 0x31e0
leaq 0x28(%r14), %rsi
leaq 0x28(%rbx), %rdi
callq 0x31e0
leaq 0x48(%r14), %rsi
leaq 0x48(%rbx), %rdi
callq 0x31e0
leaq 0x68(%r14), %rsi
leaq 0x68(%rbx), %rdi
callq 0x912c
movl $0x80, %edi
leaq (%r14,%rdi), %rsi
addq %rbx, %rdi
callq 0x9396
movb 0xb8(%r14), %al
movb %al, 0xb8(%rbx)
movb 0xb9(%r14), %al
movb %al, 0xb9(%rbx)
movb 0xba(%r14), %al
movb %al, 0xba(%rbx)
movups 0xc0(%r14), %xmm0
movups %xmm0, 0xc0(%rbx)
movq 0xd0(%r14), %rax
movq %rax, 0xd0(%rbx)
movl $0xd8, %edi
addq %rdi, %r14
addq %rbx, %rdi
movq %r14, %rsi
callq 0x31e0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::sendRequest(int, Request const&)
void sendRequest(int server_fd, const Request & request)
	{
		int sent_length = 0;
		int request_length = request.content.size();
		const char * content = &request.content.data()[0];
		while(sent_length < request_length)
		{
			int len = send(server_fd, content + sent_length, request_length - sent_length, 0);
			if(len == -1)
		    {
		        throw ProxyException("Proxy send client request error");
		    }
		    sent_length += len;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movl 0xc8(%rdx), %ebp
movq 0xc0(%rdx), %r14
subl %r14d, %ebp
xorl %r15d, %r15d
movl %ebp, %eax
subl %r15d, %eax
jle 0x9ac9
movslq %r15d, %rsi
addq %r14, %rsi
movslq %eax, %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x31a0
addl %eax, %r15d
cmpl $-0x1, %eax
jne 0x9a5f
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %rbx
leaq 0xae0(%rip), %rsi       # 0xa572
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0x624e(%rip), %rsi      # 0xfd08
leaq -0x44a3(%rip), %rdx     # 0x561e
movq %rbx, %rdi
callq 0x3490
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x3150
testb %bpl, %bpl
jne 0x9aeb
jmp 0x9af3
movq %rax, %r14
movq %rbx, %rdi
callq 0x3240
movq %r14, %rdi
callq 0x34b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/dentiny[P]HTTP-Cache-Proxy/Proxy.cpp
// Function: Proxy::getResponseHeader(int, std::vector<char, std::allocator<char>>&)
int getResponseHeader(int server_fd, std::vector<char> & buffer)
	{
		int len = recv(server_fd, &buffer.data()[0], BUFFER_SIZE, 0);
	    if(len == -1)
	    {
	    	throw ProxyException("Receive header error");
	    }
	    buffer[len] = '\0';
	    return len;
	}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdx, %rbx
movl %esi, %edi
movq (%rdx), %rsi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
callq 0x30e0
cmpl $-0x1, %eax
je 0x9dee
movslq %eax, %rcx
movq (%rbx), %rdx
movb $0x0, (%rdx,%rcx)
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x7ad(%rip), %rsi       # 0xa5ad
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x386c
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x55e8
xorl %ebp, %ebp
leaq 0x5ee0(%rip), %rsi      # 0xfd08
leaq -0x4811(%rip), %rdx     # 0x561e
movq %rbx, %rdi
callq 0x3490
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x3150
testb %bpl, %bpl
jne 0x9e4e
jmp 0x9e56
movq %rax, %r14
movq %rbx, %rdi
callq 0x3240
movq %r14, %rdi
callq 0x34b0
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/cps-tss.cc
// Function: parseargs(int, char**)
void parseargs(int argc, char *argv[]) {
    int	c;
    while ((c = getopt(argc, argv, "r:")) != -1) {
        switch (c) {
            case 'r':
                fpr = fopen(optarg, "r");
                break;
            default:
                break;
        }
    }

    
    if(fpr == NULL){
        printf("can't open ruleset file\n");
        exit(-1);
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x3c19(%rip), %r15      # 0x6020
movq 0x6bba(%rip), %r13      # 0x8fc8
leaq 0x3e0d(%rip), %r12      # 0x6222
movl %r14d, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2050
cmpl $0x72, %eax
je 0x242f
cmpl $-0x1, %eax
jne 0x2415
jmp 0x2444
movq (%r13), %rdi
movq %r12, %rsi
callq 0x2190
movq %rax, 0x6d0e(%rip)      # 0x9150
jmp 0x2415
cmpq $0x0, 0x6d04(%rip)      # 0x9150
je 0x245d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c2f(%rip), %rdi      # 0x6093
callq 0x21f0
pushq $-0x1
popq %rdi
callq 0x21a0
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/cps-tss.cc
// Function: remove_redund_pkg(std::vector<pc_rule, std::allocator<pc_rule>>&, std::vector<pc_rule, std::allocator<pc_rule>>&)
vector<pc_rule*> remove_redund_pkg(vector<pc_rule> &pc, vector<pc_rule> &pc_prefix) 
{
    rule_boundary rb;
    init_boundary(rb);
    
    //pc_prefix = pc;
    
    vector<pc_rule*> pcr;
    for_each(pc.begin(), pc.end(), [&pcr](pc_rule &r){pcr.push_back(&r);});
    cout<<"Orignal ruleset "<<pc.size()<<endl;

    remove_redund_rt(pcr, rb, false);
    extend_rules(pcr, pc_prefix);
    
    cout<<"After prefix explanation: "<< pc_prefix.size()<<endl;

    vector<pc_rule*> pc_pprefix;
    for_each(pc_prefix.begin(), pc_prefix.end(), [&pc_pprefix](pc_rule &r){pc_pprefix.push_back(&r);});

    return move(pc_pprefix);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, -0x38(%rbp)
movq %rsi, %r15
movq %rdi, -0x30(%rbp)
xorps %xmm0, %xmm0
leaq -0xd0(%rbp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x3124
leaq -0x80(%rbp), %r12
andq $0x0, 0x10(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movq (%r15), %rbx
movq 0x8(%r15), %r14
leaq -0x60(%rbp), %r13
cmpq %r14, %rbx
je 0x24ec
movq %rbx, -0x60(%rbp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2c1a
addq $0x88, %rbx
jmp 0x24cf
movq 0x6ae5(%rip), %rdi      # 0x8fd8
leaq 0x3b29(%rip), %rsi      # 0x6023
callq 0x2130
movq -0x38(%rbp), %r14
movq %rax, %rdi
movq 0x8(%r15), %rax
subq (%r15), %rax
movl $0x88, %ecx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x20c0
movq %rax, %rdi
callq 0x2090
leaq -0x80(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
xorl %edx, %edx
callq 0x3575
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x41cd
movq 0x6a8c(%rip), %rdi      # 0x8fd8
leaq 0x3ae1(%rip), %rsi      # 0x6034
callq 0x2130
movq %rax, %rdi
movq 0x8(%r14), %rax
subq (%r14), %rax
movl $0x88, %ecx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x20c0
movq %rax, %rdi
callq 0x2090
xorps %xmm0, %xmm0
leaq -0x60(%rbp), %r15
andq $0x0, 0x10(%r15)
movaps %xmm0, (%r15)
movq (%r14), %rbx
movq 0x8(%r14), %r12
leaq -0x40(%rbp), %r14
cmpq %r12, %rbx
je 0x25b4
movq %rbx, -0x40(%rbp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x2c1a
addq $0x88, %rbx
jmp 0x2597
leaq -0x60(%rbp), %rdi
movq (%rdi), %rax
movq -0x30(%rbp), %rbx
movq %rax, (%rbx)
movq 0x8(%rdi), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rdi), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
callq 0x2c06
leaq -0x80(%rbp), %rdi
callq 0x2c06
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2610
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2c06
jmp 0x2613
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x2c06
movq %rbx, %rdi
callq 0x2230
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/cps-tss.cc
// Function: bitstring_from_rule(pc_rule*)
array<char, MAX_BITS> bitstring_from_rule(pc_rule *rule) 
{
    array<char, MAX_BITS> bitstring;
    int pos = 0;
    for(int i = 2; i < 4; i++) {
        int prefixlen;
        if(i == 0 || i == 1) 
            prefixlen = 32 - __builtin_popcount(rule->field[i].high - rule->field[i].low);
        if(i == 2 || i == 3)
            prefixlen = 16 - __builtin_popcount(rule->field[i].high - rule->field[i].low);
        if( i == 4) 
            prefixlen = 8 - __builtin_popcount(rule->field[i].high - rule->field[i].low);

        int tail = __builtin_popcount(rule->field[i].high - rule->field[i].low);

        uint32_t bits = rule->field[i].high >> tail;
        for(int j = prefixlen -1; j >= 0; j--) {
            //from high to low bits 
            if(bits & (1ULL<< j)) {
                bitstring[pos + prefixlen-j-1] = '1';
            }
            else {
                bitstring[pos + prefixlen-j-1] = '0';
            }
        }
        for(int j = 0; j< tail; j++) {
            bitstring[j+prefixlen+pos] = '*';
        }

        if(i==0 || i == 1) {
            pos += 32;
        }
        if(i==2 || i == 3) {
            pos += 16;
        }
        if(i==4)
            pos += 8;
    }
    return move(bitstring);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rax
addq $0x8, %rsi
movabsq $0x2, %rdi
leaq -0x40(%rbp), %r8
movl $0x10, %r9d
movl $0x33333333, %r10d      # imm = 0x33333333
movabsq $0x1, %r11
movl %r9d, %ebx
cmpq $0x4, %rdi
je 0x28bb
movq %rdi, %rcx
shlq $0x4, %rcx
movq 0x8(%rsi,%rcx), %r14
movl (%rsi,%rcx), %ecx
movl %r14d, %edx
subl %ecx, %edx
movl %edx, %ecx
shrl %ecx
andl $0x55555555, %ecx       # imm = 0x55555555
subl %ecx, %edx
movl %edx, %ecx
andl %r10d, %ecx
shrl $0x2, %edx
andl %r10d, %edx
addl %ecx, %edx
movl %edx, %ecx
shrl $0x4, %ecx
addl %edx, %ecx
andl $0xf0f0f0f, %ecx        # imm = 0xF0F0F0F
imull $0x1010101, %ecx, %edx  # imm = 0x1010101
shrl $0x18, %edx
movl %r9d, %r15d
movl %edx, %ecx
shrq %cl, %r14
subl %edx, %r15d
movl %r14d, %r14d
movslq %r15d, %rcx
movq %r8, %r15
testq %rcx, %rcx
jle 0x288c
decq %rcx
movq %r11, %r12
shlq %cl, %r12
testl %r12d, %r14d
sete %r12b
xorb $0x31, %r12b
movb %r12b, (%r15)
incq %r15
jmp 0x286b
movl %ebx, %ecx
subl %edx, %ecx
movslq %ecx, %rcx
addq %rbp, %rcx
addq $-0x40, %rcx
xorl %r14d, %r14d
cmpq %r14, %rdx
je 0x28ac
movb $0x2a, (%rcx,%r14)
incq %r14
jmp 0x289d
incq %rdi
addq $0x10, %r8
addl $0x10, %ebx
jmp 0x280a
movups -0x40(%rbp), %xmm0
movups -0x30(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/cps-tss.cc
// Function: print_bitstring(std::vector<pc_rule*, std::allocator<pc_rule*>>&)
void print_bitstring(vector<pc_rule*> &pc) 
{
    array<char, MAX_BITS> bitstring;
    int old_priority;
    for(auto rule = pc.begin(); rule != pc.end(); rule ++) {
        if((*rule)->priority != old_priority) {
            old_priority = (*rule)->priority;
            cout<<endl;
            cout<<(*rule)->priority<<endl;
        }
        bitstring = bitstring_from_rule(*rule);
        for_each(bitstring.begin(), bitstring.begin() + 32, [](char c){cout<<c<<" ";});
        cout<<endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, -0x30(%rbp)
movq (%rdi), %r13
movq 0x66e6(%rip), %r15      # 0x8fd8
leaq 0x3754(%rip), %r12      # 0x604d
movq -0x30(%rbp), %rax
cmpq 0x8(%rax), %r13
je 0x2972
movq (%r13), %rsi
movl (%rsi), %r14d
cmpl %ebx, %r14d
je 0x2934
movq %r15, %rdi
callq 0x2090
movq (%r13), %rax
movl (%rax), %esi
movq %r15, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2090
movq (%r13), %rsi
movl %r14d, %ebx
leaq -0x50(%rbp), %rdi
callq 0x27d1
xorl %r14d, %r14d
cmpq $0x20, %r14
je 0x2964
movsbl -0x50(%rbp,%r14), %esi
movq %r15, %rdi
callq 0x2180
movq %rax, %rdi
movq %r12, %rsi
callq 0x2130
incq %r14
jmp 0x2940
movq %r15, %rdi
callq 0x2090
addq $0x8, %r13
jmp 0x28f9
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/cps-tss.cc
// Function: get_tuple(std::array<char, 32ul>&)
array<int, MAXDIMENSIONS> get_tuple(array<char, MAX_BITS> &bitstring) 
{
    array<int, MAXDIMENSIONS> field_prefixlen;
    field_prefixlen.fill(0);
    int start_pos[MAXDIMENSIONS] = {0, 32, 64, 80, 96}; 
    int bits[MAXDIMENSIONS] = {32,32,16,16,8};
    for(int i = 0; i < MAXDIMENSIONS; i++) {    
        int spos = start_pos[i];
        for(int j = spos; j < spos + bits[i]; j++) {
            if(bitstring[j] != '*') {
                field_prefixlen[i]++;
            }
        }

    }
    return move(field_prefixlen);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x14(%rbp), %rsi
andl $0x0, (%rsi)
leaq -0x28(%rbp), %rdi
callq 0x2b88
xorl %eax, %eax
leaq 0x3705(%rip), %rcx      # 0x60b0
leaq 0x371e(%rip), %rdx      # 0x60d0
cmpq $0x5, %rax
je 0x29dd
movslq (%rcx,%rax,4), %rsi
movslq (%rdx,%rax,4), %rdi
addq %rsi, %rdi
cmpq %rdi, %rsi
jge 0x29d8
cmpb $0x2a, (%r14,%rsi)
je 0x29d3
incl -0x28(%rbp,%rax,4)
incq %rsi
jmp 0x29c3
incq %rax
jmp 0x29b2
movl -0x18(%rbp), %eax
movl %eax, 0x10(%rbx)
movups -0x28(%rbp), %xmm0
movups %xmm0, (%rbx)
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/cps-tss.cc
// Function: main
int main(int argc, char *argv[])
{

    vector<pc_rule> pc_orig;
    vector<pc_rule> pc_prefix;
    vector<pc_rule*> pc;

    parseargs(argc, argv);
    loadrules(fpr, pc_orig);

    vector<pc_rule*> pc_r = remove_redund_pkg(pc_orig, pc_prefix);
    cout<<"load "<<pc_r.size()<<" rules"<<endl;

    //freopen ("tuple.txt","w",stdout);
    tuples_num(pc_r);
    freopen ("prefix.txt","w",stdout);
    print_bitstring(pc_r);
    fclose(stdout);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
xorps %xmm0, %xmm0
leaq -0x80(%rbp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movaps %xmm0, -0x40(%rbp)
andq $0x0, -0x30(%rbp)
movaps %xmm0, -0x60(%rbp)
andq $0x0, -0x50(%rbp)
callq 0x23ec
movq 0x6724(%rip), %rdi      # 0x9150
movq %rbx, %rsi
callq 0x3290
leaq -0x20(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x2471
movq 0x658c(%rip), %rdi      # 0x8fd8
leaq 0x360c(%rip), %rsi      # 0x605f
callq 0x2130
movq -0x18(%rbp), %rsi
subq -0x20(%rbp), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x20c0
leaq 0x35f2(%rip), %rsi      # 0x6065
movq %rax, %rdi
callq 0x2130
movq %rax, %rdi
callq 0x2090
leaq -0x20(%rbp), %rdi
callq 0x2624
movq 0x6525(%rip), %rbx      # 0x8fb8
movq (%rbx), %rdx
leaq 0x35cf(%rip), %rdi      # 0x606c
leaq 0x35d3(%rip), %rsi      # 0x6077
callq 0x2170
leaq -0x20(%rbp), %rdi
callq 0x28d3
movq (%rbx), %rdi
callq 0x2140
leaq -0x20(%rbp), %rdi
callq 0x2c06
leaq -0x60(%rbp), %rdi
callq 0x2c06
leaq -0x40(%rbp), %rdi
callq 0x310e
leaq -0x80(%rbp), %rdi
callq 0x310e
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
jmp 0x2ae9
movq %rax, %rbx
jmp 0x2afa
movq %rax, %rbx
leaq -0x20(%rbp), %rdi
callq 0x2c06
leaq -0x60(%rbp), %rdi
callq 0x2c06
leaq -0x40(%rbp), %rdi
callq 0x310e
leaq -0x80(%rbp), %rdi
callq 0x310e
movq %rbx, %rdi
callq 0x2230
nop
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/rulesutils.cc
// Function: init_boundary(rule_boundary&)
void init_boundary(rule_boundary & rb)
{
    rb.field[0].low = 0;
    rb.field[0].high = 0xFFFFFFFF;
    rb.field[1].low = 0;
    rb.field[1].high = 0xFFFFFFFF;
    rb.field[2].low = 0;
    rb.field[2].high = 0xFFFF;
    rb.field[3].low = 0;
    rb.field[3].high = 0xFFFF;
    rb.field[4].low = 0;
    rb.field[4].high = 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
andq $0x0, (%rdi)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movq %rax, 0x18(%rdi)
andq $0x0, 0x20(%rdi)
movl $0xffff, %eax           # imm = 0xFFFF
movq %rax, 0x28(%rdi)
andq $0x0, 0x30(%rdi)
movq %rax, 0x38(%rdi)
andq $0x0, 0x40(%rdi)
movq $0xff, 0x48(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/rulesutils.cc
// Function: CheckIPBounds(range)
int CheckIPBounds(range fld)
{
    if (fld.low > 0xFFFFFFFF)
    {
        printf("Error: IPRange is buggy!(%llu)\n",fld.low);
        return 1;
    }
    if (fld.high > 0xFFFFFFFF)
    {
        printf("Error: IPRange is buggy!(%llu)\n",fld.high);
        return 1;
    }
    if (fld.low > fld.high)
    {
        printf("Error: IPRange is buggy!(%llu - %llu)\n",fld.low,fld.high);
        return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rsi, %rdx
movq %rdi, %rsi
movq %rdi, %rax
shrq $0x20, %rax
je 0x3180
leaq 0x2f7a(%rip), %rdi      # 0x60f8
jmp 0x3193
movq %rdx, %rax
shrq $0x20, %rax
je 0x319f
leaq 0x2f68(%rip), %rdi      # 0x60f8
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2030
pushq $0x1
popq %rax
popq %rbp
retq
xorl %eax, %eax
cmpq %rdx, %rsi
jbe 0x319d
leaq 0x2f6b(%rip), %rdi      # 0x6118
xorl %eax, %eax
callq 0x2030
jmp 0x319a
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/rulesutils.cc
// Function: IP2Range(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, pc_rule*, int)
void IP2Range(unsigned ip1,unsigned ip2,unsigned ip3,unsigned ip4,unsigned iplen,pc_rule *rule,int index)
{
    unsigned tmp;
    unsigned Lo,Hi;

    if(iplen == 0){
        Lo = 0;
        Hi = 0xFFFFFFFF;

    }else if(iplen > 0 && iplen <= 8) {
        tmp = ip1 << 24;
        tmp &= (0xffffffff << (32-iplen));

        Lo = tmp;
        Hi = Lo + (1<<(32-iplen)) - 1;
    }else if(iplen > 8 && iplen <= 16){
        tmp =  ip1 << 24; 
        tmp += ip2 << 16;
        tmp &= (0xffffffff << (32-iplen));

        Lo = tmp;
        Hi = Lo + (1<<(32-iplen)) - 1;
    }else if(iplen > 16 && iplen <= 24){
        tmp = ip1 << 24; 
        tmp += ip2 << 16; 
        tmp += ip3 << 8; 
        tmp &= (0xffffffff << (32-iplen));

        Lo = tmp;
        Hi = Lo + (1<<(32-iplen)) - 1;
    }else if(iplen > 24 && iplen <= 32){
        tmp = ip1 << 24; 
        tmp += ip2 << 16; 
        tmp += ip3 << 8; 
        tmp += ip4;
        tmp &= (0xffffffff << (32-iplen));

        Lo = tmp;
        Hi = Lo + (1<<(32-iplen)) - 1;
    }else{
        printf("Error: Src IP length exceeds 32\n");
        exit(1);
    }

    rule->field[index].low  = Lo;
    rule->field[index].high = Hi;

    if (CheckIPBounds(rule->field[index]))
    {
        printf("Error: IP2Range bounds check for %d failed\n",index);
        exit(1);
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
testl %r8d, %r8d
je 0x31dd
cmpl $0x8, %r8d
ja 0x31e4
negb %r8b
pushq $-0x1
popq %rax
movl %r8d, %ecx
shll %cl, %eax
shll $0x18, %edi
andl %eax, %edi
notl %eax
addl %edi, %eax
jmp 0x3242
xorl %edi, %edi
pushq $-0x1
popq %rax
jmp 0x3242
cmpl $0x10, %r8d
ja 0x3207
shll $0x18, %edi
shll $0x10, %esi
addl %edi, %esi
negb %r8b
pushq $-0x1
popq %rax
movl %r8d, %ecx
shll %cl, %eax
andl %eax, %esi
notl %eax
addl %esi, %eax
movl %esi, %edi
jmp 0x3242
cmpl $0x18, %r8d
ja 0x321a
shll $0x18, %edi
shll $0x10, %esi
addl %edi, %esi
shll $0x8, %edx
jmp 0x322d
cmpl $0x20, %r8d
ja 0x3282
shll $0x18, %edi
shll $0x10, %esi
addl %edi, %esi
shll $0x8, %edx
addl %ecx, %edx
addl %esi, %edx
negb %r8b
pushq $-0x1
popq %rax
movl %r8d, %ecx
shll %cl, %eax
andl %eax, %edx
notl %eax
addl %edx, %eax
movl %edx, %edi
movl 0x10(%rbp), %ebx
movl %edi, %edi
movslq %ebx, %rcx
shlq $0x4, %rcx
movq %rdi, 0x8(%r9,%rcx)
movl %eax, %esi
movq %rsi, 0x10(%r9,%rcx)
callq 0x3164
testl %eax, %eax
jne 0x326a
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2ece(%rip), %rdi      # 0x613f
movl %ebx, %esi
xorl %eax, %eax
callq 0x2030
pushq $0x1
popq %rdi
callq 0x21a0
leaq 0x2f67(%rip), %rdi      # 0x61f0
callq 0x21f0
jmp 0x327a
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/rulesutils.cc
// Function: is_equal(pc_rule, pc_rule, rule_boundary)
bool is_equal(pc_rule rule1, pc_rule rule2, rule_boundary boundary)
{
    int count = 0;
    range r1, r2;
    for (int i = 0;i < MAXDIMENSIONS;i++)
    {

        r1 = range_in_boundary_1D(rule1.field[i], boundary.field[i]);

        r2 = range_in_boundary_1D(rule2.field[i], boundary.field[i]);

        if (r1.low <= r2.low && r1.high >= r2.high)

        {
            count++;
        }
    }

    if (count == MAXDIMENSIONS)
        return true;
    else
        return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
leaq 0x120(%rbp), %rcx
leaq 0x98(%rbp), %rdx
leaq 0x10(%rbp), %rsi
xorl %edi, %edi
cmpq $0x50, %rax
je 0x3545
movq (%rcx,%rax), %r8
movq 0x8(%rcx,%rax), %r9
movq 0x8(%rdx,%rax), %r10
cmpq %r8, %r10
cmovaq %r10, %r8
movq 0x10(%rdx,%rax), %r10
cmpq %r9, %r10
cmovbq %r10, %r9
cmpq %r8, 0x8(%rsi,%rax)
setbe %r8b
cmpq %r9, 0x10(%rsi,%rax)
setae %r9b
andb %r8b, %r9b
movzbl %r9b, %r8d
addl %r8d, %edi
addq $0x10, %rax
jmp 0x34fc
cmpl $0x5, %edi
sete %al
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/derekzwy[P]an-optimal-tcam-encoding-algorithm-for-packet-classification/rulesutils.cc
// Function: check_cmpl(prefix*)
bool check_cmpl(struct prefix *pf) 
{
    int rangelen = 0;
    if(pf->nvalid != 1) {
        for(size_t i = 0; i < pf->nvalid; i ++) {
            rangelen += (int)pow(2, 16 - pf->length[i]);
        }
        for(size_t i = 0; i < pf->ninvalid; i ++) {
            rangelen += (int)pow(2, 16 - pf->cmpllength[i]);
        }
    }
    else {
        rangelen = (int)pow(2, 16 - pf->length[0]);
    }
    if(rangelen == (int)pow(2, 16 - pf->fpf_len)) {
        return true;
    }
    else {
        cout<<pf->nvalid<<endl;
        cout<<rangelen<<" "<<pf->fpf_len<<" "<<(int)pow(2, 16 - pf->fpf_len)<<endl;
        return false;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movl 0x108(%rdi), %eax
pushq $0x10
popq %r12
cmpl $0x1, %eax
jne 0x416a
movl %r12d, %eax
subl 0x40(%r14), %eax
cvtsi2sd %rax, %xmm0
callq 0x2110
cvttsd2si %xmm0, %ebx
movl %r12d, %eax
subl 0x104(%r14), %eax
cvtsi2sd %rax, %xmm0
callq 0x2110
cvttsd2si %xmm0, %r13d
cmpl %r13d, %ebx
je 0x4155
movl 0x108(%r14), %esi
movq 0x4ef1(%rip), %r15      # 0x8fd8
movq %r15, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x2090
movq %r15, %rdi
movl %ebx, %esi
callq 0x2220
leaq 0x1f45(%rip), %r15      # 0x604d
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movl 0x104(%r14), %esi
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movq %rax, %r15
subl 0x104(%r14), %r12d
cvtsi2sd %r12, %xmm0
callq 0x2110
cvttsd2si %xmm0, %esi
movq %r15, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2090
cmpl %r13d, %ebx
sete %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
xorl %r15d, %r15d
movl %eax, %eax
cmpq %rax, %r15
jae 0x419a
movl %r12d, %eax
subl 0x40(%r14,%r15,4), %eax
cvtsi2sd %rax, %xmm0
callq 0x2110
cvttsd2si %xmm0, %eax
addl %eax, %ebx
incq %r15
movl 0x108(%r14), %eax
jmp 0x416f
xorl %r15d, %r15d
movl 0x10c(%r14), %eax
cmpq %rax, %r15
jae 0x40bb
movl %r12d, %eax
subl 0xc0(%r14,%r15,4), %eax
cvtsi2sd %rax, %xmm0
callq 0x2110
cvttsd2si %xmm0, %eax
addl %eax, %ebx
incq %r15
jmp 0x419d