// File: /workspace/github_cpp_makefile_star2_O3/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 $0x10d8, %rsp           # imm = 0x10D8
movq %r8, %r14
movl %ecx, %r15d
movq %rdx, -0x30(%rbp)
movq %rsi, %r13
movq %rdi, %rbx
callq 0x667c
leaq 0x10(%rbx), %rax
movq %rax, -0x88(%rbp)
movq %rax, (%rbx)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x6270
leaq 0x20(%rbx), %rax
movq %rax, -0x48(%rbp)
leaq 0x30(%rbx), %rax
movq %rax, -0x80(%rbp)
movq %rax, 0x20(%rbx)
movq $0x0, 0x28(%rbx)
movb $0x0, 0x30(%rbx)
leaq 0xc56b(%rip), %rsi      # 0x10038
leaq -0x10f0(%rbp), %rdi
movq %r13, %rdx
callq 0x5fff
leaq 0xc910(%rip), %rsi      # 0x103f3
leaq -0x10f0(%rbp), %rdi
callq 0x35c0
leaq 0x60(%rbx), %rsi
movq %rsi, 0x50(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq %rsi, -0x78(%rbp)
je 0x3b17
movq %rdx, 0x50(%rbx)
movq (%rcx), %rdx
movq %rdx, 0x60(%rbx)
jmp 0x3b1d
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x10e0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b49
callq 0x3320
leaq 0xe8(%rbx), %rcx
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)
xorl %eax, %eax
movq %rax, 0xd0(%rbx)
movq %rcx, -0x70(%rbp)
movq %rcx, 0xd8(%rbx)
movq %rax, 0xe0(%rbx)
movb $0x0, 0xe8(%rbx)
leaq -0xb8(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xc8(%rbp), %rdi
callq 0x6270
leaq -0x118(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movl %r15d, %edx
callq 0xe60a
movq -0xc8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3be9
callq 0x3320
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3220
movq -0x48(%rbp), %rdi
movq %r14, %rsi
callq 0x3220
movl 0x28(%rbx), %r8d
movq (%rbx), %rax
movq 0x20(%rbx), %r9
movq %rax, (%rsp)
leaq -0x10f0(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x6607
leaq -0x118(%rbp), %rdi
leaq -0x10f0(%rbp), %rsi
callq 0xea3c
leaq -0x118(%rbp), %rdi
xorl %esi, %esi
callq 0xec2e
movq %rax, %r14
movl (%rax), %eax
cmpl $0x2, %eax
je 0x3c92
cmpl $0x5, %eax
jne 0x3d82
addq $0x14, %r14
movq %r14, %rdi
callq 0x3170
movq 0x1135f(%rip), %rdi     # 0x14fd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x33a0
movq 0x1134d(%rip), %rdi     # 0x14fd0
callq 0x31d0
movl $0x1, %edi
callq 0x33c0
movl $0x48, %edi
callq 0x3340
leaq -0x98(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq -0x30(%rbp), %rcx
movq (%rcx), %rsi
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
movq %rax, -0x30(%rbp)
callq 0x6270
leaq 0x14(%r14), %r15
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
movq %r15, %rdi
callq 0x3170
leaq (%r14,%rax), %rdx
addq $0x14, %rdx
leaq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0x630e
movq -0x68(%rbp), %r15
callq 0x3060
movq %rax, %r14
movl (%rax), %r12d
movl $0x0, (%rax)
leaq -0x40(%rbp), %r13
movq %r15, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x3410
cmpq %r15, (%r13)
je 0x3e83
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x3e8f
movl (%r14), %ecx
cmpl $0x22, %ecx
je 0x3e8f
testl %ecx, %ecx
jne 0x3d3f
movl %r12d, (%r14)
leaq -0xa8(%rbp), %rsi
movq -0x30(%rbp), %r14
movq %r14, %rdi
movl %eax, %edx
callq 0xe60a
movq %r14, 0x40(%rbx)
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
leaq -0x98(%rbp), %r14
je 0x3d71
callq 0x3320
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x3d82
callq 0x3320
movq %rbx, %rdi
callq 0x3fc0
movl $0x48, %edi
callq 0x3340
movq %rax, %r14
movq %rax, %rdi
movl $0x2710, %esi           # imm = 0x2710
callq 0xe6b0
movq %r14, 0x48(%rbx)
leaq 0x70b(%rip), %rax       # 0x44ba
leaq -0x68(%rbp), %rsi
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
leaq -0x38(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x40(%rbp), %rdi
callq 0x608a
leaq -0x40(%rbp), %rdi
callq 0x3570
leaq 0xb2a(%rip), %rax       # 0x4908
leaq -0x68(%rbp), %rsi
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
leaq -0xd0(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x38(%rbp), %rdi
callq 0x608a
leaq -0x38(%rbp), %rdi
callq 0x3570
movq 0x111c0(%rip), %r14     # 0x14fd0
leaq 0xc230(%rip), %rsi      # 0x10047
movl $0x17, %edx
movq %r14, %rdi
callq 0x33a0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3330
movsbl %al, %esi
movq 0x1118e(%rip), %rdi     # 0x14fd0
callq 0x3040
movq %rax, %rdi
callq 0x3260
cmpq $0x0, -0x38(%rbp)
jne 0x3fba
cmpq $0x0, -0x40(%rbp)
jne 0x3fba
leaq -0x118(%rbp), %rdi
callq 0xe69a
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc2ba(%rip), %rdi      # 0x10144
callq 0x3240
leaq 0xc2ae(%rip), %rdi      # 0x10144
callq 0x3450
movq %rax, %r15
jmp 0x3ecd
movq %rax, %r15
jmp 0x3edf
movq %rax, %r15
jmp 0x3ef7
jmp 0x3f47
jmp 0x3f47
jmp 0x3f3b
movq %rax, %r15
movq %r14, %rdi
jmp 0x3efb
movq %rax, %r15
cmpl $0x0, (%r14)
jne 0x3ecd
movl %r12d, (%r14)
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x3edf
callq 0x3320
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x3ef7
callq 0x3320
movq -0x30(%rbp), %rdi
callq 0x3320
jmp 0x3f51
movq %rax, %r15
movq -0xc8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3f5d
callq 0x3320
jmp 0x3f5d
movq %rax, %r15
jmp 0x3f5d
movq %rax, %r15
leaq -0x10e0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x3f8a
jmp 0x3f8f
movq %rax, %r15
jmp 0x3f8f
jmp 0x3f3b
jmp 0x3f3b
movq %rax, %r15
jmp 0x3f51
cmpq $0x0, -0x38(%rbp)
jne 0x3fba
movq %rax, %r15
cmpq $0x0, -0x40(%rbp)
jne 0x3fba
leaq -0x118(%rbp), %rdi
callq 0xe69a
movq 0xd8(%rbx), %rdi
cmpq -0x70(%rbp), %rdi
je 0x3f6f
callq 0x3320
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x3f80
callq 0x3320
movq 0x50(%rbx), %rdi
cmpq -0x78(%rbp), %rdi
je 0x3f8f
callq 0x3320
movq -0x48(%rbp), %rax
movq (%rax), %rdi
cmpq -0x80(%rbp), %rdi
je 0x3fa1
callq 0x3320
movq (%rbx), %rdi
cmpq -0x88(%rbp), %rdi
je 0x3fb2
callq 0x3320
movq %r15, %rdi
callq 0x3580
callq 0x30e0
nop