// File: /workspace/github_cpp_makefile_star2_O1/vianna274[P]dropbox/src/Client.cpp
// Function: Dropbox::Client::listenMaster()
void Client::listenMaster() {
	while(1) {
		MessageData * data = this->listenToMaster->receive(TIMEOUT_OFF);
		if (data->type == TYPE_NEW_BOSS) {
			
			while(1) {
				WrapperSocket socketToGetPort(string(data->payload), 4000);
				MessageData request = make_packet(TYPE_MAKE_CONNECTION, 1, 1, this->localIp.length(), this->localIp.c_str(), this->username.c_str());
				socketToGetPort.send(&request);
				MessageData *newPort = socketToGetPort.receive(TIMEOUT_ON, 1500);
				if(newPort != NULL && newPort->type == TYPE_MAKE_CONNECTION){
				
					socketMtx.lock();
					this->socket = new WrapperSocket(string(data->payload), stoi(newPort->payload));
					this->payload1 = string(data->payload);
					this->payload2 = stoi(newPort->payload);
					socketMtx.unlock();
					break;
				} 
				else if(newPort != NULL && newPort->type == TYPE_REJECT_TO_LISTEN) {
					cout << newPort->payload << endl;
					std::exit(1);
				}
			}
			
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10c8, %rsp           # imm = 0x10C8
movq %rdi, %rbx
leaq 0x98(%rdi), %rax
movq %rax, -0x70(%rbp)
leaq 0xd8(%rdi), %rax
movq %rax, -0x78(%rbp)
leaq -0x108(%rbp), %r13
movq %rdi, -0x60(%rbp)
movq 0x48(%rbx), %rdi
xorl %esi, %esi
callq 0xed22
cmpl $0x13, (%rax)
jne 0x44f6
movq %rax, %r14
addq $0x14, %r14
movq %r13, %rbx
leaq -0xb0(%rbp), %r12
movq %r12, -0xc0(%rbp)
movq %r14, %rdi
callq 0x3170
leaq (%rax,%r14), %rdx
leaq -0xc0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x62de
movq %rbx, %r13
movq %rbx, %rdi
movq %r15, %rsi
movl $0xfa0, %edx            # imm = 0xFA0
callq 0xe64e
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x4560
callq 0x3320
movq -0x60(%rbp), %rcx
movl 0x28(%rcx), %r8d
movq (%rcx), %rax
movq 0x20(%rcx), %r9
movq %rax, (%rsp)
leaq -0x10dc(%rbp), %r15
movq %r15, %rdi
movl $0x2, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x65d3
movq %r13, %rbx
movq %r13, %rdi
movq %r15, %rsi
callq 0xeae4
movq %rbx, %rdi
movl $0x1, %esi
movl $0x5dc, %edx            # imm = 0x5DC
callq 0xe9b6
movq %rax, %r12
testq %rax, %rax
je 0x45cb
movl (%r12), %eax
cmpl $0x2, %eax
je 0x45db
cmpl $0x5, %eax
je 0x47e3
movq %r13, %rbx
movq %r13, %rdi
callq 0xe6de
jmp 0x4510
movq -0x70(%rbp), %rdi
callq 0x3470
testl %eax, %eax
jne 0x4817
movl $0x48, %edi
callq 0x3340
movq %rax, -0x58(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq %r14, %rdi
callq 0x3170
leaq (%rax,%r14), %rdx
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x62de
leaq 0x14(%r12), %r15
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %r15, %rdi
callq 0x3170
leaq (%r12,%rax), %rdx
addq $0x14, %rdx
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x62de
movq %r15, -0x80(%rbp)
movq -0x50(%rbp), %r12
callq 0x3060
movq %rax, %r15
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, (%r15)
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movl $0xa, %edx
callq 0x3410
cmpq %r12, -0x68(%rbp)
je 0x481e
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
movq -0x58(%rbp), %r12
jb 0x482e
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x482e
testl %ecx, %ecx
jne 0x46b7
movl -0x2c(%rbp), %ecx
movl %ecx, (%r15)
movq %r12, %rdi
leaq -0xa0(%rbp), %rsi
movl %eax, %edx
callq 0xe64e
movq -0x60(%rbp), %rax
movq %r12, 0x40(%rax)
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x46e2
callq 0x3320
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x46fa
callq 0x3320
leaq -0x40(%rbp), %r12
movq %r12, -0x50(%rbp)
movq %r14, %rdi
callq 0x3170
leaq (%rax,%r14), %rdx
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x62de
movq -0x78(%rbp), %rdi
movq %rbx, %rsi
callq 0x33d0
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x4737
callq 0x3320
movq %r12, -0x50(%rbp)
movq -0x80(%rbp), %r14
movq %r14, %rdi
callq 0x3170
leaq (%rax,%r14), %rdx
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x62de
movq -0x50(%rbp), %r14
movl (%r15), %r12d
movl $0x0, (%r15)
movq %r14, %rdi
leaq -0x68(%rbp), %rsi
movl $0xa, %edx
callq 0x3410
cmpq %r14, -0x68(%rbp)
je 0x483a
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x484a
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x484a
testl %ecx, %ecx
leaq -0x40(%rbp), %rcx
jne 0x47b1
movl %r12d, (%r15)
movq -0x60(%rbp), %rdx
movl %eax, 0xf8(%rdx)
movq -0x50(%rbp), %rdi
cmpq %rcx, %rdi
je 0x47c9
callq 0x3320
movq -0x70(%rbp), %rdi
callq 0x3280
movq %r13, %rdi
callq 0xe6de
movq -0x60(%rbp), %rbx
jmp 0x44f6
addq $0x14, %r12
movq %r12, %rdi
callq 0x3170
movq 0x107da(%rip), %rdi     # 0x14fd0
movq %r12, %rsi
movq %rax, %rdx
callq 0x33a0
movq 0x107c8(%rip), %rdi     # 0x14fd0
callq 0x31d0
movl $0x1, %edi
callq 0x33c0
movl %eax, %edi
callq 0x3250
leaq 0xb91f(%rip), %rdi      # 0x10144
movq -0x58(%rbp), %r12
callq 0x3240
leaq 0xb90f(%rip), %rdi      # 0x10144
callq 0x3450
leaq 0xb903(%rip), %rdi      # 0x10144
leaq -0x40(%rbp), %r14
callq 0x3240
leaq 0xb8f3(%rip), %rdi      # 0x10144
leaq -0x40(%rbp), %r14
callq 0x3450
jmp 0x48f5
jmp 0x48f5
movq %rax, %rbx
leaq -0x40(%rbp), %rax
jmp 0x48ab
movq %rax, %rbx
movq -0x58(%rbp), %r12
jmp 0x48b9
movq %rax, %rbx
movq -0x58(%rbp), %r12
jmp 0x48d1
jmp 0x48f5
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x488d
movl %r12d, (%r15)
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
jne 0x48d4
jmp 0x48f8
movq %rax, %rbx
cmpl $0x0, (%r15)
leaq -0x40(%rbp), %rax
jne 0x48ab
movl -0x2c(%rbp), %ecx
movl %ecx, (%r15)
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0x48b9
callq 0x3320
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x48d1
callq 0x3320
movq %r12, %rdi
callq 0x3320
jmp 0x48f8
jmp 0x48f5
jmp 0x48f5
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x4904
callq 0x3320
jmp 0x4904
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0xe6de
movq %rbx, %rdi
callq 0x3580