// File: vianna274[P]dropbox/src/WrapperSocket.cpp
// Function: Dropbox::WrapperSocket::send(Dropbox::_MessageData*)
int WrapperSocket::send(MessageData *packet) {
  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;
      return -1;
    }
  
  }while(!this->waitAck(packet->seq) && ++tries < TOTAL_TRIES);
  this->socketSeq++;
  
  if(tries == TOTAL_TRIES) return 0;
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
movl 0x8(%rax), %esi
callq 0x98e0
movl $0x0, -0x1c(%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 0x17f83
movq 0xb1da(%rip), %rax      # 0x22fd0
movq (%rax), %rdi
leaq 0x1825(%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 0x17e3f
movq 0xb182(%rip), %rdi      # 0x22fc8
leaq -0x40(%rbp), %rsi
callq 0x3330
movq %rax, -0xa0(%rbp)
jmp 0x17e58
movq -0xa0(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x35d0
movq %rax, -0xa8(%rbp)
jmp 0x17e73
movq -0xa8(%rbp), %rdi
leaq 0x1599(%rip), %rsi      # 0x1941a
callq 0x33a0
movq %rax, -0xb0(%rbp)
jmp 0x17e8f
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 0x17ec9
movq -0xb0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3330
movq %rax, -0xc8(%rbp)
jmp 0x17ee2
movq -0xc8(%rbp), %rdi
movq 0xb0c0(%rip), %rsi      # 0x22fb0
callq 0x33d0
jmp 0x17ef7
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 $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x17ff0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17f78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17f6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17f66
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 0x17ffc
jmp 0x17f85
movq -0x88(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x18010
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xc9(%rbp)
jne 0x17fbc
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x3, %eax
setl %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x17dc1
movq -0x88(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
cmpl $0x3, -0x1c(%rbp)
jne 0x17fe9
movl $0x0, -0x4(%rbp)
jmp 0x17ff0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3610
nopw %cs:(%rax,%rax)