// File: solaldunckel[P]webserv/srcs/HTTP/Server.cpp
// Function: Server::send(int)
bool Server::send(int fd) {
  FD_CLR(fd, &write_fds_);

  Response *response = clients_[fd]->getResponse();

  if (response) {
    int ret = response->send(fd);

    if (ret < 0)
      return false;
    else if (ret == 0) {
      bool disconnect = response->shouldDisconnect() || clients_[fd]->disconnect();
      Log.print(INFO, head_ + ">> " + response->response_log(Log.getLogLevel()));
      clients_[fd]->clear();
      if (disconnect)
        return false;
    }
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
movl -0x14(%rbp), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
xorq $-0x1, %rcx
movl -0x14(%rbp), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
andq 0x178(%rdi,%rax,8), %rcx
movq %rcx, 0x178(%rdi,%rax,8)
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq (%rax), %rdi
callq 0x21d10
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2d8b8
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x29560
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x2d6ba
movb $0x0, -0x1(%rbp)
jmp 0x2d8bc
cmpl $0x0, -0x24(%rbp)
jne 0x2d8b4
movq -0x20(%rbp), %rdi
callq 0x292e0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xc9(%rbp)
jne 0x2d6fe
movq -0xc8(%rbp), %rdi
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq (%rax), %rdi
callq 0x21c90
movb %al, -0xc9(%rbp)
movq -0xc8(%rbp), %rsi
movb -0xc9(%rbp), %al
andb $0x1, %al
movb %al, -0x25(%rbp)
addq $0x218, %rsi            # imm = 0x218
leaq 0x162fc(%rip), %rdx     # 0x43a1a
leaq -0x68(%rbp), %rdi
callq 0x8f70
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq 0x2eebf(%rip), %rdi     # 0x5c5f8
callq 0x3b230
movl %eax, -0xd0(%rbp)
jmp 0x2d746
movl -0xd0(%rbp), %edx
movq -0xd8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x29670
jmp 0x2d761
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x9550
jmp 0x2d777
leaq -0xb9(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x5960
movq -0xe0(%rbp), %rdx
leaq 0x15882(%rip), %rsi     # 0x4301a
leaq -0xb8(%rbp), %rdi
callq 0x6be0
jmp 0x2d7a6
leaq 0x2ee4b(%rip), %rdi     # 0x5c5f8
movl $0x1, %esi
leaq -0x48(%rbp), %rdx
leaq -0xb8(%rbp), %rcx
xorl %r8d, %r8d
callq 0x3b240
jmp 0x2d7c7
leaq -0xb8(%rbp), %rdi
callq 0x5aa8
leaq -0xb9(%rbp), %rdi
callq 0x55e0
leaq -0x48(%rbp), %rdi
callq 0x5aa8
leaq -0x88(%rbp), %rdi
callq 0x5aa8
leaq -0x68(%rbp), %rdi
callq 0x5aa8
movq -0xc8(%rbp), %rdi
addq $0x48, %rdi
leaq -0x14(%rbp), %rsi
callq 0x2e960
movq (%rax), %rdi
callq 0x216e0
testb $0x1, -0x25(%rbp)
je 0x2d8b2
movb $0x0, -0x1(%rbp)
jmp 0x2d8bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2d8a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2d89b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2d886
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x5aa8
leaq -0xb9(%rbp), %rdi
callq 0x55e0
leaq -0x48(%rbp), %rdi
callq 0x5aa8
leaq -0x88(%rbp), %rdi
callq 0x5aa8
leaq -0x68(%rbp), %rdi
callq 0x5aa8
jmp 0x2d8ca
jmp 0x2d8b4
jmp 0x2d8b6
jmp 0x2d8b8
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xe0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x5950
nopw %cs:(%rax,%rax)