// File: /workspace/github_cpp_makefile_star2_O1/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 0x6c03
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 0x6c7a
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 0x6d0e
leaq 0x8(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
xorl %edx, %edx
callq 0x54d0
leaq 0x8(%rsp), %rdi
callq 0x6fbc
leaq 0xb8(%rsp), %rdi
callq 0x6de4
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4f43(%rip), %rsi      # 0xb196
leaq 0x4f40(%rip), %rdx      # 0xb19a
leaq 0xb8(%rsp), %rdi
callq 0x775e
leaq 0x2e8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0xab66
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 0x66b9
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 0x775e
leaq 0x170(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xabf0
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, 0x74(%rsp)
movl %ebx, %edi
leaq 0x190(%rsp), %rsi
leaq 0x74(%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 0x775e
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 0x775e
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xad45
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 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x50(%rsp), %rdi
movl $0x2d, %edx
callq 0x5350
movq 0x50(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x6f4f
movq 0xb8(%rsp), %rcx
movl $0xf, %esi
cmpq %r14, %rcx
je 0x6562
movq 0xc8(%rsp), %rsi
movq 0xc0(%rsp), %r8
movq 0x58(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq 0x88(%rsp), %r15
leaq 0x18(%rsp), %r12
jbe 0x65a0
movl $0xf, %esi
leaq 0x60(%rsp), %rdi
cmpq %rdi, 0x50(%rsp)
je 0x659b
movq 0x60(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x65b4
movq 0x50(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x50e0
jmp 0x65c2
leaq 0x50(%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 0x65e7
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x65ed
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 0xabf0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6635
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6651
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x666e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x6685
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x669f
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 0x6e04
leaq 0x3f8(%rsp), %rdi
callq 0x6059
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x6a11
movq 0xa8(%rsp), %rsi
jmp 0x67d8
jmp 0x67e5
jmp 0x67e5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6732
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6732
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6753
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6753
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6775
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6775
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6796
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6796
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6a11
movq 0x88(%rsp), %rsi
jmp 0x67d8
jmp 0x67e5
jmp 0x67e5
jmp 0x67e5
movq %rax, %rbx
movq 0x170(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a11
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6a11
movq %rax, %rbx
jmp 0x6a11
movq %rdx, %r15
movq %rax, %rbx
leaq 0x3f8(%rsp), %rdi
callq 0x6eac
jmp 0x6858
jmp 0x6852
movq %rdx, %r15
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6858
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6858
jmp 0x6852
movq %rdx, %r15
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x6fbc
jmp 0x6843
movq %rdx, %r15
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x6de4
jmp 0x6858
movq %rdx, %r15
movq %rax, %rbx
cmpl $0x1, %r15d
jne 0x6a11
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 0x6b56
leaq 0x490f(%rip), %rsi      # 0xb19b
leaq 0xb8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6b93
leaq 0x4878(%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 0x68d6
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x68e9
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 0xad45
movq 0x130(%rsp), %rdi
cmpq %r14, %rdi
je 0x692f
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6950
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x696b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x378(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x6e04
leaq 0x378(%rsp), %rdi
callq 0x6059
movq %rax, %rbx
leaq 0x378(%rsp), %rdi
callq 0x6eac
jmp 0x6a0c
jmp 0x6a09
movq %rax, %rbx
movq 0x130(%rsp), %rdi
cmpq %r14, %rdi
je 0x69c6
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x69c6
movq %rax, %rbx
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69ec
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x69ec
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6a0c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6a0c
movq %rax, %rbx
callq 0x5470
leaq 0x2d8(%rsp), %rdi
callq 0x6ef8
jmp 0x6a2d
movq %rax, %rdi
callq 0x6eed
jmp 0x6a2a
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0x6f2a
jmp 0x6a45
jmp 0x6a42
jmp 0x6a42
jmp 0x6a42
movq %rax, %rbx
leaq 0x288(%rsp), %r14
movq %r14, %rdi
callq 0x7580
movq -0x28(%r14), %rdi
testq %rdi, %rdi
je 0x6a96
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 0x72e6
movq -0x28(%r14), %rdi
leaq 0x230(%rsp), %rax
cmpq %rax, %rdi
je 0x6acc
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6acc
movq %rax, %rbx
leaq 0x208(%rsp), %r14
movq %r14, %rdi
callq 0x7580
movq -0x28(%r14), %rdi
testq %rdi, %rdi
je 0x6b1d
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 0x72e6
movq -0x28(%r14), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x6b4e
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x52c0
movq %rbx, %rdi
callq 0x54e0