// File: solaldunckel[P]webserv/srcs/HTTP/Server.cpp
// Function: Server::recv(int)
bool Server::recv(int fd) {
  Request *req = clients_[fd]->getRequest();

  if (!req)
    req = clients_[fd]->getRequest(true);

  char buf[BUF_SIZE];

  FD_CLR(fd, &read_fds_);

  int nbytes = ::recv(fd, buf, BUF_SIZE, 0);

  if (nbytes <= 0)
    return false;

  std::string buffer(buf, nbytes);

  int ret = req->parse(buffer);

  if (ret >= 1) {
    clients_[fd]->setupConfig(servers_, options_);
    Log.print(INFO, head_ + "<< " + clients_[fd]->getConfig()->log(Log.getLogLevel()));
    clients_[fd]->setupResponse(servers_, options_, ret);
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10140, %rsp          # imm = 0x10140
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x100f0(%rbp)
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq (%rax), %rdi
xorl %esi, %esi
callq 0x21b50
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x2d264
movq -0x100f0(%rbp), %rdi
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq (%rax), %rdi
movl $0x1, %esi
callq 0x21b50
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
xorq $-0x1, %rax
movq %rax, -0x100f8(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x100f8(%rbp), %rdx
movl %eax, %ecx
movq -0x100f0(%rbp), %rax
movslq %ecx, %rcx
andq 0xf8(%rax,%rcx,8), %rdx
movq %rdx, 0xf8(%rax,%rcx,8)
movl -0x14(%rbp), %edi
leaq -0x10020(%rbp), %rsi
movl $0xffff, %edx           # imm = 0xFFFF
xorl %ecx, %ecx
callq 0x5160
movl %eax, -0x10024(%rbp)
cmpl $0x0, -0x10024(%rbp)
jg 0x2d2e2
movb $0x0, -0x1(%rbp)
jmp 0x2d600
movslq -0x10024(%rbp), %rax
movq %rax, -0x10108(%rbp)
leaq -0x10049(%rbp), %rdi
movq %rdi, -0x10100(%rbp)
callq 0x5960
movq -0x10108(%rbp), %rdx
movq -0x10100(%rbp), %rcx
leaq -0x10048(%rbp), %rdi
leaq -0x10020(%rbp), %rsi
callq 0x5630
jmp 0x2d326
leaq -0x10049(%rbp), %rdi
callq 0x55e0
movq -0x20(%rbp), %rdi
leaq -0x10048(%rbp), %rsi
callq 0x21fd0
movl %eax, -0x1010c(%rbp)
jmp 0x2d34a
movl -0x1010c(%rbp), %eax
movl %eax, -0x10060(%rbp)
cmpl $0x1, -0x10060(%rbp)
jl 0x2d5e0
movq -0x100f0(%rbp), %rdi
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq %rax, -0x10118(%rbp)
jmp 0x2d380
movq -0x100f0(%rbp), %rax
movq -0x10118(%rbp), %rcx
movq (%rcx), %rdi
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0x21720
jmp 0x2d3a0
movq -0x100f0(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
leaq 0x16661(%rip), %rdx     # 0x43a16
leaq -0x100a0(%rbp), %rdi
callq 0x8f70
jmp 0x2d3c3
movq -0x100f0(%rbp), %rdi
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq %rax, -0x10120(%rbp)
jmp 0x2d3e0
movq -0x10120(%rbp), %rax
movq (%rax), %rdi
callq 0x21cf0
movq %rax, -0x10128(%rbp)
jmp 0x2d3f8
leaq 0x2f1f9(%rip), %rdi     # 0x5c5f8
callq 0x3b230
movl %eax, -0x1012c(%rbp)
jmp 0x2d40c
movl -0x1012c(%rbp), %edx
movq -0x10128(%rbp), %rsi
leaq -0x100c0(%rbp), %rdi
callq 0x130c0
jmp 0x2d427
leaq -0x10080(%rbp), %rdi
leaq -0x100a0(%rbp), %rsi
leaq -0x100c0(%rbp), %rdx
callq 0x9550
jmp 0x2d443
leaq -0x100e1(%rbp), %rdi
movq %rdi, -0x10138(%rbp)
callq 0x5960
movq -0x10138(%rbp), %rdx
leaq 0x15bb6(%rip), %rsi     # 0x4301a
leaq -0x100e0(%rbp), %rdi
callq 0x6be0
jmp 0x2d472
leaq 0x2f17f(%rip), %rdi     # 0x5c5f8
movl $0x1, %esi
leaq -0x10080(%rbp), %rdx
leaq -0x100e0(%rbp), %rcx
xorl %r8d, %r8d
callq 0x3b240
jmp 0x2d496
leaq -0x100e0(%rbp), %rdi
callq 0x5aa8
leaq -0x100e1(%rbp), %rdi
callq 0x55e0
leaq -0x10080(%rbp), %rdi
callq 0x5aa8
leaq -0x100c0(%rbp), %rdi
callq 0x5aa8
leaq -0x100a0(%rbp), %rdi
callq 0x5aa8
movq -0x100f0(%rbp), %rdi
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq %rax, -0x10140(%rbp)
jmp 0x2d4ef
movq -0x100f0(%rbp), %rax
movq -0x10140(%rbp), %rcx
movq (%rcx), %rdi
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movl -0x10060(%rbp), %ecx
callq 0x217b0
jmp 0x2d515
jmp 0x2d5e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10058(%rbp)
movl %eax, -0x1005c(%rbp)
leaq -0x10049(%rbp), %rdi
callq 0x55e0
jmp 0x2d60e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10058(%rbp)
movl %eax, -0x1005c(%rbp)
jmp 0x2d5f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10058(%rbp)
movl %eax, -0x1005c(%rbp)
jmp 0x2d5d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10058(%rbp)
movl %eax, -0x1005c(%rbp)
jmp 0x2d5c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10058(%rbp)
movl %eax, -0x1005c(%rbp)
jmp 0x2d5ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10058(%rbp)
movl %eax, -0x1005c(%rbp)
leaq -0x100e0(%rbp), %rdi
callq 0x5aa8
leaq -0x100e1(%rbp), %rdi
callq 0x55e0
leaq -0x10080(%rbp), %rdi
callq 0x5aa8
leaq -0x100c0(%rbp), %rdi
callq 0x5aa8
leaq -0x100a0(%rbp), %rdi
callq 0x5aa8
jmp 0x2d5f2
movb $0x1, -0x1(%rbp)
leaq -0x10048(%rbp), %rdi
callq 0x5aa8
jmp 0x2d600
leaq -0x10048(%rbp), %rdi
callq 0x5aa8
jmp 0x2d60e
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x10140, %rsp          # imm = 0x10140
popq %rbp
retq
movq -0x10058(%rbp), %rdi
callq 0x5950
nopw (%rax,%rax)