// File: romkatv[P]hcproxy/src/acceptor.cc
// Function: hcproxy::Acceptor::Accept()
int Acceptor::Accept() {
  while (true) {
    struct sockaddr addr = {};
    socklen_t addrlen = sizeof(addr);
    int conn = accept4(fd_, &addr, &addrlen, SOCK_NONBLOCK);
    if (conn >= 0) {
      CHECK(addrlen == sizeof(addr));
      CHECK(addr.sa_family == AF_INET);
      LOG(INFO) << "[" << conn << "] accepted connection from " << IpPort(addr);
      SetSockOpt(conn, IPPROTO_TCP, TCP_NODELAY);
      return conn;
    }
    LOG(ERROR) << "accept4() failed: " << Errno();
    CHECK(errno == EMFILE || errno == ENFILE || errno == ENOBUFS || errno == ENOMEM) << Errno();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x15100
movq -0x108(%rbp), %rax
movl $0x10, -0x1c(%rbp)
movl (%rax), %edi
leaq -0x18(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
movl $0x800, %ecx            # imm = 0x800
callq 0x15650
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x1d69e
movl -0x1c(%rbp), %eax
movb $0x0, -0x41(%rbp)
cmpq $0x10, %rax
jne 0x1d3fb
jmp 0x1d481
leaq 0xc6f3b(%rip), %rsi     # 0xe433d
leaq -0x40(%rbp), %rdi
movq %rdi, -0x118(%rbp)
movl $0x48, %edx
movl $0x3, %ecx
callq 0x194b0
movq -0x118(%rbp), %rdi
movb $0x1, -0x41(%rbp)
callq 0x194e0
movq %rax, -0x110(%rbp)
jmp 0x1d435
movq -0x110(%rbp), %rdi
leaq 0xc6fb5(%rip), %rsi     # 0xe43f8
callq 0x1bfe0
movq %rax, -0x120(%rbp)
jmp 0x1d451
movq -0x120(%rbp), %rdi
leaq 0xcbf2c(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x128(%rbp)
jmp 0x1d46d
movq -0x128(%rbp), %rsi
leaq -0x55(%rbp), %rdi
callq 0x194f0
jmp 0x1d47f
jmp 0x1d481
testb $0x1, -0x41(%rbp)
jne 0x1d489
jmp 0x1d4ad
leaq -0x40(%rbp), %rdi
callq 0x19500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0x41(%rbp)
jne 0x1d556
jmp 0x1d55f
movzwl -0x18(%rbp), %eax
movb $0x0, -0x79(%rbp)
cmpl $0x2, %eax
jne 0x1d4bf
jmp 0x1d545
leaq 0xc6e77(%rip), %rsi     # 0xe433d
leaq -0x78(%rbp), %rdi
movq %rdi, -0x138(%rbp)
movl $0x49, %edx
movl $0x3, %ecx
callq 0x194b0
movq -0x138(%rbp), %rdi
movb $0x1, -0x79(%rbp)
callq 0x194e0
movq %rax, -0x130(%rbp)
jmp 0x1d4f9
movq -0x130(%rbp), %rdi
leaq 0xc6f09(%rip), %rsi     # 0xe4410
callq 0x1c090
movq %rax, -0x140(%rbp)
jmp 0x1d515
movq -0x140(%rbp), %rdi
leaq 0xcbe68(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x148(%rbp)
jmp 0x1d531
movq -0x148(%rbp), %rsi
leaq -0x7a(%rbp), %rdi
callq 0x194f0
jmp 0x1d543
jmp 0x1d545
testb $0x1, -0x79(%rbp)
jne 0x1d54d
jmp 0x1d57f
leaq -0x78(%rbp), %rdi
callq 0x19500
leaq -0x40(%rbp), %rdi
callq 0x19500
jmp 0x1d86c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0x79(%rbp)
jne 0x1d673
jmp 0x1d67c
leaq 0xc6db7(%rip), %rsi     # 0xe433d
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x158(%rbp)
movl $0x4a, %edx
xorl %ecx, %ecx
callq 0x1c360
movq -0x158(%rbp), %rdi
callq 0x194e0
movq %rax, -0x150(%rbp)
jmp 0x1d5b5
movq -0x150(%rbp), %rdi
leaq 0xc6c1d(%rip), %rsi     # 0xe41e0
callq 0x1bb10
movq %rax, -0x160(%rbp)
jmp 0x1d5d1
movq -0x160(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1bad0
movq %rax, -0x168(%rbp)
jmp 0x1d5ea
movq -0x168(%rbp), %rdi
leaq 0xc6e32(%rip), %rsi     # 0xe442a
callq 0x1d940
movq %rax, -0x170(%rbp)
jmp 0x1d606
leaq -0xa8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x24e50
jmp 0x1d618
movq -0x170(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x1d880
movq %rax, -0x178(%rbp)
jmp 0x1d634
movq -0x178(%rbp), %rsi
leaq -0xa9(%rbp), %rdi
callq 0x194f0
jmp 0x1d649
leaq -0xa0(%rbp), %rdi
callq 0x1c390
movl -0x20(%rbp), %edi
movl $0x6, %esi
movl $0x1, %edx
callq 0x1d1c0
movl -0x20(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x78(%rbp), %rdi
callq 0x19500
jmp 0x1d86c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x1c390
jmp 0x1d86c
leaq 0xc6c98(%rip), %rsi     # 0xe433d
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x188(%rbp)
movl $0x4e, %edx
movl $0x2, %ecx
callq 0x1d9a0
movq -0x188(%rbp), %rdi
callq 0x194e0
movq %rax, -0x180(%rbp)
jmp 0x1d6d7
movq -0x180(%rbp), %rdi
leaq 0xc6d61(%rip), %rsi     # 0xe4446
callq 0x1d970
movq %rax, -0x190(%rbp)
jmp 0x1d6f3
callq 0x1c0c0
jmp 0x1d6fa
movq -0x190(%rbp), %rdi
callq 0x1c050
movq %rax, -0x198(%rbp)
jmp 0x1d70f
movq -0x198(%rbp), %rsi
leaq -0xd3(%rbp), %rdi
callq 0x194f0
jmp 0x1d724
leaq -0xd0(%rbp), %rdi
callq 0x1d9d0
callq 0x15640
movl (%rax), %eax
movb $0x0, -0xf9(%rbp)
cmpl $0x18, %eax
je 0x1d761
callq 0x15640
cmpl $0x17, (%rax)
je 0x1d761
callq 0x15640
cmpl $0x69, (%rax)
je 0x1d761
callq 0x15640
cmpl $0xc, (%rax)
jne 0x1d766
jmp 0x1d811
leaq 0xc6bd0(%rip), %rsi     # 0xe433d
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
movl $0x4f, %edx
movl $0x3, %ecx
callq 0x194b0
movq -0x1a8(%rbp), %rdi
movb $0x1, -0xf9(%rbp)
callq 0x194e0
movq %rax, -0x1a0(%rbp)
jmp 0x1d7a6
movq -0x1a0(%rbp), %rdi
leaq 0xc6ca5(%rip), %rsi     # 0xe4459
callq 0x1da10
movq %rax, -0x1b0(%rbp)
jmp 0x1d7c2
movq -0x1b0(%rbp), %rdi
leaq 0xcbbbb(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x1b8(%rbp)
jmp 0x1d7de
callq 0x1c0c0
jmp 0x1d7e5
movq -0x1b8(%rbp), %rdi
callq 0x1c050
movq %rax, -0x1c0(%rbp)
jmp 0x1d7fa
movq -0x1c0(%rbp), %rsi
leaq -0xfc(%rbp), %rdi
callq 0x194f0
jmp 0x1d80f
jmp 0x1d811
testb $0x1, -0xf9(%rbp)
jne 0x1d81c
jmp 0x1d859
leaq -0xf8(%rbp), %rdi
callq 0x19500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x1d9d0
jmp 0x1d86c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0xf9(%rbp)
jne 0x1d85e
jmp 0x1d86a
jmp 0x1d3aa
leaq -0xf8(%rbp), %rdi
callq 0x19500
jmp 0x1d86c
movq -0x50(%rbp), %rdi
callq 0xe1080
nopw %cs:(%rax,%rax)
nop