// File: /workspace/github_cpp_makefile_star2_O3/brianbbsu[P]TCP-Ping/src/server.cpp
// Function: main
int main(int argc, char *argv[])
{
    uint16_t port;
    po::options_description desc, desc_all;
    desc.add_options()
    ("help,h", "Print help messages");
    desc_all.add(desc);
    desc_all.add_options()
    ("port", po::value<uint16_t>(&port)->required(), "Port to listen on");
    
    po::positional_options_description pos_desc;
    pos_desc.add("port", 1);

    po::variables_map vmap;
    try{
        po::store(po::command_line_parser(argc, argv).options(desc_all).positional(pos_desc).run(), vmap);
        if(vmap.count("help"))print_help(desc);
        po::notify(vmap);
    }catch(const std::exception &ex){
        logger::log_error("Failed to parse arguments: " + std::string(ex.what()) + "\n");
        print_help(desc);
    }
    
    logger::log_info("== TCP Ping - Server - Made by Po-Hsuan Su (b08902107) ==");
    int fd = setup(port);
    
    while(1)
    {
        sockaddr_in conn_addr;
        socklen_t conn_addr_len = sizeof(conn_addr);
        int conn_fd = accept(fd, (struct sockaddr*)&conn_addr, &conn_addr_len);
        if(conn_fd < 0)
        {
            logger::log_error("Failed to establish new connection!");
            continue;
        }
        char conn_ip[INET_ADDRSTRLEN + 2];
        memset(conn_ip, 0, sizeof(conn_ip));
        inet_ntop(AF_INET, &conn_addr.sin_addr, conn_ip, INET_ADDRSTRLEN);
        logger::log_info("recv from " + std::string(conn_ip) + ":" + std::to_string(ntohs(conn_addr.sin_port)));
        shutdown(conn_fd, SHUT_RDWR);
        close(conn_fd);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movq %rsi, %rbx
movl %edi, %ebp
movq 0x9ece(%rip), %rax      # 0xffa8
movl (%rax), %r14d
movl %r14d, %r15d
shrl %r15d
leaq 0x1a0(%rsp), %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x5580
leaq 0x220(%rsp), %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x5580
leaq 0x1a0(%rsp), %rdi
callq 0x5360
leaq 0x2d8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x503c(%rip), %rsi      # 0xb164
leaq 0x503c(%rip), %rdx      # 0xb16b
callq 0x5530
leaq 0x220(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x52d0
leaq 0x220(%rsp), %rdi
callq 0x5360
movq %rax, 0x2d8(%rsp)
leaq 0x6(%rsp), %rdi
callq 0x6c01
movb $0x1, 0x8c(%rax)
leaq 0x5009(%rip), %rsi      # 0xb17f
leaq 0x5007(%rip), %rcx      # 0xb184
leaq 0x2d8(%rsp), %rdi
movq %rax, %rdx
callq 0x5560
leaq 0x2a0(%rsp), %rdi
callq 0x53c0
leaq 0x4fde(%rip), %rsi      # 0xb17f
leaq 0x2a0(%rsp), %rdi
movl $0x1, %edx
callq 0x5300
leaq 0x2d8(%rsp), %rdi
callq 0x5120
leaq 0xb8(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x6c78
leaq 0xb8(%rsp), %rdi
leaq 0x220(%rsp), %rbx
movq %rbx, %rsi
callq 0x5260
leaq 0xb8(%rsp), %rdi
movq %rbx, 0x70(%rdi)
leaq 0x2a0(%rsp), %rsi
callq 0x5490
leaq 0x8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x6d0c
leaq 0x8(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
xorl %edx, %edx
callq 0x54d0
leaq 0x8(%rsp), %rdi
callq 0x6faa
leaq 0xb8(%rsp), %rdi
callq 0x6dd2
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4f43(%rip), %rsi      # 0xb196
leaq 0x4f40(%rip), %rdx      # 0xb19a
leaq 0xb8(%rsp), %rdi
callq 0x7762
leaq 0x2e8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0xaae2
movq %rax, %rbx
leaq 0x2f0(%rsp), %r15
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x62a4
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
cmpq %r15, %rbx
jne 0x66b7
leaq 0x2d8(%rsp), %rdi
callq 0x5190
leaq 0x180(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x4eea(%rip), %rsi      # 0xb1b7
leaq 0x4f1c(%rip), %rdx      # 0xb1f0
leaq 0x170(%rsp), %rdi
callq 0x7762
leaq 0x170(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xab6c
movq 0x170(%rsp), %rdi
cmpq %r15, %rdi
je 0x6310
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x52c0
movzwl 0x6(%rsp), %edi
callq 0x5b12
movl %eax, %ebx
leaq 0x88(%rsp), %r15
leaq 0x18(%rsp), %r12
leaq 0x150(%rsp), %rbp
movl $0x10, 0x54(%rsp)
movl %ebx, %edi
leaq 0x190(%rsp), %rsi
leaq 0x54(%rsp), %rdx
callq 0x50f0
movl %eax, %r13d
testl %eax, %eax
js 0x63eb
xorps %xmm0, %xmm0
movaps %xmm0, 0x150(%rsp)
movw $0x0, 0x160(%rsp)
movl $0x2, %edi
leaq 0x194(%rsp), %rsi
movq %rbp, %rdx
movl $0x10, %ecx
callq 0x52f0
movq %r15, 0x78(%rsp)
movq %rbp, %rdi
callq 0x5130
leaq (%rsp,%rax), %rdx
addq $0x150, %rdx            # imm = 0x150
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x7762
movl $0xa, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x4e52(%rip), %rcx      # 0xb215
callq 0x5330
movq %r12, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6454
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x645c
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x98(%rsp), %r13
movq %r13, %rdi
leaq 0x4de4(%rip), %rsi      # 0xb1f1
leaq 0x4e00(%rip), %rdx      # 0xb214
callq 0x7762
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xacc1
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x6331
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6331
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x8(%rsp), %rdi
leaq 0x4da0(%rip), %rsi      # 0xb220
callq 0x5550
movq %r14, 0xb8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x64b1
movq %rdx, 0xb8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xc8(%rsp)
jmp 0x64b8
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0xc0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movzwl 0x192(%rsp), %eax
rolw $0x8, %ax
movzwl %ax, %r15d
movl $0x1, %r12d
cmpw $0xa, %r15w
jb 0x651c
movl $0x2, %r12d
cmpw $0x64, %ax
jb 0x651c
movl $0x3, %r12d
cmpl $0x3e8, %r15d           # imm = 0x3E8
jb 0x651c
cmpl $0x2710, %r15d          # imm = 0x2710
movl $0x5, %r12d
sbbl $0x0, %r12d
movl %r12d, %esi
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
movl $0x2d, %edx
callq 0x5350
movq 0x58(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x6f3d
movq 0xb8(%rsp), %rcx
movl $0xf, %edi
cmpq %r14, %rcx
je 0x6562
movq 0xc8(%rsp), %rdi
movq 0xc0(%rsp), %r8
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
leaq 0x88(%rsp), %r15
leaq 0x18(%rsp), %r12
jbe 0x65a3
movl $0xf, %edi
leaq 0x68(%rsp), %r9
cmpq %r9, %rsi
je 0x659e
movq 0x68(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x65b2
leaq 0xb8(%rsp), %rdi
callq 0x50e0
jmp 0x65c0
leaq 0x58(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5330
leaq 0x40(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x65e5
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x65eb
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x30(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xab6c
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6633
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x664f
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x666c
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x6683
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x669d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x52c0
movl %r13d, %edi
movl $0x2, %esi
callq 0x53e0
movl %r13d, %edi
callq 0x5570
jmp 0x6331
leaq 0x3f8(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x6df2
leaq 0x3f8(%rsp), %rdi
callq 0x6059
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x6a0f
movq 0xa8(%rsp), %rsi
jmp 0x67d6
jmp 0x67e3
jmp 0x67e3
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6730
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6730
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6751
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6751
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6773
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6773
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6794
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6794
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6a0f
movq 0x88(%rsp), %rsi
jmp 0x67d6
jmp 0x67e3
jmp 0x67e3
jmp 0x67e3
movq %rax, %rbx
movq 0x170(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a0f
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6a0f
movq %rax, %rbx
jmp 0x6a0f
movq %rdx, %r15
movq %rax, %rbx
leaq 0x3f8(%rsp), %rdi
callq 0x6e9a
jmp 0x6856
jmp 0x6850
movq %rdx, %r15
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6856
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6856
jmp 0x6850
movq %rdx, %r15
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x6faa
jmp 0x6841
movq %rdx, %r15
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x6dd2
jmp 0x6856
movq %rdx, %r15
movq %rax, %rbx
cmpl $0x1, %r15d
jne 0x6a0f
movq %rbx, %rdi
callq 0x5110
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
movq %rax, %rsi
callq 0x6b54
leaq 0x4911(%rip), %rsi      # 0xb19b
leaq 0xb8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6b91
leaq 0x487a(%rip), %rsi      # 0xb11d
leaq 0xb8(%rsp), %rdi
callq 0x5550
leaq 0x140(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x68d4
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x68e7
movq %rdx, 0x130(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x140(%rsp)
movq 0x8(%rax), %rdx
leaq 0x130(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xacc1
movq 0x130(%rsp), %rdi
cmpq %r14, %rdi
je 0x692d
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x694e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6969
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x378(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x6df2
leaq 0x378(%rsp), %rdi
callq 0x6059
movq %rax, %rbx
leaq 0x378(%rsp), %rdi
callq 0x6e9a
jmp 0x6a0a
jmp 0x6a07
movq %rax, %rbx
movq 0x130(%rsp), %rdi
cmpq %r14, %rdi
je 0x69c4
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x69c4
movq %rax, %rbx
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69ea
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x69ea
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6a0a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6a0a
movq %rax, %rbx
callq 0x5470
leaq 0x2d8(%rsp), %rdi
callq 0x6ee6
jmp 0x6a2b
movq %rax, %rdi
callq 0x6edb
jmp 0x6a28
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0x6f18
jmp 0x6a43
jmp 0x6a40
jmp 0x6a40
jmp 0x6a40
movq %rax, %rbx
leaq 0x288(%rsp), %r14
movq %r14, %rdi
callq 0x757e
movq -0x28(%r14), %rdi
testq %rdi, %rdi
je 0x6a94
movq 0x280(%rsp), %rsi
subq %rdi, %rsi
callq 0x52c0
xorl %eax, %eax
movq %rax, 0x260(%rsp)
movl %eax, 0x268(%rsp)
movq %rax, 0x270(%rsp)
movl %eax, 0x278(%rsp)
movq %rax, 0x280(%rsp)
leaq 0x248(%rsp), %r14
movq %r14, %rdi
callq 0x72d8
movq -0x28(%r14), %rdi
leaq 0x230(%rsp), %rax
cmpq %rax, %rdi
je 0x6aca
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6aca
movq %rax, %rbx
leaq 0x208(%rsp), %r14
movq %r14, %rdi
callq 0x757e
movq -0x28(%r14), %rdi
testq %rdi, %rdi
je 0x6b1b
movq 0x200(%rsp), %rsi
subq %rdi, %rsi
callq 0x52c0
xorl %eax, %eax
movq %rax, 0x1e0(%rsp)
movl %eax, 0x1e8(%rsp)
movq %rax, 0x1f0(%rsp)
movl %eax, 0x1f8(%rsp)
movq %rax, 0x200(%rsp)
leaq 0x1c8(%rsp), %r14
movq %r14, %rdi
callq 0x72d8
movq -0x28(%r14), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x6b4c
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x52c0
movq %rbx, %rdi
callq 0x54e0