// File: vianna274[P]dropbox/src/WrapperSocket.cpp
// Function: Dropbox::WrapperSocket::send(Dropbox::_MessageData*, int)
bool WrapperSocket::send(MessageData *packet, int wait) {
  set_socketSeq(packet, this->socketSeq);
  int tries = 0;
  do{

    if (sendto(this->localSocketHandler, (void *)packet, PACKET_LEN, 0,(const struct sockaddr *) &(this->remoteSocketAddr),sizeof(struct sockaddr_in)) < 0) {
      fprintf(stderr, "Error on sending");
      cout << string(packet->payload) << packet->type << " " << string(packet->username) << endl;
      exit(1);
    }
  
  }while(!this->waitAck(packet->seq, wait) && ++tries < TOTAL_TRIES);
  this->socketSeq++;
  
  if(tries == TOTAL_TRIES) return false;
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
movl 0x8(%rax), %esi
callq 0x98e0
movl $0x0, -0x20(%rbp)
movq -0x88(%rbp), %r8
movl (%r8), %edi
movq -0x18(%rbp), %rsi
addq $0x20, %r8
movl $0x1000, %edx           # imm = 0x1000
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x30a0
cmpq $0x0, %rax
jge 0x17ab4
movq 0xb6a7(%rip), %rax      # 0x22fd0
movq (%rax), %rdi
leaq 0x1cf2(%rip), %rsi      # 0x19625
xorl %eax, %eax
callq 0x34b0
movq -0x18(%rbp), %rax
addq $0x14, %rax
movq %rax, -0x98(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x3620
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x3480
jmp 0x17972
movq 0xb64f(%rip), %rdi      # 0x22fc8
leaq -0x40(%rbp), %rsi
callq 0x3330
movq %rax, -0xa0(%rbp)
jmp 0x1798b
movq -0xa0(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x35d0
movq %rax, -0xa8(%rbp)
jmp 0x179a6
movq -0xa8(%rbp), %rdi
leaq 0x1a66(%rip), %rsi      # 0x1941a
callq 0x33a0
movq %rax, -0xb0(%rbp)
jmp 0x179c2
movq -0x18(%rbp), %rax
addq $0xfb4, %rax            # imm = 0xFB4
movq %rax, -0xc0(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x3620
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0x3480
jmp 0x179fc
movq -0xb0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3330
movq %rax, -0xc8(%rbp)
jmp 0x17a15
movq -0xc8(%rbp), %rdi
movq 0xb58d(%rip), %rsi      # 0x22fb0
callq 0x33d0
jmp 0x17a2a
leaq -0x78(%rbp), %rdi
callq 0x3280
leaq -0x79(%rbp), %rdi
callq 0x33e0
leaq -0x40(%rbp), %rdi
callq 0x3280
leaq -0x41(%rbp), %rdi
callq 0x33e0
movl $0x1, %edi
callq 0x3420
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17aa9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17aa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17a97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3280
leaq -0x79(%rbp), %rdi
callq 0x33e0
leaq -0x40(%rbp), %rdi
callq 0x3280
leaq -0x41(%rbp), %rdi
callq 0x33e0
jmp 0x17b2c
jmp 0x17ab6
movq -0x88(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %esi
movl -0x1c(%rbp), %edx
callq 0x17b40
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xc9(%rbp)
jne 0x17af0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x3, %eax
setl %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x178f4
movq -0x88(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
cmpl $0x3, -0x20(%rbp)
jne 0x17b1a
movb $0x0, -0x1(%rbp)
jmp 0x17b1e
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3610
nopw %cs:(%rax,%rax)