// File: /workspace/github_cpp_makefile_star2_O2/vianna274[P]dropbox/src/Client.cpp
// Function: Dropbox::Client::Client(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Client::Client (string username, string serverAddr, int serverDistributorPort, string localIp) : username(username), syncDirPath("/tmp/sync_dir_"+username+"/")
{
	WrapperSocket socketToGetPort(serverAddr, serverDistributorPort);
	this->username = username;
	this->localIp = localIp;
	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_OFF);
	if(newPort->type == TYPE_MAKE_CONNECTION){
		this->socket = new WrapperSocket(serverAddr, stoi(newPort->payload));
	} 
	else if(newPort->type == TYPE_REJECT_TO_LISTEN) {
		cout << newPort->payload << endl;
		std::exit(1);
	}

	get_sync_dir();
	this->listenToMaster = new WrapperSocket(10000);
	thread listenToMasterThread(&Client::listenMaster, this);
	listenToMasterThread.detach();
	thread askServerUpdatesThread(&Client::askServerUpdates, this);
	askServerUpdatesThread.detach();
	cout << "Connected Successfully." << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10b8, %rsp           # imm = 0x10B8
movq %r8, %r13
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
callq 0x58b4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x33d0
leaq 0x20(%rbx), %rax
movq %rax, -0x40(%rbp)
leaq 0x30(%rbx), %rax
movq %rax, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
movb $0x0, 0x30(%rbx)
leaq 0x87d9(%rip), %rsi      # 0xc038
leaq -0x10d0(%rbp), %rdi
movq %r14, %rdx
callq 0x4fb3
leaq 0x50(%rbx), %rdi
leaq 0x8b42(%rip), %rdx      # 0xc3bb
leaq -0x10d0(%rbp), %rsi
movq %rdi, -0x48(%rbp)
callq 0x4f8a
leaq -0x10d0(%rbp), %rdi
callq 0x3170
leaq 0xe8(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0xc0(%rbx)
movups %xmm0, 0xb0(%rbx)
movups %xmm0, 0xa0(%rbx)
movups %xmm0, 0x90(%rbx)
movups %xmm0, 0x80(%rbx)
movups %xmm0, 0x70(%rbx)
andq $0x0, 0xd0(%rbx)
movq %rax, 0xd8(%rbx)
andq $0x0, 0xe0(%rbx)
movb $0x0, 0xe8(%rbx)
leaq -0xb0(%rbp), %rdi
movq %r12, %rsi
callq 0x33d0
leaq -0xf8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movl %r15d, %edx
callq 0xb422
leaq -0xb0(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3210
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x3210
movl 0x28(%rbx), %r8d
movq (%rbx), %rax
movq 0x20(%rbx), %r9
movq %rax, (%rsp)
leaq -0x10d0(%rbp), %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x5844
leaq -0xf8(%rbp), %rdi
leaq -0x10d0(%rbp), %rsi
callq 0xb850
leaq -0xf8(%rbp), %rdi
xorl %esi, %esi
callq 0xb9d4
movq %rax, %r14
movl (%rax), %eax
cmpl $0x2, %eax
je 0x39a6
cmpl $0x5, %eax
jne 0x3a0c
addq $0x14, %r14
movq 0xd63a(%rip), %rdi      # 0x10fc8
movq %r14, %rsi
callq 0x3310
movq %rax, %rdi
callq 0x31c0
pushq $0x1
popq %rdi
callq 0x3370
pushq $0x48
popq %rdi
callq 0x3320
movq %rax, %r13
leaq -0x90(%rbp), %rdi
movq %r12, %rsi
callq 0x33d0
addq $0x14, %r14
leaq -0x68(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movq %r14, %rsi
callq 0x3130
leaq -0x68(%rbp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x5029
leaq -0x90(%rbp), %rsi
movq %r13, %rdi
movl %eax, %edx
callq 0xb422
movq %r13, 0x40(%rbx)
leaq -0x68(%rbp), %rdi
callq 0x3170
leaq -0x90(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3b9e
pushq $0x48
popq %rdi
callq 0x3320
movq %rax, %r14
movq %rax, %rdi
movl $0x2710, %esi           # imm = 0x2710
callq 0xb4da
movq %r14, 0x48(%rbx)
leaq 0x459(%rip), %rax       # 0x3e90
leaq -0x68(%rbp), %rsi
movq %rax, (%rsi)
andq $0x0, 0x8(%rsi)
leaq -0x30(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x38(%rbp), %rdi
callq 0x504a
leaq -0x38(%rbp), %rdi
callq 0x3530
leaq 0x68d(%rip), %rax       # 0x40f0
leaq -0x68(%rbp), %rsi
movq %rax, (%rsi)
andq $0x0, 0x8(%rsi)
leaq -0x70(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x30(%rbp), %rdi
callq 0x504a
leaq -0x30(%rbp), %rdi
callq 0x3530
movq 0xd539(%rip), %rdi      # 0x10fc8
leaq 0x85b1(%rip), %rsi      # 0xc047
callq 0x3310
movq %rax, %rdi
callq 0x31c0
leaq -0x30(%rbp), %rdi
callq 0x50c8
leaq -0x38(%rbp), %rdi
callq 0x50c8
leaq -0xf8(%rbp), %rdi
callq 0xb4c4
addq $0x10b8, %rsp           # imm = 0x10B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
jmp 0x3afa
movq %rax, %r12
jmp 0x3b06
jmp 0x3adf
movq %rax, %r12
jmp 0x3b47
jmp 0x3b52
movq %rax, %r12
movq %r14, %rdi
jmp 0x3b09
movq %rax, %r12
leaq -0x68(%rbp), %rdi
callq 0x3170
leaq -0x90(%rbp), %rdi
callq 0x3170
movq %r13, %rdi
callq 0x32f0
jmp 0x3b55
movq %rax, %r12
leaq -0xb0(%rbp), %rdi
callq 0x3170
jmp 0x3b61
movq %rax, %r12
jmp 0x3b61
movq %rax, %r12
leaq -0x10d0(%rbp), %rdi
jmp 0x3b80
movq %rax, %r12
jmp 0x3b85
jmp 0x3b52
jmp 0x3b52
movq %rax, %r12
leaq -0x30(%rbp), %rdi
callq 0x50c8
leaq -0x38(%rbp), %rdi
callq 0x50c8
jmp 0x3b55
movq %rax, %r12
leaq -0xf8(%rbp), %rdi
callq 0xb4c4
leaq 0xc0(%rbx), %r14
leaq 0xd8(%rbx), %rdi
callq 0x3170
movq %r14, %rdi
callq 0x5508
movq -0x48(%rbp), %rdi
callq 0x3170
movq -0x40(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3170
movq %r12, %rdi
callq 0x3540