// File: /workspace/github_cpp_makefile_star2_O2/FFY00[P]uicc/include/uicc.h
// Function: USIM::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<string> readFile(string filename) {
        vector<string> content;

        if (!openFile(filename))
            return content;

        if (fileDesc.size() <= 2 ) { // this is a plain file
            long size=fileSize;
            string fullanswr="";
            Assert( size < 32767, "Not developped");
            long alreadyRead=0;

            while (size > 0 ) {
                string command(u8"\x00\xb0",2);
                string good(u8"\x90\x00",2);
                unsigned char s;

                if (size > 255)
                    s=255;
                else
                    s=size;

                unsigned char P1=alreadyRead>>8;
                unsigned char P2=alreadyRead&0xFF;
                command+=string((char *)&P1,1);
                command+=string((char *)&P2,1);
                command+=string((char *)&s,1);
                write(command);
                string answ=read(s+2);

                if ( answ.size()==(size_t)s+good.size() &&
                        answ.substr(answ.size()-good.size()) == good )
                    fullanswr+=answ.substr(0,answ.size()-good.size());

                size-=s;
                alreadyRead+=s;
            }

            content.push_back(fullanswr);
            return content;
        } else {
            // This is a records set file
            // records
            // string len must be 5 bytes
            // file type is byte 0
            // byte 1 is useless: always 0x21
            // bytes 3 and 4: record length
            // (byte 3 should be 00 according to ETSI 102 221)
            // byte 5: number of records
            for (int i=0; i < (unsigned char)fileDesc[4] ; i++ ) {
                string command(u8"\x00\xb2\x01\x04",4);
                string good(u8"\x90\x00",2);
                command+=fileDesc.substr(3,1);
                write(command);
                string answ=read( (unsigned char)fileDesc[3]+2);

                if ( answ.size()== ((unsigned char)fileDesc[3]+good.size()) &&
                        answ.substr(answ.size()-good.size()) == good )
                    content.push_back(answ.substr(0,answ.size()-good.size()));
            }

            return content;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, -0x30(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, -0x60(%rbp)
andq $0x0, 0x10(%rdi)
leaq -0xe8(%rbp), %rdi
movq %rdx, %rsi
callq 0x2330
leaq -0xe8(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xd5aa
movl %eax, %ebx
leaq -0xe8(%rbp), %rdi
callq 0x2120
testb %bl, %bl
je 0x8f90
movq -0x30(%rbp), %rax
cmpq $0x3, 0x30(%rax)
jae 0x8df4
movq -0x30(%rbp), %rax
movslq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
leaq 0xa792(%rip), %rsi      # 0x13392
leaq -0xc0(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x20f0
cmpl $0x7ffe, -0x38(%rbp)    # imm = 0x7FFE
jg 0x8fa6
leaq -0x48(%rbp), %rax
leaq -0x80(%rbp), %r14
leaq -0x58(%rbp), %r15
xorl %ebx, %ebx
cmpq $0x0, -0x38(%rbp)
jle 0x8f74
leaq -0x70(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movw $0xb000, -0x70(%rbp)    # imm = 0xB000
pushq $0x2
popq %rdx
movq %rdx, -0x78(%rbp)
xorl %ecx, %ecx
movb %cl, -0x6e(%rbp)
leaq -0x90(%rbp), %rsi
movq %rsi, -0xa0(%rbp)
movw $0x90, -0x90(%rbp)
movq %rdx, -0x98(%rbp)
movb %cl, -0x8e(%rbp)
movl $0xff, %edx
movq -0x38(%rbp), %rsi
cmpq %rdx, %rsi
movl $0xff, %r12d
cmovbq %rsi, %r12
movq %rax, -0x58(%rbp)
movb %bh, -0x48(%rbp)
movq $0x1, -0x50(%rbp)
movb %cl, -0x47(%rbp)
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %r13
movq %rax, %r14
callq 0x2470
movq %r15, %rdi
callq 0x2120
movq %r14, -0x58(%rbp)
movq %rbx, -0xc8(%rbp)
movb %bl, -0x48(%rbp)
movq $0x1, -0x50(%rbp)
movb $0x0, -0x47(%rbp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x2470
movq %r15, %rdi
callq 0x2120
movq %r14, -0x58(%rbp)
movq %r12, %rbx
movb %bl, -0x48(%rbp)
movq $0x1, -0x50(%rbp)
movb $0x0, -0x47(%rbp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x2470
movq %r13, %r14
movq %r15, %rdi
callq 0x2120
leaq -0x148(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x2330
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0xb178
leaq -0x128(%rbp), %r12
movq %r13, %rdi
callq 0x2120
leaq 0x2(%rbx), %rdx
movq %r15, %rdi
movq -0x30(%rbp), %rsi
callq 0xac6e
movq -0x50(%rbp), %rdx
movq -0x98(%rbp), %rax
leaq (%rax,%rbx), %rcx
cmpq %rcx, %rdx
jne 0x8dbe
subq %rax, %rdx
movq %r12, %rdi
movq %r15, %rsi
pushq $-0x1
popq %rcx
callq 0x2260
movq %r12, %rdi
leaq -0xa0(%rbp), %rsi
callq 0xb402
movl %eax, %r13d
movq %r12, %rdi
callq 0x2120
testb %r13b, %r13b
je 0x8dbe
movq -0x50(%rbp), %rcx
subq -0x98(%rbp), %rcx
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2260
leaq -0xc0(%rbp), %rdi
movq %r12, %rsi
callq 0x2470
movq %r12, %rdi
callq 0x2120
subq %rbx, -0x38(%rbp)
movq %rbx, %rax
movq -0xc8(%rbp), %rbx
addq %rax, %rbx
movq %r15, %rdi
callq 0x2120
leaq -0xa0(%rbp), %rdi
callq 0x2120
movq %r14, %rdi
callq 0x2120
leaq -0x48(%rbp), %rax
jmp 0x8c2b
movq -0x30(%rbp), %rax
leaq 0x28(%rax), %r13
leaq -0xa0(%rbp), %r12
leaq -0x108(%rbp), %r15
xorl %ecx, %ecx
movq (%r13), %rax
movzbl 0x4(%rax), %eax
cmpl %eax, %ecx
jae 0x8f90
movl %ecx, -0x38(%rbp)
leaq -0xb0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl $0x401b200, -0xb0(%rbp) # imm = 0x401B200
movq $0x4, -0xb8(%rbp)
xorl %ecx, %ecx
movb %cl, -0xac(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movw $0x90, -0x70(%rbp)
movq $0x2, -0x78(%rbp)
movb %cl, -0x6e(%rbp)
movq %r12, %rdi
movq %r13, %rsi
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
callq 0x2260
leaq -0xc0(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x2470
movq %r12, %rbx
movq %r12, %rdi
callq 0x2120
movq %r15, %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x2330
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0xb178
movq %r12, %rdi
callq 0x2120
movq -0x30(%rbp), %rsi
movq 0x28(%rsi), %rax
movzbl 0x3(%rax), %edx
addq $0x2, %rdx
movq %rbx, %r12
movq %rbx, %rdi
callq 0xac6e
movq -0x98(%rbp), %rdx
movq (%r13), %rax
movzbl 0x3(%rax), %ecx
movq -0x78(%rbp), %rax
addq %rax, %rcx
cmpq %rcx, %rdx
jne 0x8f4d
subq %rax, %rdx
leaq -0x58(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
pushq $-0x1
popq %rcx
callq 0x2260
movq %r14, %rdi
leaq -0x80(%rbp), %rsi
callq 0xb402
movl %eax, %r12d
movq %r14, %rdi
callq 0x2120
testb %r12b, %r12b
movq %rbx, %r12
je 0x8f4d
movq -0x98(%rbp), %rcx
subq -0x78(%rbp), %rcx
leaq -0x58(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2260
movq -0x60(%rbp), %rdi
movq %rbx, %rsi
callq 0xf1f8
movq %rbx, %rdi
callq 0x2120
movq %r12, %rdi
callq 0x2120
leaq -0x80(%rbp), %rdi
callq 0x2120
leaq -0xc0(%rbp), %rdi
callq 0x2120
movl -0x38(%rbp), %ecx
incl %ecx
jmp 0x8e0c
leaq -0xc0(%rbp), %rsi
movq -0x60(%rbp), %rdi
callq 0x99ca
leaq -0xc0(%rbp), %rdi
callq 0x2120
movq -0x60(%rbp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10023(%rip), %r14     # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
leaq 0xab22(%rip), %rsi      # 0x13ae5
leaq 0xa709(%rip), %rdx      # 0x136d3
leaq 0xa4bb(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x310, %r8d            # imm = 0x310
movq %rax, %r9
xorl %eax, %eax
callq 0x2360
movq 0xffbd(%rip), %rax      # 0x18fa8
movq (%rax), %rdi
callq 0x22c0
movq (%r14), %rdi
callq 0x22c0
pushq $0x1
popq %rdi
callq 0x22e0
movq %rax, %rbx
jmp 0x9085
jmp 0x9016
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x908c
movq %rax, %rbx
jmp 0x9091
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x2120
jmp 0x904d
jmp 0x904a
jmp 0x904a
jmp 0x906d
jmp 0x904a
jmp 0x906d
jmp 0x904a
jmp 0x904a
jmp 0x906d
jmp 0x906d
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
jmp 0x9051
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x2120
jmp 0x9070
jmp 0x9068
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x9077
jmp 0x9068
movq %rax, %rbx
jmp 0x907c
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x2120
leaq -0x80(%rbp), %rdi
callq 0x2120
leaq -0xc0(%rbp), %rdi
callq 0x2120
movq -0x60(%rbp), %rdi
callq 0x8a5a
movq %rbx, %rdi
callq 0x2400