// File: ljl0222[P]SecondFileSystem/User.cpp
// Function: User::Read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void User::Read(string sfd, string outFile, string size) {
    if (sfd.empty() || !isdigit(sfd.front())) {
        cout << "read���������� \n";
        return;
    }
    int fd = stoi(sfd);

    int usize;
    if (size.empty() || !isdigit(size.front()) || (usize = stoi(size)) < 0) {
        cout << "read���������� \n";
        return;
    }
    char* buffer = new char[usize];
    //cout << "fd = " << fd << " outFile = " << outFile << " size = " << size << "\n";
    u_arg[0] = fd;
    u_arg[1] = (long)buffer;
    u_arg[2] = usize;
    u_FileManager->Read();
    if (IsError())
        return;

    cout << "read " << u_ar0[User::EAX] << " bytes success : \n";
    if (outFile.empty()) {
        for (unsigned int i = 0; i < u_ar0[User::EAX]; ++i) {
            cout << (char)buffer[i];
        }
        cout << " \n";
        return;
    }
    fstream fout(outFile, ios::out | ios::binary);
    if (!fout) {
        cout << "���������ļ� " << outFile << " ʧ�ܣ� \n";
        return;
    }
    fout.write(buffer, u_ar0[User::EAX]);
    fout.close();
    cout << "�������ļ� " << outFile << " �ɹ��� \n";
    delete[]buffer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rsi, -0x280(%rbp)
movq %rdi, %rax
movq -0x280(%rbp), %rdi
movq %rdi, -0x278(%rbp)
movq %rdx, -0x270(%rbp)
movq %rcx, -0x268(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x260(%rbp)
callq 0x3550
testb $0x1, %al
jne 0xa4ae
movq -0x278(%rbp), %rdi
callq 0x30d0
movsbl (%rax), %edi
callq 0x32b0
cmpl $0x0, %eax
jne 0xa4c6
movq 0x9b13(%rip), %rdi      # 0x13fc8
leaq 0x3cd6(%rip), %rsi      # 0xe192
callq 0x32e0
jmp 0xa7a3
movq -0x278(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xa920
movq -0x268(%rbp), %rdi
movl %eax, -0x24(%rbp)
callq 0x3550
testb $0x1, %al
jne 0xa524
movq -0x268(%rbp), %rdi
callq 0x30d0
movsbl (%rax), %edi
callq 0x32b0
cmpl $0x0, %eax
je 0xa524
movq -0x268(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xa920
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
jge 0xa53c
movq 0x9a9d(%rip), %rdi      # 0x13fc8
leaq 0x3c60(%rip), %rsi      # 0xe192
callq 0x32e0
jmp 0xa7a3
movslq -0x28(%rbp), %rdi
callq 0x3030
movq %rax, %rcx
movq -0x260(%rbp), %rax
movq %rcx, -0x30(%rbp)
movl -0x24(%rbp), %ecx
movl %ecx, 0x1020(%rax)
movq -0x30(%rbp), %rcx
movl %ecx, 0x1024(%rax)
movl -0x28(%rbp), %ecx
movl %ecx, 0x1028(%rax)
movq 0x1400(%rax), %rdi
callq 0x6ef0
movq -0x260(%rbp), %rdi
callq 0x9450
testb $0x1, %al
jne 0xa58d
jmp 0xa592
jmp 0xa7a3
movq 0x9a2f(%rip), %rdi      # 0x13fc8
leaq 0x3c03(%rip), %rsi      # 0xe1a3
callq 0x32e0
movq %rax, %rdi
movq -0x260(%rbp), %rax
movl 0x20(%rax), %esi
callq 0x3480
movq %rax, %rdi
leaq 0x3be8(%rip), %rsi      # 0xe1a9
callq 0x32e0
movq -0x270(%rbp), %rdi
callq 0x3550
testb $0x1, %al
jne 0xa5d8
jmp 0xa628
movl $0x0, -0x34(%rbp)
movq -0x260(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x20(%rcx), %eax
jae 0xa610
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
movq 0x99cc(%rip), %rdi      # 0x13fc8
movsbl (%rax,%rcx), %esi
callq 0x3390
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa5df
movq 0x99b1(%rip), %rdi      # 0x13fc8
leaq 0x3ae1(%rip), %rsi      # 0xe0ff
callq 0x32e0
jmp 0xa7a3
movl $0x10, %edi
movl $0x4, %esi
callq 0xa960
movq -0x270(%rbp), %rsi
movl %eax, %edx
leaq -0x248(%rbp), %rdi
callq 0x3540
movq -0x248(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x248(%rbp,%rax), %rdi
callq 0x3170
movb %al, -0x281(%rbp)
jmp 0xa66c
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0xa678
jmp 0xa6f7
movq 0x9949(%rip), %rdi      # 0x13fc8
leaq 0x3b36(%rip), %rsi      # 0xe1bc
callq 0x32e0
movq %rax, -0x290(%rbp)
jmp 0xa694
movq -0x270(%rbp), %rsi
movq -0x290(%rbp), %rdi
callq 0x32a0
movq %rax, -0x298(%rbp)
jmp 0xa6b0
movq -0x298(%rbp), %rdi
leaq 0x3b0c(%rip), %rsi      # 0xe1ca
callq 0x32e0
jmp 0xa6c5
movl $0x1, -0x258(%rbp)
jmp 0xa797
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x30b0
jmp 0xa7ac
movq -0x260(%rbp), %rax
leaq -0x238(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl 0x20(%rax), %eax
movl %eax, %edx
callq 0x3460
jmp 0xa715
leaq -0x248(%rbp), %rdi
callq 0x3070
jmp 0xa723
movq 0x989e(%rip), %rdi      # 0x13fc8
leaq 0x3aa3(%rip), %rsi      # 0xe1d4
callq 0x32e0
movq %rax, -0x2a0(%rbp)
jmp 0xa73f
movq -0x270(%rbp), %rsi
movq -0x2a0(%rbp), %rdi
callq 0x32a0
movq %rax, -0x2a8(%rbp)
jmp 0xa75b
movq -0x2a8(%rbp), %rdi
leaq 0x3a77(%rip), %rsi      # 0xe1e0
callq 0x32e0
jmp 0xa770
movq -0x30(%rbp), %rax
movq %rax, -0x2b0(%rbp)
cmpq $0x0, %rax
je 0xa78d
movq -0x2b0(%rbp), %rdi
callq 0x3430
movl $0x0, -0x258(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x30b0
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
movq -0x250(%rbp), %rdi
callq 0x3580
nopl (%rax,%rax)