// File: /workspace/github_cpp_makefile_star2_O1/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 0x10957
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 0x7304
leaq -0x148(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x1b8(%rbp), %rsi
movq -0x1b0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x158(%rbp), %rdi
callq 0x7304
leaq -0x128(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x198(%rbp), %rsi
movq -0x190(%rbp), %rdx
addq %rsi, %rdx
leaq -0x138(%rbp), %rdi
callq 0x7304
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 0x104ee
callq 0x4360
movq -0x158(%rbp), %rdi
cmpq %r15, %rdi
je 0x104ff
callq 0x4360
movq -0x178(%rbp), %rdi
cmpq %r14, %rdi
je 0x10510
callq 0x4360
leaq -0x50(%rbp), %r13
xorl %ebx, %ebx
leaq -0x40(%rbp), %r14
leaq -0x60(%rbp), %r15
movq %r14, %rdi
callq 0x1013c
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
sete %cl
cmpq $0x41, %rax
setae %al
orb %cl, %al
jne 0x108f7
leaq -0x268(%rbp), %rdi
callq 0x44f0
testl %eax, %eax
jne 0x109b0
movq -0x40(%rbp), %rax
movq %r13, -0x60(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x7304
leaq -0xc8(%rbp), %r12
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 0x115db
movq %r12, %rdi
callq 0x4490
movq %r15, %rdi
leaq 0x2116(%rip), %rsi      # 0x126cd
callq 0x40f0
testl %eax, %eax
je 0x1065a
movq %r15, %rdi
leaq 0x2132(%rip), %rsi      # 0x12700
callq 0x40f0
testl %eax, %eax
je 0x1070d
movq %r15, %rdi
leaq 0x2152(%rip), %rsi      # 0x12737
callq 0x40f0
testl %eax, %eax
je 0x10779
movq %r15, %rdi
leaq 0x216e(%rip), %rsi      # 0x1276a
callq 0x40f0
testl %eax, %eax
je 0x10834
movq %r15, %rdi
leaq 0x2188(%rip), %rsi      # 0x1279b
callq 0x40f0
testl %eax, %eax
je 0x1085c
movq %r15, %rdi
leaq 0x21a2(%rip), %rsi      # 0x127cc
callq 0x40f0
testl %eax, %eax
je 0x10881
movq %r15, %rdi
leaq 0x21be(%rip), %rsi      # 0x127ff
callq 0x40f0
testl %eax, %eax
je 0x108a6
leaq 0x21cd(%rip), %rdi      # 0x12822
jmp 0x108d4
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x1076d
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 0x7304
leaq -0xf8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %r12
movq %r12, %rdi
callq 0x7304
leaq -0x2d8(%rbp), %rdi
movq %r13, %rsi
leaq -0xc0(%rbp), %rdx
movq %r12, %rcx
callq 0x81b2
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x106fa
callq 0x4360
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
jmp 0x10815
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x10828
leaq -0x90(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x7304
leaq -0x2d8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x6cca
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
jmp 0x10815
leaq 0x1f60(%rip), %rdi      # 0x126d4
jmp 0x108d4
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x10853
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 0x7304
leaq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %r12
movq %r12, %rdi
callq 0x7304
leaq -0x2d8(%rbp), %rdi
movq %r13, %rsi
leaq -0x80(%rbp), %rdx
movq %r12, %rcx
callq 0x8f0e
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x1080d
callq 0x4360
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x108d9
callq 0x4360
jmp 0x108d9
leaq 0x1eda(%rip), %rdi      # 0x12709
jmp 0x108d4
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x10878
leaq -0x2d8(%rbp), %rdi
callq 0x6fbc
jmp 0x108d9
leaq 0x1ee4(%rip), %rdi      # 0x1273e
jmp 0x108d4
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x1089d
leaq -0x2d8(%rbp), %rdi
callq 0x6f0c
jmp 0x108d9
leaq 0x1ef7(%rip), %rdi      # 0x12776
jmp 0x108d4
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x108c4
leaq -0x2d8(%rbp), %rdi
callq 0x5080
jmp 0x108d9
leaq 0x1f03(%rip), %rdi      # 0x127a7
jmp 0x108d4
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
cmpq $0x20, %rax
jne 0x108cd
movb $0x1, %bl
leaq -0x2d8(%rbp), %rdi
callq 0x6f68
jmp 0x108d9
leaq 0x1f0e(%rip), %rdi      # 0x127d9
jmp 0x108d4
leaq 0x1f30(%rip), %rdi      # 0x12804
callq 0x4550
leaq -0x268(%rbp), %rdi
callq 0x42c0
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %r13
cmpq %r13, %rdi
je 0x108f7
callq 0x4360
movq %r14, %rdi
callq 0xe054
testb $0x1, %bl
je 0x1051e
leaq -0x2d8(%rbp), %rdi
callq 0x6a2c
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10929
callq 0x4360
leaq -0x1a8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1093e
callq 0x4360
leaq -0x1c8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10953
callq 0x4360
xorl %eax, %eax
jmp 0x1099e
movq 0x766a(%rip), %rbx      # 0x17fc8
leaq 0x1d08(%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 0x109d0
callq 0x4360
jmp 0x109d0
movq %rax, %rbx
movq -0x158(%rbp), %rdi
cmpq %r15, %rdi
je 0x109e6
callq 0x4360
jmp 0x109e6
movq %rax, %rbx
movq -0x178(%rbp), %rdi
cmpq %r14, %rdi
je 0x10ad6
callq 0x4360
jmp 0x10ad6
movq %rax, %rbx
jmp 0x10ad6
movq %rax, %rbx
jmp 0x10aeb
movq %rax, %rbx
jmp 0x10b00
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x10a38
callq 0x4360
jmp 0x10a38
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
jmp 0x10a83
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
jmp 0x10a83
movq %rax, %rbx
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x10a75
callq 0x4360
jmp 0x10a75
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x10aa5
callq 0x4360
jmp 0x10aa5
movq %rax, %rbx
jmp 0x10aa5
jmp 0x10ab9
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x4490
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x10abc
callq 0x4360
jmp 0x10abc
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0xe054
jmp 0x10aca
movq %rax, %rbx
leaq -0x2d8(%rbp), %rdi
callq 0x6a2c
leaq -0x188(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10aeb
callq 0x4360
leaq -0x1a8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10b00
callq 0x4360
leaq -0x1c8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10b15
callq 0x4360
movq %rbx, %rdi
callq 0x4610
nop