// File: bchu7796[P]p2p-file-sharing/peers.cpp
// Function: client::parse_command(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int client::parse_command(std::string command){
    std::vector<std::string> parameters;
    std::vector<file_info> file_infos;

    split(command, parameters);
    if(parameters[0] == "show"){
        file_list_request();
        return 0;
    }
    else if(parameters[0] == "share"){
        std::stringstream file_number_string(parameters[1]);
        int file_number = 0;
        struct file_info temp_file_info;
        file_number_string >> file_number;
        for(int i=0; i<file_number; i++){
            temp_file_info.file_name = parameters[i+2];
            temp_file_info.file_length = get_file_size(parameters[i+2]);
            file_infos.push_back(temp_file_info);
        }
        register_request(file_number, file_infos);
    }
    else if(parameters[0] == "download"){
        download(parameters[1]);
    }
    else{
        std::cout<<"command not found"<<std::endl;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rsi, -0x280(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x61f0
leaq -0x48(%rbp), %rdi
callq 0x67c0
movq -0x288(%rbp), %rdi
movq -0x280(%rbp), %rsi
movq -0x278(%rbp), %rdx
movl $0x20, %ecx
callq 0x3f00
jmp 0x563f
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x6810
movq %rax, %rdi
leaq 0x7a6e(%rip), %rsi      # 0xd0c4
callq 0x67e0
movb %al, -0x289(%rbp)
jmp 0x5663
movb -0x289(%rbp), %al
testb $0x1, %al
jne 0x566f
jmp 0x56a1
movq -0x288(%rbp), %rdi
callq 0x39e0
jmp 0x567d
movl $0x0, -0x4(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x5981
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x599f
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x6810
movq %rax, %rdi
leaq 0x7a11(%rip), %rsi      # 0xd0c9
callq 0x67e0
movb %al, -0x28a(%rbp)
jmp 0x56c5
movb -0x28a(%rbp), %al
testb $0x1, %al
jne 0x56d4
jmp 0x58b0
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x6810
movq %rax, -0x298(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0x6210
movl %eax, -0x290(%rbp)
jmp 0x5700
movl -0x290(%rbp), %edx
movq -0x298(%rbp), %rsi
leaq -0x1e0(%rbp), %rdi
callq 0x3420
jmp 0x571b
movl $0x0, -0x1e4(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x6830
leaq -0x1e0(%rbp), %rdi
leaq -0x1e4(%rbp), %rsi
callq 0x31c0
jmp 0x5746
movl $0x0, -0x214(%rbp)
movl -0x214(%rbp), %eax
cmpl -0x1e4(%rbp), %eax
jge 0x5813
movl -0x214(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x6810
movq %rax, %rsi
leaq -0x210(%rbp), %rdi
callq 0x3030
jmp 0x5788
movl -0x214(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x6810
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3130
jmp 0x57ae
movq -0x288(%rbp), %rdi
leaq -0x238(%rbp), %rsi
movq %rsi, -0x2a0(%rbp)
callq 0x5560
movq -0x2a0(%rbp), %rdi
movl %eax, -0x1f0(%rbp)
callq 0x31d0
leaq -0x48(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x6850
jmp 0x57ec
jmp 0x57ee
movl -0x214(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x214(%rbp)
jmp 0x5750
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5893
movw -0x1e4(%rbp), %ax
movw %ax, -0x2a2(%rbp)
leaq -0x250(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x68c0
jmp 0x5833
movq -0x288(%rbp), %rdi
movw -0x2a2(%rbp), %ax
movzwl %ax, %esi
leaq -0x250(%rbp), %rdx
callq 0x3710
jmp 0x5852
leaq -0x250(%rbp), %rdi
callq 0x69b0
leaq -0x210(%rbp), %rdi
callq 0x6a10
leaq -0x1e0(%rbp), %rdi
callq 0x3210
jmp 0x5971
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x69b0
leaq -0x210(%rbp), %rdi
callq 0x6a10
leaq -0x1e0(%rbp), %rdi
callq 0x3210
jmp 0x599f
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x6810
movq %rax, %rdi
leaq 0x7808(%rip), %rsi      # 0xd0cf
callq 0x67e0
movb %al, -0x2a3(%rbp)
jmp 0x58d4
movb -0x2a3(%rbp), %al
testb $0x1, %al
jne 0x58e0
jmp 0x593c
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x6810
movq %rax, %rsi
leaq -0x270(%rbp), %rdi
callq 0x3130
jmp 0x58ff
movq -0x288(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x4ee0
jmp 0x5914
leaq -0x270(%rbp), %rdi
callq 0x31d0
jmp 0x596f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x31d0
jmp 0x599f
movq 0xe68d(%rip), %rdi      # 0x13fd0
leaq 0x778e(%rip), %rsi      # 0xd0d8
callq 0x32d0
movq %rax, -0x2b0(%rbp)
jmp 0x5958
movq -0x2b0(%rbp), %rdi
movq 0xe652(%rip), %rsi      # 0x13fb8
callq 0x3310
jmp 0x596d
jmp 0x596f
jmp 0x5971
jmp 0x5973
movl $0x0, -0x4(%rbp)
movl $0x1, -0x58(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x69b0
leaq -0x30(%rbp), %rdi
callq 0x6230
movl -0x4(%rbp), %eax
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x69b0
leaq -0x30(%rbp), %rdi
callq 0x6230
movq -0x50(%rbp), %rdi
callq 0x34a0
nopw (%rax,%rax)