// File: luigix25[P]SSLP/client_files/client.cpp
// Function: cmd_list()
bool cmd_list(){

	if(!send_command(LIST_COMMAND)){
		cout<<"[Error] send command"<<endl;
		return false;
	}
	
	char *recvd;
	int len;
	recvd = recvDataHMAC(server_socket,len);
	if(recvd == NULL) return false;

	EncryptedChunk ec;
	ec.setCipherText(recvd);
	ec.size = len;

	Chunk c;

	DecryptManager dm;
	if(!dm.DecryptUpdate(c,ec))
		return false;

	if(!dm.DecryptFinal(c))
		return false;

	string concatenated(c.getPlainText());

	vector<string> files_list = split(concatenated,string(" "));

	cout<<"Files Available for downloading from Server:"<<endl;
	for(uint i= 0;i<files_list.size();i++){
		cout<<files_list[i]<<'\t';
	}
	cout<<endl;

	cout<<"Files Available for uploading to Server:"<<endl;

	vector<string> files_client = get_file_list(CLIENT_PATH);

	for(uint i= 0;i<files_client.size();i++){
		cout<<files_client[i]<<'\t';
	}
	cout << endl;

	return true;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl $0x1, %edi
callq 0x5290
testb $0x1, %al
jne 0x5464
movq 0xdb78(%rip), %rdi      # 0x12fb8
leaq 0x8cd1(%rip), %rsi      # 0xe118
callq 0x44a0
movq %rax, %rdi
movq 0xdb52(%rip), %rsi      # 0x12fa8
callq 0x4500
movb $0x0, -0x1(%rbp)
jmp 0x58fe
leaq 0xe1b5(%rip), %rdi      # 0x13620
leaq -0x14(%rbp), %rsi
callq 0x88c0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5488
movb $0x0, -0x1(%rbp)
jmp 0x58fe
leaq -0x30(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0xd860
movq -0x118(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xd930
jmp 0x54aa
movl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xd6b0
jmp 0x54bb
leaq -0x60(%rbp), %rdi
callq 0xa600
jmp 0x54c6
leaq -0x60(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xa700
movb %al, -0x119(%rbp)
jmp 0x54df
movb -0x119(%rbp), %al
testb $0x1, %al
jne 0x552e
jmp 0x54eb
movb $0x0, -0x1(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0x58c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x58f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x58ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x58e1
leaq -0x60(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xa8c0
movb %al, -0x11a(%rbp)
jmp 0x5543
movb -0x11a(%rbp), %al
testb $0x1, %al
jne 0x555f
jmp 0x554f
movb $0x0, -0x1(%rbp)
movl $0x1, -0x64(%rbp)
jmp 0x58c4
leaq -0x58(%rbp), %rdi
callq 0xd7e0
movq %rax, -0x128(%rbp)
jmp 0x5571
leaq -0x89(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x4910
movq -0x128(%rbp), %rsi
movq -0x130(%rbp), %rdx
leaq -0x88(%rbp), %rdi
callq 0x76e0
jmp 0x55a0
leaq -0x89(%rbp), %rdi
callq 0x4530
leaq -0xc8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x41f0
jmp 0x55c1
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x4910
movq -0x138(%rbp), %rdx
leaq 0x8e0f(%rip), %rsi      # 0xe3f1
leaq -0xe8(%rbp), %rdi
callq 0x76e0
jmp 0x55f0
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0x82c0
jmp 0x560c
leaq -0xe8(%rbp), %rdi
callq 0x42b0
leaq -0xe9(%rbp), %rdi
callq 0x4530
leaq -0xc8(%rbp), %rdi
callq 0x42b0
movq 0xd981(%rip), %rdi      # 0x12fb8
leaq 0x8aef(%rip), %rsi      # 0xe12d
callq 0x44a0
movq %rax, -0x140(%rbp)
jmp 0x564c
movq -0x140(%rbp), %rdi
movq 0xd94e(%rip), %rsi      # 0x12fa8
callq 0x4500
jmp 0x5661
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
movq %rax, -0x148(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7790
movq %rax, %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
jae 0x576b
movl -0xf0(%rbp), %eax
movl %eax, %esi
leaq -0xa8(%rbp), %rdi
callq 0x77b0
movq %rax, %rsi
movq 0xd903(%rip), %rdi      # 0x12fb8
callq 0x4470
movq %rax, -0x150(%rbp)
jmp 0x56c3
movq -0x150(%rbp), %rdi
movl $0x9, %esi
callq 0x45e0
jmp 0x56d6
jmp 0x56d8
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x566b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x89(%rbp), %rdi
callq 0x4530
jmp 0x58e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x58b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x573d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x42b0
leaq -0xe9(%rbp), %rdi
callq 0x4530
leaq -0xc8(%rbp), %rdi
callq 0x42b0
jmp 0x58b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x58aa
movq 0xd846(%rip), %rdi      # 0x12fb8
movq 0xd82f(%rip), %rsi      # 0x12fa8
callq 0x4500
jmp 0x5780
movq 0xd831(%rip), %rdi      # 0x12fb8
leaq 0x89cc(%rip), %rsi      # 0xe15a
callq 0x44a0
movq %rax, -0x158(%rbp)
jmp 0x579c
movq -0x158(%rbp), %rdi
movq 0xd7fe(%rip), %rsi      # 0x12fa8
callq 0x4500
jmp 0x57b1
leaq 0x89cb(%rip), %rsi      # 0xe183
leaq -0x108(%rbp), %rdi
callq 0x8170
jmp 0x57c6
movl $0x0, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
movq %rax, -0x160(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x7790
movq %rax, %rcx
movq -0x160(%rbp), %rax
cmpq %rcx, %rax
jae 0x5864
movl -0x10c(%rbp), %eax
movl %eax, %esi
leaq -0x108(%rbp), %rdi
callq 0x77b0
movq %rax, %rsi
movq 0xd7a2(%rip), %rdi      # 0x12fb8
callq 0x4470
movq %rax, -0x168(%rbp)
jmp 0x5824
movq -0x168(%rbp), %rdi
movl $0x9, %esi
callq 0x45e0
jmp 0x5837
jmp 0x5839
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0x57d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x77d0
jmp 0x58aa
movq 0xd74d(%rip), %rdi      # 0x12fb8
movq 0xd736(%rip), %rsi      # 0x12fa8
callq 0x4500
jmp 0x5879
movb $0x1, -0x1(%rbp)
movl $0x1, -0x64(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x77d0
leaq -0xa8(%rbp), %rdi
callq 0x77d0
leaq -0x88(%rbp), %rdi
callq 0x42b0
jmp 0x58c4
leaq -0xa8(%rbp), %rdi
callq 0x77d0
leaq -0x88(%rbp), %rdi
callq 0x42b0
jmp 0x58e1
leaq -0x60(%rbp), %rdi
callq 0xa6d0
leaq -0x58(%rbp), %rdi
callq 0xd6d0
leaq -0x30(%rbp), %rdi
callq 0xd880
jmp 0x58fe
leaq -0x60(%rbp), %rdi
callq 0xa6d0
leaq -0x58(%rbp), %rdi
callq 0xd6d0
leaq -0x30(%rbp), %rdi
callq 0xd880
jmp 0x590c
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x4900
nopw %cs:(%rax,%rax)