// File: /workspace/github_cpp_makefile_star2_O3/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 0xec2e
cmpl $0x13, (%rax)
jne 0x44f2
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 0x630e
movq %rbx, %r13
movq %rbx, %rdi
movq %r15, %rsi
movl $0xfa0, %edx            # imm = 0xFA0
callq 0xe60a
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x455c
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 0x6607
movq %r13, %rbx
movq %r13, %rdi
movq %r15, %rsi
callq 0xea3c
movq %rbx, %rdi
movl $0x1, %esi
movl $0x5dc, %edx            # imm = 0x5DC
callq 0xe934
movq %rax, %r12
testq %rax, %rax
je 0x45c7
movl (%r12), %eax
cmpl $0x2, %eax
je 0x45d7
cmpl $0x5, %eax
je 0x47df
movq %r13, %rbx
movq %r13, %rdi
callq 0xe69a
jmp 0x450c
movq -0x70(%rbp), %rdi
callq 0x3470
testl %eax, %eax
jne 0x4813
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 0x630e
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 0x630e
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 0x481a
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
movq -0x58(%rbp), %r12
jb 0x482a
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x482a
testl %ecx, %ecx
jne 0x46b3
movl -0x2c(%rbp), %ecx
movl %ecx, (%r15)
movq %r12, %rdi
leaq -0xa0(%rbp), %rsi
movl %eax, %edx
callq 0xe60a
movq -0x60(%rbp), %rax
movq %r12, 0x40(%rax)
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x46de
callq 0x3320
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x46f6
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 0x630e
movq -0x78(%rbp), %rdi
movq %rbx, %rsi
callq 0x33d0
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x4733
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 0x630e
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 0x4836
leaq -0x80000000(%rax), %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rcx
jb 0x4846
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x4846
testl %ecx, %ecx
leaq -0x40(%rbp), %rcx
jne 0x47ad
movl %r12d, (%r15)
movq -0x60(%rbp), %rdx
movl %eax, 0xf8(%rdx)
movq -0x50(%rbp), %rdi
cmpq %rcx, %rdi
je 0x47c5
callq 0x3320
movq -0x70(%rbp), %rdi
callq 0x3280
movq %r13, %rdi
callq 0xe69a
movq -0x60(%rbp), %rbx
jmp 0x44f2
addq $0x14, %r12
movq %r12, %rdi
callq 0x3170
movq 0x107de(%rip), %rdi     # 0x14fd0
movq %r12, %rsi
movq %rax, %rdx
callq 0x33a0
movq 0x107cc(%rip), %rdi     # 0x14fd0
callq 0x31d0
movl $0x1, %edi
callq 0x33c0
movl %eax, %edi
callq 0x3250
leaq 0xb923(%rip), %rdi      # 0x10144
movq -0x58(%rbp), %r12
callq 0x3240
leaq 0xb913(%rip), %rdi      # 0x10144
callq 0x3450
leaq 0xb907(%rip), %rdi      # 0x10144
leaq -0x40(%rbp), %r14
callq 0x3240
leaq 0xb8f7(%rip), %rdi      # 0x10144
leaq -0x40(%rbp), %r14
callq 0x3450
jmp 0x48f1
jmp 0x48f1
movq %rax, %rbx
leaq -0x40(%rbp), %rax
jmp 0x48a7
movq %rax, %rbx
movq -0x58(%rbp), %r12
jmp 0x48b5
movq %rax, %rbx
movq -0x58(%rbp), %r12
jmp 0x48cd
jmp 0x48f1
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x4889
movl %r12d, (%r15)
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
jne 0x48d0
jmp 0x48f4
movq %rax, %rbx
cmpl $0x0, (%r15)
leaq -0x40(%rbp), %rax
jne 0x48a7
movl -0x2c(%rbp), %ecx
movl %ecx, (%r15)
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0x48b5
callq 0x3320
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x48cd
callq 0x3320
movq %r12, %rdi
callq 0x3320
jmp 0x48f4
jmp 0x48f1
jmp 0x48f1
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x4900
callq 0x3320
jmp 0x4900
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0xe69a
movq %rbx, %rdi
callq 0x3580