// File: yasz24[P]eau2/src/network/./../application/../store/../utils/queue.h
// Function: Queue::remove(Object*)
Object* remove(Object* o) {
    if (this->size() > 0) {
      size_t len = this->size();
      ObjectNode *to_remove = nullptr;
      //go through the given list.
      ObjectNode *curNode = this->head_;
      for (size_t i = 0; i < len; i++) {
        //check if curNode's data is the same as o.
        if (curNode->data_->equals(o)) {
          //set the first node that is equal to the object to be removed.
          to_remove = curNode;
          break;
        }
        curNode = curNode->getNext(); 
      }
      if (!(to_remove == nullptr)) {
        if (to_remove->equals(this->head_)) {
          this->head_ = this->head_->getNext();
        }
        if (to_remove->equals(this->tail_)) {
          this->tail_ = this->tail_->getPrev();
        }
        //set to_remove's next's prev to to_remove's prev
        if (to_remove->getNext() != nullptr) {
          to_remove->getNext()->setPrev(to_remove->getPrev());
        }
        if (to_remove->getPrev() != nullptr) {
          to_remove->getPrev()->setNext(to_remove->getNext());
        }
        to_remove->setNext(nullptr);
        to_remove->setPrev(nullptr);
        this->size_ -= 1;
        return to_remove->data_;
      }
    }
    return nullptr;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x40(%rbp)
callq 0xea20
cmpq $0x0, %rax
jbe 0xfc0e
movq -0x40(%rbp), %rdi
callq 0xea20
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xfafb
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
testb $0x1, %al
jne 0xfad5
jmp 0xfadf
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0xfafb
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xfab3
cmpq $0x0, -0x28(%rbp)
je 0xfc0c
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rdi
movq 0x10(%rax), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
testb $0x1, %al
jne 0xfb1e
jmp 0xfb37
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rdi
movq 0x18(%rax), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
testb $0x1, %al
jne 0xfb4f
jmp 0xfb68
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
cmpq $0x0, %rax
je 0xfb9d
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq -0x48(%rbp), %rdi
movq %rax, %rsi
movq (%rdi), %rax
callq *0x58(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
cmpq $0x0, %rax
je 0xfbd2
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x50(%rbp), %rdi
movq %rax, %rsi
movq (%rdi), %rax
callq *0x50(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
xorl %ecx, %ecx
movl %ecx, %esi
callq *0x50(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
xorl %ecx, %ecx
movl %ecx, %esi
callq *0x58(%rax)
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rcx
subq $0x1, %rcx
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0xfc16
jmp 0xfc0e
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq