// File: /workspace/github_cpp_makefile_star2_O3/UTAP[P]APHTTP/server/server.cpp
// Function: Server::run()
void Server::run() {
  ::listen(sc, 10);

  struct sockaddr_in cli_addr;
  socklen_t clilen;
  clilen = sizeof(cli_addr);
  SOCKET newsc;

  while (true) {
    newsc = ::accept(sc, (struct sockaddr *)&cli_addr, &clilen);
    if (!ISVALIDSOCKET(newsc))
      throw Exception("Error on accept: " + string(getSocketError()));
    Response *res = NULL;
    try {
      char* data = new char[BUFSIZE + 1];
      size_t recv_len, recv_total_len = 0;
      Request *req = NULL;
      while (!req) {
        recv_len =
            recv(newsc, data + recv_total_len, BUFSIZE - recv_total_len, 0);
        if (recv_len > 0) {
          recv_total_len += recv_len;
          data[recv_total_len >= 0 ? recv_total_len : 0] = 0;
          req = parseRawReq(data, recv_total_len);
        } else
          break;
      }
      delete[] data;
      if (!recv_total_len) {
        CLOSESOCKET(newsc);
        continue;
      }
      req->log();
      size_t i = 0;
      for (; i < routes.size(); i++) {
        if (routes[i]->isMatch(req->getMethod(), req->getPath())) {
          res = routes[i]->handle(req);
          break;
        }
      }
      if (i == routes.size() && notFoundHandler) {
        res = notFoundHandler->callback(req);
      }
      delete req;
    } catch (const Exception& exc) {
      delete res;
      res = ServerErrorHandler::callback(exc.getMessage());
    }
    int si;
    res->log();
    string res_data = res->print(si);
    delete res;
    int wr = send(newsc, res_data.c_str(), si, 0);
    if (wr != si)
      throw Exception("Send error: " + string(getSocketError()));
    CLOSESOCKET(newsc);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
movl (%rdi), %edi
movl $0xa, %esi
callq 0x4390
leaq -0x40(%rbp), %rdx
movl $0x10, (%rdx)
movq %rbx, -0x38(%rbp)
movl (%rbx), %edi
leaq -0x110(%rbp), %rsi
callq 0x4140
movl %eax, -0x2c(%rbp)
testl %eax, %eax
js 0x135bc
movl $0x3f4001, %edi         # imm = 0x3F4001
callq 0x4030
movq %rax, %r12
xorl %r14d, %r14d
xorl %r15d, %r15d
testq %r15, %r15
jne 0x13311
leaq (%r12,%r14), %rsi
movl $0x3f4000, %edx         # imm = 0x3F4000
subq %r14, %rdx
movl -0x2c(%rbp), %edi
xorl %ecx, %ecx
callq 0x4150
testq %rax, %rax
je 0x13311
addq %rax, %r14
movb $0x0, (%r12,%r14)
movq %r12, %rdi
movq %r14, %rsi
callq 0xffdb
movq %rax, %r15
jmp 0x132d9
movq %r12, %rdi
callq 0x4420
testq %r14, %r14
je 0x133b3
movq %r15, %rdi
callq 0xbafc
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rdx
cmpq %rax, %rdx
je 0x133c0
xorl %ebx, %ebx
movq (%rax,%rbx,8), %r14
movq %r15, %rdi
leaq -0xe0(%rbp), %r13
callq 0xb376
movl %eax, %r12d
movq %r13, %rdi
movq %r15, %rsi
callq 0xb340
movq %r14, %rdi
movl %r12d, %esi
movq %r13, %rdx
callq 0x14d50
movl %eax, %r14d
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x1338b
callq 0x4310
testb %r14b, %r14b
jne 0x133ca
incq %rbx
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rdx, %rbx
jb 0x13341
movq %rax, %rdx
jmp 0x133c5
movl -0x2c(%rbp), %edi
callq 0x4600
jmp 0x134d5
movq %rdx, %rcx
xorl %ebx, %ebx
xorl %r12d, %r12d
jmp 0x133f0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax,%rbx,8), %rdi
xorl %r12d, %r12d
movq %r15, %rsi
callq 0x14d94
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %rcx
movq %rax, %r12
subq %rdx, %rcx
sarq $0x3, %rcx
cmpq %rcx, %rbx
jne 0x13415
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
je 0x13415
movq (%rdi), %rax
movq %r15, %rsi
callq *0x10(%rax)
movq %rax, %r12
leaq 0x88(%r15), %rdi
callq 0xa9f2
leaq 0x58(%r15), %rdi
callq 0xa9f2
leaq 0x28(%r15), %rdi
callq 0xa9f2
movq (%r15), %rdi
leaq 0x10(%r15), %rax
cmpq %rax, %rdi
je 0x13444
callq 0x4310
movq %r15, %rdi
callq 0x4310
movq %r12, %rdi
xorl %esi, %esi
callq 0x8caa
leaq -0x60(%rbp), %rdi
movq %r12, %rsi
leaq -0x3c(%rbp), %rdx
callq 0x84d0
leaq 0x48(%r12), %rdi
callq 0xa9f2
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %rax
cmpq %rax, %rdi
je 0x13484
callq 0x4310
movq 0x8(%r12), %rdi
leaq 0x18(%r12), %rax
cmpq %rax, %rdi
je 0x13498
callq 0x4310
movq %r12, %rdi
callq 0x4310
movq -0x60(%rbp), %rsi
movslq -0x3c(%rbp), %rdx
movl -0x2c(%rbp), %edi
xorl %ecx, %ecx
callq 0x4200
cmpl %eax, -0x3c(%rbp)
jne 0x13625
movl -0x2c(%rbp), %edi
callq 0x4600
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x134d5
callq 0x4310
movq -0x38(%rbp), %rax
movl (%rax), %edi
leaq -0x110(%rbp), %rsi
leaq -0x40(%rbp), %rdx
jmp 0x132b6
movq %rdx, %r15
movq %rax, %r13
jmp 0x13522
jmp 0x13519
jmp 0x13519
movq %rdx, %r15
movq %rax, %r13
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x1351f
callq 0x4310
jmp 0x1351f
jmp 0x13519
movq %rdx, %r15
movq %rax, %r13
xorl %r12d, %r12d
cmpl $0x1, %r15d
jne 0x13822
movq %r13, %rdi
callq 0x41a0
movq %rax, %r14
testq %r12, %r12
je 0x1356e
leaq 0x48(%r12), %rdi
callq 0xa9f2
movq 0x28(%r12), %rdi
leaq 0x38(%r12), %rax
cmpq %rax, %rdi
je 0x1355a
callq 0x4310
movq 0x8(%r12), %rdi
leaq 0x18(%r12), %rax
cmpq %rax, %rdi
je 0x1356e
callq 0x4310
movq %r12, %rdi
callq 0x4310
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
callq 0x7dfa
movq %rbx, %rdi
callq 0x1422c
movq %rax, %r12
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x135b2
callq 0x4310
callq 0x4540
jmp 0x1344c
movl $0x28, %edi
callq 0x41f0
movq %rax, %rbx
callq 0x4060
movl (%rax), %edi
callq 0x4170
leaq -0x60(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
movq %rax, %rsi
callq 0x4190
leaq 0x61e0(%rip), %rcx      # 0x197cf
leaq -0x60(%rbp), %rdi
movl $0x11, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x43a0
leaq -0xf0(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x13691
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x136a2
movl $0x28, %edi
callq 0x41f0
movq %rax, %rbx
callq 0x4060
movl (%rax), %edi
callq 0x4170
leaq -0xa0(%rbp), %rdi
leaq -0x2d(%rbp), %rdx
movq %rax, %rsi
callq 0x4190
leaq 0x6189(%rip), %rcx      # 0x197e1
leaq -0xa0(%rbp), %rdi
movl $0xc, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x43a0
leaq -0xb0(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x136e6
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x136f7
movq %rdx, -0x100(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xf0(%rbp)
movq 0x8(%rax), %rdx
leaq -0x100(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %r15b
movq %rbx, %rdi
callq 0x138e0
xorl %r15d, %r15d
leaq 0xb3fb(%rip), %rsi      # 0x1ead0
leaq -0xbbaa(%rip), %rdx     # 0x7b32
movq %rbx, %rdi
callq 0x4570
jmp 0x13739
movq %rdx, -0xc0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xb0(%rbp)
movq 0x8(%rax), %rdx
leaq -0xc0(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %r15b
movq %rbx, %rdi
callq 0x138e0
xorl %r15d, %r15d
leaq 0xb3a6(%rip), %rsi      # 0x1ead0
leaq -0xbbff(%rip), %rdx     # 0x7b32
movq %rbx, %rdi
callq 0x4570
movq %rax, %r13
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x13753
callq 0x4310
jmp 0x13753
movq %rax, %r13
callq 0x4540
jmp 0x13822
movq %rax, %rdi
callq 0x6f48
movq %rax, %r13
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x13779
callq 0x4310
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1378e
callq 0x4310
testb %r15b, %r15b
jne 0x137b2
jmp 0x13803
movq %rax, %r13
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x137b2
callq 0x4310
jmp 0x137b2
movq %rax, %r13
movq %rbx, %rdi
callq 0x4290
jmp 0x13803
movq %rax, %r13
movq -0x100(%rbp), %rdi
cmpq %r14, %rdi
je 0x137d0
callq 0x4310
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x137e2
callq 0x4310
testb %r15b, %r15b
jne 0x1381a
jmp 0x13822
movq %rax, %r13
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1381a
callq 0x4310
jmp 0x1381a
movq %rax, %r13
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x13822
callq 0x4310
jmp 0x13822
movq %rax, %r13
movq %rbx, %rdi
callq 0x4290
movq %r13, %rdi
callq 0x45a0