// File: /workspace/github_cpp_makefile_star2_O2/vianna274[P]dropbox/client.cpp
// Function: main
int main(int argc, char *argv[])
{
	bool endSession = false;
	
	if(argc != 4){
        cout << "Incorrect number of arguments.\nExpected ./build/client <username> <server_ip_adress> <local_ip>" << endl;
        return -1;
	}
	string username(argv[1]);
	string serverIP(argv[2]);
	string localIp(argv[3]);
	Dropbox::Client client(username, serverIP, SERVER_PORT, localIp);

	while(!endSession){
		
		vector<string> arguments = getArguments();
		if(arguments.size() > 0 && arguments.size() < 3){
			client.lockMutex();
			
			string command = arguments[0];
			boost::to_upper(command);
			if (command == "UPLOAD"){
				if(arguments.size() != 2) puts("Wrong size of command -- upload <file path>");
				else {
					client.sendFile(client.getSocket(), arguments[1], client.getUsername());
				}

			}else if (command == "DOWNLOAD"){
				if(arguments.size() != 2) puts("Wrong size of command -- download <file path>");
				else {
					client.download(arguments[1]);
				}
			}else if (command == "DELETE"){
				if(arguments.size() != 2) puts("Wrong size of command -- delete <file path>");
				else {
					client.sendDeleteFile(client.getSocket(), arguments[1], client.getUsername());
				}

			}else if (command == "LIST_SERVER"){
				if(arguments.size() != 1) puts("Wrong size of command -- list_server");
				else {
					client.requestServerFileList();
				}

			}else if (command == "LIST_CLIENT"){
				if(arguments.size() != 1) puts("Wrong size of command -- list_client");
				else {
					client.list_client();
				}

			}else if (command == "GET_SYNC_DIR"){
				if(arguments.size() != 1) puts("Wrong size of command -- get_sync_dir");
				else { 
					client.get_sync_dir();
				}

			}else if(command == "EXIT"){
				if(arguments.size() != 1) puts("Wrong size of command -- exit");
				else {
					client.exit();
					endSession = true;
				}

			} else {
				puts("Unidentified command!");
			}

			client.unlockMutex();
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
cmpl $0x4, %edi
jne 0xd397
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq -0x128(%rbp), %rdi
leaq -0x2c8(%rbp), %rdx
callq 0x4160
movq 0x10(%rbx), %rsi
leaq -0x108(%rbp), %rdi
leaq -0x2c8(%rbp), %rdx
callq 0x4160
movq 0x18(%rbx), %rsi
leaq -0xe8(%rbp), %rdi
leaq -0x2c8(%rbp), %rdx
callq 0x4160
leaq -0xc8(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x4460
leaq -0xa8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x4460
leaq -0x88(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x4460
leaq -0x2c8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
leaq -0x88(%rbp), %r8
movl $0xfa0, %ecx            # imm = 0xFA0
callq 0x48fc
leaq -0x88(%rbp), %rdi
callq 0x41b0
leaq -0xa8(%rbp), %rdi
callq 0x41b0
leaq -0xc8(%rbp), %rdi
callq 0x41b0
leaq -0x40(%rbp), %r14
leaq -0x2c8(%rbp), %rbx
movq %r14, %r15
movq %r14, %rdi
callq 0xcd78
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
sete %cl
cmpq $0x41, %rax
setae %al
orb %cl, %al
jne 0xd387
leaq -0x258(%rbp), %rdi
callq 0x61c8
movq -0x40(%rbp), %rsi
leaq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0x4460
leaq -0x48(%rbp), %r12
movq %r12, %rdi
callq 0x4690
movq %r14, %rdi
movq %r12, %rsi
callq 0xd643
movq %r12, %rdi
callq 0x4480
movq %r14, %rdi
leaq 0x254b(%rip), %rsi      # 0xf685
callq 0xd66b
testb %al, %al
je 0xd1af
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rsi, %rax
cmpq $0x40, %rax
jne 0xd1fb
movq -0x288(%rbp), %r13
addq $0x20, %rsi
leaq -0x188(%rbp), %rdi
callq 0x4460
movq %rbx, %r12
leaq -0x1c8(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4460
movq %r12, %rbx
movq %r12, %rdi
movq %r13, %rsi
leaq -0x188(%rbp), %r13
movq %r13, %rdx
movq %r14, %rcx
callq 0x71f4
movq %r14, %rdi
callq 0x41b0
movq %r13, %rdi
jmp 0xd27b
movq %r14, %rdi
leaq 0x24ff(%rip), %rsi      # 0xf6b8
callq 0xd66b
testb %al, %al
je 0xd207
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rsi, %rax
cmpq $0x40, %rax
jne 0xd285
addq $0x20, %rsi
leaq -0x168(%rbp), %rdi
callq 0x4460
movq %rbx, %rdi
leaq -0x168(%rbp), %r14
movq %r14, %rsi
callq 0x5dd2
jmp 0xd278
leaq 0x248a(%rip), %rdi      # 0xf68c
jmp 0xd36d
movq %r14, %rdi
leaq 0x24de(%rip), %rsi      # 0xf6ef
callq 0xd66b
testb %al, %al
je 0xd291
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rsi, %rax
cmpq $0x40, %rax
jne 0xd2bf
movq -0x288(%rbp), %r13
addq $0x20, %rsi
leaq -0x148(%rbp), %rdi
callq 0x4460
leaq -0x1a8(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4460
movq %rbx, %rdi
movq %r13, %rsi
leaq -0x148(%rbp), %r14
movq %r14, %rdx
movq %r12, %rcx
callq 0x7bee
movq %r12, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x41b0
jmp 0xd372
leaq 0x2435(%rip), %rdi      # 0xf6c1
jmp 0xd36d
movq %r14, %rdi
leaq 0x2487(%rip), %rsi      # 0xf722
callq 0xd66b
testb %al, %al
je 0xd2cb
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0xd2f6
movq %rbx, %rdi
callq 0x5fd0
jmp 0xd372
leaq 0x2430(%rip), %rdi      # 0xf6f6
jmp 0xd36d
movq %r14, %rdi
leaq 0x247e(%rip), %rsi      # 0xf753
callq 0xd66b
testb %al, %al
je 0xd2ff
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0xd32a
movq %rbx, %rdi
callq 0x5f32
jmp 0xd372
leaq 0x2431(%rip), %rdi      # 0xf72e
jmp 0xd36d
movq %r14, %rdi
leaq 0x247b(%rip), %rsi      # 0xf784
callq 0xd66b
testb %al, %al
je 0xd333
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0xd35d
movq %rbx, %rdi
callq 0x4c8e
jmp 0xd372
leaq 0x242e(%rip), %rdi      # 0xf75f
jmp 0xd36d
movq %r14, %rdi
leaq 0x247a(%rip), %rsi      # 0xf7b7
callq 0xd66b
testb %al, %al
je 0xd366
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
je 0xd3b7
leaq 0x2461(%rip), %rdi      # 0xf7bc
jmp 0xd36d
leaq 0x242d(%rip), %rdi      # 0xf791
jmp 0xd36d
leaq 0x246d(%rip), %rdi      # 0xf7da
callq 0x4540
leaq -0x258(%rbp), %rdi
callq 0x42b0
leaq -0x68(%rbp), %rdi
callq 0x41b0
movq %r15, %r14
movq %r15, %rdi
callq 0xb146
jmp 0xd0d0
movq 0x7c22(%rip), %rdi      # 0x14fc0
leaq 0x2280(%rip), %rsi      # 0xf625
callq 0x4370
movq %rax, %rdi
callq 0x4200
pushq $-0x1
popq %rax
jmp 0xd413
leaq -0x2c8(%rbp), %rdi
callq 0x5f84
leaq -0x258(%rbp), %rdi
callq 0x42b0
leaq -0x68(%rbp), %rdi
callq 0x41b0
leaq -0x40(%rbp), %rdi
callq 0xb146
leaq -0x2c8(%rbp), %rdi
callq 0x5c2e
leaq -0xe8(%rbp), %rdi
callq 0x41b0
leaq -0x108(%rbp), %rdi
callq 0x41b0
leaq -0x128(%rbp), %rdi
callq 0x41b0
xorl %eax, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xd4c3
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x41b0
jmp 0xd43e
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x41b0
jmp 0xd44f
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x41b0
jmp 0xd4fe
movq %rax, %rbx
jmp 0xd4fe
movq %rax, %rbx
jmp 0xd50a
movq %rax, %rbx
jmp 0xd516
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
callq 0x41b0
jmp 0xd48c
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
jmp 0xd4bc
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
jmp 0xd4bc
movq %rax, %rbx
leaq -0x1c8(%rbp), %rdi
callq 0x41b0
jmp 0xd4b5
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
callq 0x41b0
jmp 0xd4d4
movq %rax, %rbx
jmp 0xd4d4
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x4480
leaq -0x68(%rbp), %rdi
callq 0x41b0
jmp 0xd4e4
jmp 0xd4e1
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0xb146
jmp 0xd4f2
movq %rax, %rbx
leaq -0x2c8(%rbp), %rdi
callq 0x5c2e
leaq -0xe8(%rbp), %rdi
callq 0x41b0
leaq -0x108(%rbp), %rdi
callq 0x41b0
leaq -0x128(%rbp), %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x4600