// File: /workspace/github_cpp_makefile_star2_O3/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 $0x2b8, %rsp            # imm = 0x2B8
cmpl $0x4, %edi
jne 0x1086e
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq -0x1d8(%rbp), %rdi
leaq -0x2d8(%rbp), %rdx
callq 0x4160
movq 0x10(%rbx), %rsi
leaq -0x1b8(%rbp), %rdi
leaq -0x2d8(%rbp), %rdx
callq 0x4160
movq 0x18(%rbx), %rsi
leaq -0x198(%rbp), %rdi
leaq -0x2d8(%rbp), %rdx
callq 0x4160
leaq -0x168(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x178(%rbp), %rdi
callq 0x7330
leaq -0x148(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x1b8(%rbp), %rsi
movq -0x1b0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x158(%rbp), %rdi
callq 0x7330
leaq -0x128(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x198(%rbp), %rsi
movq -0x190(%rbp), %rdx
addq %rsi, %rdx
leaq -0x138(%rbp), %rdi
callq 0x7330
leaq -0x2d8(%rbp), %rdi
leaq -0x178(%rbp), %rsi
leaq -0x158(%rbp), %rdx
leaq -0x138(%rbp), %r8
movl $0xfa0, %ecx            # imm = 0xFA0
callq 0x4b1c
movq -0x138(%rbp), %rdi
cmpq %r12, %rdi
je 0x103f6
callq 0x4360
movq -0x158(%rbp), %rdi
cmpq %r15, %rdi
je 0x10407
callq 0x4360
movq -0x178(%rbp), %rdi
cmpq %r14, %rdi
je 0x10418
callq 0x4360
leaq -0x40(%rbp), %r14
leaq -0x60(%rbp), %r15
leaq -0xc8(%rbp), %r12
movq %r14, %rdi
callq 0x10044
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
sete %cl
cmpq $0x41, %rax
setae %al
orb %cl, %al
jne 0x10560
leaq -0x268(%rbp), %rdi
callq 0x44f0
testl %eax, %eax
jne 0x108c7
movq -0x40(%rbp), %rax
leaq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x7330
movq %r12, %rdi
callq 0x46a0
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
addq %rax, %rcx
movq %rax, -0x118(%rbp)
movq %rcx, -0x110(%rbp)
leaq -0x118(%rbp), %rdi
movq %r12, %rsi
callq 0x114d2
movq %r12, %rdi
callq 0x4490
movq %r15, %rdi
leaq 0x2210(%rip), %rsi      # 0x126cd
callq 0x40f0
testl %eax, %eax
je 0x1056d
movq %r15, %rdi
leaq 0x222c(%rip), %rsi      # 0x12700
callq 0x40f0
testl %eax, %eax
je 0x10620
movq %r15, %rdi
leaq 0x224c(%rip), %rsi      # 0x12737
callq 0x40f0
testl %eax, %eax
je 0x1068c
movq %r15, %rdi
leaq 0x2268(%rip), %rsi      # 0x1276a
callq 0x40f0
testl %eax, %eax
je 0x10747
movq %r15, %rdi
leaq 0x2282(%rip), %rsi      # 0x1279b
callq 0x40f0
testl %eax, %eax
je 0x1076f
movq %r15, %rdi
leaq 0x229c(%rip), %rsi      # 0x127cc
callq 0x40f0
testl %eax, %eax
je 0x10794
movq %r15, %rdi
leaq 0x22b8(%rip), %rsi      # 0x127ff
callq 0x40f0
testl %eax, %eax
je 0x107b9
leaq 0x22c7(%rip), %rdi      # 0x12822
jmp 0x107e8
movq %r14, %rdi
callq 0xdffc
jmp 0x10427
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x10680
movq -0x298(%rbp), %r13
leaq -0xb0(%rbp), %rcx
movq %rcx, -0xc0(%rbp)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x7330
leaq -0xf8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %rbx
movq %rbx, %rdi
callq 0x7330
leaq -0x2d8(%rbp), %rdi
movq %r13, %rsi
leaq -0xc0(%rbp), %rdx
movq %rbx, %rcx
callq 0x81f0
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x1060d
callq 0x4360
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
jmp 0x10728
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x1073b
leaq -0x90(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x7330
leaq -0x2d8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x6d06
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
jmp 0x10728
leaq 0x204d(%rip), %rdi      # 0x126d4
jmp 0x107e8
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x10766
movq -0x298(%rbp), %r13
leaq -0x70(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x7330
leaq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %rbx
movq %rbx, %rdi
callq 0x7330
leaq -0x2d8(%rbp), %rdi
movq %r13, %rsi
leaq -0x80(%rbp), %rdx
movq %rbx, %rcx
callq 0x8f4c
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x10720
callq 0x4360
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x107ed
callq 0x4360
jmp 0x107ed
leaq 0x1fc7(%rip), %rdi      # 0x12709
jmp 0x107e8
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x1078b
leaq -0x2d8(%rbp), %rdi
callq 0x6ff8
jmp 0x107ed
leaq 0x1fd1(%rip), %rdi      # 0x1273e
jmp 0x107e8
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x107b0
leaq -0x2d8(%rbp), %rdi
callq 0x6f48
jmp 0x107ed
leaq 0x1fe4(%rip), %rdi      # 0x12776
jmp 0x107e8
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x107d8
leaq -0x2d8(%rbp), %rdi
callq 0x5080
jmp 0x107ed
leaq 0x1ff0(%rip), %rdi      # 0x127a7
jmp 0x107e8
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x107e1
movb $0x1, %r13b
leaq -0x2d8(%rbp), %rdi
callq 0x6fa4
jmp 0x107f0
leaq 0x1ffa(%rip), %rdi      # 0x127d9
jmp 0x107e8
leaq 0x201c(%rip), %rdi      # 0x12804
callq 0x4550
xorl %r13d, %r13d
leaq -0x268(%rbp), %rdi
callq 0x42c0
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x1080e
callq 0x4360
movq %r14, %rdi
callq 0xdffc
testb %r13b, %r13b
je 0x10427
leaq -0x2d8(%rbp), %rdi
callq 0x6a4c
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10840
callq 0x4360
leaq -0x1a8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10855
callq 0x4360
leaq -0x1c8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1086a
callq 0x4360
xorl %eax, %eax
jmp 0x108b5
movq 0x7753(%rip), %rbx      # 0x17fc8
leaq 0x1df1(%rip), %rsi      # 0x1266d
movl $0x5f, %edx
movq %rbx, %rdi
callq 0x43f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4290
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4280
movq %rax, %rbx
movq -0x138(%rbp), %rdi
cmpq %r12, %rdi
je 0x108e7
callq 0x4360
jmp 0x108e7
movq %rax, %rbx
movq -0x158(%rbp), %rdi
cmpq %r15, %rdi
je 0x108fd
callq 0x4360
jmp 0x108fd
movq %rax, %rbx
movq -0x178(%rbp), %rdi
cmpq %r14, %rdi
je 0x109ed
callq 0x4360
jmp 0x109ed
movq %rax, %rbx
jmp 0x109ed
movq %rax, %rbx
jmp 0x10a02
movq %rax, %rbx
jmp 0x10a17
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x1094f
callq 0x4360
jmp 0x1094f
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
jmp 0x1099a
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
jmp 0x1099a
movq %rax, %rbx
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x1098c
callq 0x4360
jmp 0x1098c
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x109c1
callq 0x4360
jmp 0x109c1
movq %rax, %rbx
jmp 0x109c1
jmp 0x109ad
movq %rax, %rbx
jmp 0x109d3
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x4490
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x109d3
callq 0x4360
leaq -0x40(%rbp), %rdi
callq 0xdffc
jmp 0x109e1
movq %rax, %rbx
leaq -0x2d8(%rbp), %rdi
callq 0x6a4c
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10a02
callq 0x4360
leaq -0x1a8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10a17
callq 0x4360
leaq -0x1c8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10a2c
callq 0x4360
movq %rbx, %rdi
callq 0x4610