// File: /workspace/github_cpp_makefile_star2_O3/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 $0x118, %rsp            # imm = 0x118
movq %rsi, %r12
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, -0x90(%rbp)
movq $0x0, 0x10(%rdi)
leaq -0x128(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0x138(%rbp), %rdi
callq 0x1394e
leaq -0x138(%rbp), %rsi
movq %r12, %rdi
callq 0x1168e
movl %eax, %ebx
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
je 0xb4dd
callq 0x2220
testb %bl, %bl
je 0xb9e4
cmpq $0x3, 0x30(%r12)
movq %r12, -0xb8(%rbp)
jae 0xb7d0
movslq 0x48(%r12), %r13
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xcea3(%rip), %rdx      # 0x183b2
leaq -0xb0(%rbp), %rdi
movq %rdx, %rsi
callq 0x139ec
cmpl $0x7ffe, %r13d          # imm = 0x7FFE
jg 0xb9fd
testl %r13d, %r13d
jle 0xb79c
xorl %ebx, %ebx
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movw $0xb000, -0x78(%rbp)    # imm = 0xB000
movl $0x2, %edx
movq %rdx, -0x80(%rbp)
xorl %ecx, %ecx
movb %cl, -0x76(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movw $0x90, -0x58(%rbp)
movq %rdx, -0x60(%rbp)
movb %cl, -0x56(%rbp)
movl $0xff, %eax
cmpq %rax, %r13
movl $0xff, %r14d
cmovbq %r13, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x48(%rbp)
movb %bh, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movb %cl, -0x37(%rbp)
movl $0x1, %edx
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xb5b4
callq 0x2220
movq %r15, -0x48(%rbp)
movb %bl, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movb $0x0, -0x37(%rbp)
movl $0x1, %edx
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xb5e9
callq 0x2220
movq %r15, -0x48(%rbp)
movb %r14b, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movb $0x0, -0x37(%rbp)
movl $0x1, %edx
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xb61f
callq 0x2220
leaq -0x108(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %r15
movq %r15, %rdi
callq 0x1394e
movq %r12, %rdi
movq %r15, %rsi
callq 0xe93c
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0xb66d
callq 0x2220
leaq 0x2(%r14), %rdx
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
callq 0xe17e
movq -0x40(%rbp), %rdx
movq -0x60(%rbp), %rax
leaq (%rax,%r14), %rcx
cmpq %rcx, %rdx
jne 0xb754
subq %rax, %rdx
leaq -0xd8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq $-0x1, %rcx
callq 0x2270
movq -0xd0(%rbp), %rdx
cmpq -0x60(%rbp), %rdx
jne 0xb6d9
movq -0xd8(%rbp), %r12
testq %rdx, %rdx
je 0xb6e5
movq -0x68(%rbp), %rsi
movq %r12, %rdi
callq 0x2260
testl %eax, %eax
sete %r15b
jmp 0xb6e8
movq -0xd8(%rbp), %r12
xorl %r15d, %r15d
jmp 0xb6e8
movb $0x1, %r15b
leaq -0xc8(%rbp), %rax
cmpq %rax, %r12
je 0xb6fc
movq %r12, %rdi
callq 0x2220
testb %r15b, %r15b
movq -0xb8(%rbp), %r12
je 0xb754
movq -0x40(%rbp), %rcx
subq -0x60(%rbp), %rcx
leaq -0xd8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
xorl %edx, %edx
callq 0x2270
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x20d0
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0xb754
callq 0x2220
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xb766
callq 0x2220
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xb778
callq 0x2220
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xb78d
callq 0x2220
subq %r14, %r13
addq %r14, %rbx
testq %r13, %r13
jg 0xb536
leaq -0xb0(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0xc7c6
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0xb9e4
callq 0x2220
jmp 0xb9e4
leaq 0x28(%r12), %rbx
movq (%rbx), %rax
cmpb $0x0, 0x4(%rax)
je 0xb9e4
leaq -0xa0(%rbp), %r13
xorl %r14d, %r14d
movq %r13, -0xb0(%rbp)
movl $0x401b200, -0xa0(%rbp) # imm = 0x401B200
movq $0x4, -0xa8(%rbp)
xorl %ecx, %ecx
movb %cl, -0x9c(%rbp)
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movw $0x90, -0x78(%rbp)
movq $0x2, -0x80(%rbp)
movb %cl, -0x76(%rbp)
movl $0x3, %edx
movl $0x1, %ecx
leaq -0x68(%rbp), %rdi
movq %rbx, %rsi
callq 0x2270
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x20d0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xb868
callq 0x2220
leaq -0xe8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf8(%rbp), %r15
movq %r15, %rdi
callq 0x1394e
movq %r12, %rdi
movq %r15, %rsi
callq 0xe93c
movq -0xf8(%rbp), %rdi
leaq -0xe8(%rbp), %rax
cmpq %rax, %rdi
je 0xb8b9
callq 0x2220
movq 0x28(%r12), %rax
movzbl 0x3(%rax), %edx
addq $0x2, %rdx
leaq -0x68(%rbp), %rdi
movq %r12, %rsi
callq 0xe17e
movq -0x60(%rbp), %rdx
movq (%rbx), %rax
movzbl 0x3(%rax), %ecx
movq -0x80(%rbp), %rax
addq %rax, %rcx
cmpq %rcx, %rdx
jne 0xb999
subq %rax, %rdx
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq $-0x1, %rcx
callq 0x2270
movq -0x40(%rbp), %rdx
cmpq -0x80(%rbp), %rdx
jne 0xb92e
movq -0x48(%rbp), %r12
testq %rdx, %rdx
je 0xb937
movq -0x88(%rbp), %rsi
movq %r12, %rdi
callq 0x2260
testl %eax, %eax
sete %r13b
jmp 0xb93a
movq -0x48(%rbp), %r12
xorl %r13d, %r13d
jmp 0xb93a
movb $0x1, %r13b
leaq -0x38(%rbp), %rax
cmpq %rax, %r12
je 0xb94b
movq %r12, %rdi
callq 0x2220
testb %r13b, %r13b
movq -0xb8(%rbp), %r12
leaq -0xa0(%rbp), %r13
je 0xb999
movq -0x60(%rbp), %rcx
subq -0x80(%rbp), %rcx
leaq -0x48(%rbp), %r15
movq %r15, %rdi
leaq -0x68(%rbp), %rsi
xorl %edx, %edx
callq 0x2270
movq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0x13a8a
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xb999
callq 0x2220
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xb9ab
callq 0x2220
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xb9c0
callq 0x2220
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0xb9d1
callq 0x2220
incl %r14d
movq (%rbx), %rax
movzbl 0x4(%rax), %eax
cmpl %eax, %r14d
jb 0xb7ec
movq -0x90(%rbp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x270d
movq %rax, %rbx
jmp 0xbad7
jmp 0xba24
movq %rax, %rbx
movq -0x138(%rbp), %rdi
cmpq %r14, %rdi
jne 0xbaea
jmp 0xbaef
movq %rax, %rbx
jmp 0xbaef
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0xba52
callq 0x2220
jmp 0xba52
jmp 0xba4f
jmp 0xba4f
jmp 0xba93
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
jmp 0xba83
jmp 0xba93
jmp 0xba62
jmp 0xba62
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
jne 0xba88
jmp 0xba96
jmp 0xba93
movq %rax, %rbx
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0xba96
callq 0x2220
jmp 0xba96
jmp 0xba93
jmp 0xbabf
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xbac2
callq 0x2220
jmp 0xbac2
jmp 0xbabf
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
leaq -0xe8(%rbp), %rax
jmp 0xba9e
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xbad7
callq 0x2220
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0xbaef
callq 0x2220
movq -0x90(%rbp), %rdi
callq 0xb2cc
movq %rbx, %rdi
callq 0x2400
nop