// File: /workspace/github_cpp_makefile_star2_O1/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 $0x138, %rsp            # imm = 0x138
movq %rsi, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, -0x98(%rbp)
movq $0x0, 0x10(%rdi)
leaq -0x150(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq -0x160(%rbp), %rdi
callq 0x1372a
leaq -0x160(%rbp), %rsi
movq %r15, %rdi
callq 0x11440
movl %eax, %ebx
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
je 0xb1d7
callq 0x2220
testb %bl, %bl
je 0xb712
cmpq $0x3, 0x30(%r15)
movq %r15, -0xc0(%rbp)
jae 0xb4b9
movslq 0x48(%r15), %r13
leaq -0xa8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xd1ab(%rip), %rdx      # 0x183b2
leaq -0xb8(%rbp), %rdi
movq %rdx, %rsi
callq 0x137c4
cmpl $0x7ffe, %r13d          # imm = 0x7FFE
jg 0xb72b
testl %r13d, %r13d
jle 0xb6e7
leaq -0x78(%rbp), %r14
leaq -0x110(%rbp), %rbx
xorl %eax, %eax
movq %rbx, %r15
movq %r14, -0x88(%rbp)
movw $0xb000, -0x78(%rbp)    # imm = 0xB000
movl $0x2, %edx
movq %rdx, -0x80(%rbp)
xorl %ecx, %ecx
movb %cl, -0x76(%rbp)
movq %rax, %rbx
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, %r12d
cmovlq %r13, %r12
leaq -0x38(%rbp), %r14
movq %r14, -0x48(%rbp)
movq %rbx, -0x90(%rbp)
movb %bh, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movb %cl, -0x37(%rbp)
movl $0x1, %edx
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0xb2c0
callq 0x2220
movq %r14, -0x48(%rbp)
movq -0x90(%rbp), %rax
movb %al, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movb $0x0, -0x37(%rbp)
movl $0x1, %edx
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x20d0
movq %r15, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
movq -0xc0(%rbp), %r15
je 0xb306
callq 0x2220
movq %r14, -0x48(%rbp)
movb %r12b, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movb $0x0, -0x37(%rbp)
movl $0x1, %edx
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x20d0
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0xb33c
callq 0x2220
movq %rbx, -0x120(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
addq %rsi, %rdx
leaq -0x120(%rbp), %r14
movq %r14, %rdi
callq 0x1372a
movq %r15, %rdi
movq %r14, %rsi
callq 0xe6b2
movq -0x120(%rbp), %rdi
cmpq %rbx, %rdi
je 0xb37c
callq 0x2220
leaq 0x2(%r12), %rdx
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0xde7c
movq -0x40(%rbp), %r14
movq -0x60(%rbp), %rax
leaq (%rax,%r12), %r15
cmpq %r15, %r14
jne 0xb3e8
movq %r14, %rdx
subq %rax, %rdx
leaq -0xe0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq $-0x1, %rcx
callq 0x2270
movq -0xd8(%rbp), %rdx
cmpq -0x60(%rbp), %rdx
jne 0xb3e8
testq %rdx, %rdx
je 0xb4b2
movq -0x68(%rbp), %rsi
movq -0xe0(%rbp), %rdi
callq 0x2260
testl %eax, %eax
sete %bl
jmp 0xb3ea
xorl %ebx, %ebx
cmpq %r15, %r14
leaq -0x78(%rbp), %r14
jne 0xb40b
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0xb40b
callq 0x2220
testb %bl, %bl
leaq -0x110(%rbp), %rbx
je 0xb462
movq -0x40(%rbp), %rcx
subq -0x60(%rbp), %rcx
leaq -0x100(%rbp), %rdi
leaq -0x48(%rbp), %rsi
xorl %edx, %edx
callq 0x2270
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x20d0
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0xb462
callq 0x2220
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xb474
callq 0x2220
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xb486
callq 0x2220
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
je 0xb497
callq 0x2220
subq %r12, %r13
movq -0x90(%rbp), %rax
addq %r12, %rax
testq %r13, %r13
jg 0xb239
jmp 0xb6e7
movb $0x1, %bl
jmp 0xb3ea
leaq 0x28(%r15), %rsi
movq (%rsi), %rax
cmpb $0x0, 0x4(%rax)
je 0xb712
leaq -0xa8(%rbp), %r13
leaq -0x78(%rbp), %r14
xorl %r12d, %r12d
movq %rsi, -0x90(%rbp)
movq %r13, -0xb8(%rbp)
movl $0x401b200, -0xa8(%rbp) # imm = 0x401B200
movq $0x4, -0xb0(%rbp)
xorl %eax, %eax
movb %al, -0xa4(%rbp)
movq %r14, -0x88(%rbp)
movw $0x90, -0x78(%rbp)
movq $0x2, -0x80(%rbp)
movb %al, -0x76(%rbp)
movl $0x3, %edx
movl $0x1, %ecx
leaq -0x68(%rbp), %rdi
callq 0x2270
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x20d0
leaq -0x130(%rbp), %r14
leaq -0x140(%rbp), %r13
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xb562
callq 0x2220
movq %r14, -0x140(%rbp)
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x1372a
movq %r15, %rdi
movq %r13, %rsi
callq 0xe6b2
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
je 0xb59e
callq 0x2220
movq 0x28(%r15), %rax
movzbl 0x3(%rax), %edx
addq $0x2, %rdx
leaq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0xde7c
movq -0x60(%rbp), %r13
movq -0x90(%rbp), %rax
movq (%rax), %rax
movzbl 0x3(%rax), %r15d
movq -0x80(%rbp), %rax
addq %rax, %r15
cmpq %r15, %r13
jne 0xb61a
movq %r13, %rdx
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 0xb61a
testq %rdx, %rdx
je 0xb6df
movq -0x88(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x2260
testl %eax, %eax
sete %r14b
jmp 0xb61d
xorl %r14d, %r14d
cmpq %r15, %r13
movq -0xc0(%rbp), %r15
leaq -0xa8(%rbp), %r13
jne 0xb642
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xb642
callq 0x2220
testb %r14b, %r14b
leaq -0x78(%rbp), %r14
je 0xb68f
movq -0x60(%rbp), %rcx
subq -0x80(%rbp), %rcx
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x68(%rbp), %rsi
xorl %edx, %edx
callq 0x2270
movq -0x98(%rbp), %rdi
movq %rbx, %rsi
callq 0x1385e
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0xb68f
callq 0x2220
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xb6a1
callq 0x2220
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
je 0xb6b2
callq 0x2220
movq -0xb8(%rbp), %rdi
cmpq %r13, %rdi
je 0xb6c3
callq 0x2220
incl %r12d
movq -0x90(%rbp), %rsi
movq (%rsi), %rax
movzbl 0x4(%rax), %eax
cmpl %eax, %r12d
jb 0xb4df
jmp 0xb712
movb $0x1, %r14b
jmp 0xb61d
leaq -0xb8(%rbp), %rsi
movq -0x98(%rbp), %rdi
callq 0xc4f4
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0xb712
callq 0x2220
movq -0x98(%rbp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x270d
movq %rax, %rbx
jmp 0xb815
jmp 0xb752
movq %rax, %rbx
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
jne 0xb828
jmp 0xb82d
movq %rax, %rbx
jmp 0xb82d
jmp 0xb75c
movq %rax, %rbx
jmp 0xb77c
movq %rax, %rbx
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0xb77c
callq 0x2220
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
jmp 0xb79b
jmp 0xb7d3
jmp 0xb7d3
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
jne 0xb7c8
jmp 0xb7d6
jmp 0xb7a6
jmp 0xb7a6
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
jne 0xb7c8
jmp 0xb7d6
jmp 0xb7d3
movq %rbx, %rcx
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %rcx, %rdi
je 0xb7d6
callq 0x2220
jmp 0xb7d6
jmp 0xb7d3
jmp 0xb7fd
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0xb800
callq 0x2220
jmp 0xb800
jmp 0xb7fd
movq %rax, %rbx
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
jne 0xb7e3
jmp 0xb800
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xb815
callq 0x2220
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0xb82d
callq 0x2220
movq -0x98(%rbp), %rdi
callq 0xafd4
movq %rbx, %rdi
callq 0x2400
nop