// File: /workspace/github_cpp_makefile_star2_O2/FFY00[P]uicc/include/uicc.h
// Function: USIM::writeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, bool, bool)
bool writeFile(string filename, vector<string> content, bool fillIt=false, bool records=false) {
        if (!openFile(filename))
            return false;

        int size=content[0].size();

        if (fileDesc.size() <= 2) { // binary (flat)
            Assert(size <= 256, "Not developped: write binary files > 256 bytes");
            string command(u8"\x00\xd6\x00\x00",4);
            string good(u8"\x90\x00",2);
            unsigned char x=(char) size;

            if (fillIt)
                command+=(unsigned char)fileSize;
            else
                command+=x;

            command+=content[0];

            if (fillIt)
                for (int j=content[0].size();
                        j< (unsigned char) fileSize ;
                        j++)
                    command+=u8"\xff";

            write(command);
            string answ=read(good.size());

            if (answ == good)
                return true;
            else
                return false;
        } else { // records
            for (size_t i=0; i < content.size(); i++ ) {
                string command(u8"\x00\xdc",2);
                string good(u8"\x90\x00",2);
                command+=(unsigned char) i+1;
                command+='\x04';
                command+=fileDesc.substr(3,1); //record lenght;
                command+=content[i];

                for (int j=content[i].size();
                        j< (unsigned char) fileDesc[3] ;
                        j++)
                    command+=u8"\xff";

                write(command);
                string answ=read(good.size());

                if ( answ != good )
                    return false;
            }
        }

        return true;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %ecx, %ebx
movq %rdx, -0x38(%rbp)
movq %rdi, %r12
leaq -0x108(%rbp), %r14
movq %r14, %rdi
callq 0x2330
movq %r12, %rdi
movq %r14, %rsi
callq 0xd5aa
movl %eax, %r14d
leaq -0x108(%rbp), %rdi
callq 0x2120
testb %r14b, %r14b
je 0x9da2
cmpq $0x3, 0x30(%r12)
jae 0x9dae
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x101, %eax            # imm = 0x101
jge 0x9fa8
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movl $0xd600, (%rcx)         # imm = 0xD600
movq $0x4, -0x8(%rcx)
xorl %edx, %edx
movb %dl, 0x4(%rcx)
leaq -0x68(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movw $0x90, (%rcx)
movq $0x2, -0x8(%rcx)
movb %dl, 0x2(%rcx)
testb %bl, %bl
je 0x9d49
movl 0x48(%r12), %eax
movsbl %al, %esi
leaq -0x58(%rbp), %rdi
callq 0x21f0
movq -0x38(%rbp), %rax
movq (%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x2470
testb %bl, %bl
je 0x9f1c
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %r15d
leaq 0x9f75(%rip), %rbx      # 0x13cf4
leaq -0x58(%rbp), %r14
movzbl 0x48(%r12), %eax
cmpl %eax, %r15d
jge 0x9f1c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2440
incl %r15d
jmp 0x9d83
movl $0x0, -0x2c(%rbp)
jmp 0x9f93
movq %r12, -0x88(%rbp)
addq $0x28, %r12
leaq -0x58(%rbp), %r13
leaq 0x9f30(%rip), %r14      # 0x13cf4
leaq -0xe8(%rbp), %r15
xorl %esi, %esi
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq %rax, %rsi
setae %al
jae 0x9f8e
movl %eax, -0x2c(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movw $0xdc00, -0x48(%rbp)    # imm = 0xDC00
pushq $0x2
popq %rdx
movq %rdx, -0x50(%rbp)
xorl %ecx, %ecx
movb %cl, -0x46(%rbp)
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movw $0x90, -0x68(%rbp)
movq %rdx, -0x70(%rbp)
movb %cl, -0x66(%rbp)
movq %rsi, -0x80(%rbp)
leal 0x1(%rsi), %eax
movsbl %al, %esi
movq %r13, %rdi
callq 0x21f0
movq %r13, %rdi
pushq $0x4
popq %rsi
callq 0x21f0
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
callq 0x2260
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2470
movq %rbx, %rdi
callq 0x2120
movq -0x80(%rbp), %rbx
shlq $0x5, %rbx
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %rbx, %rsi
movq %r13, %rdi
callq 0x2470
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax,%rbx), %ebx
movq (%r12), %rax
movzbl 0x3(%rax), %eax
cmpl %eax, %ebx
jge 0x9ea2
movq %r13, %rdi
movq %r14, %rsi
callq 0x2440
incl %ebx
jmp 0x9e87
movq %r15, %rdi
movq %r13, %rsi
callq 0x2330
movq -0x88(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb178
movq %r15, %rdi
callq 0x2120
movq -0x70(%rbp), %rdx
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xac6e
movq %r15, %rdi
leaq -0x78(%rbp), %rsi
callq 0xa602
movl %eax, %ebx
movq %r15, %rdi
callq 0x2120
leaq -0x78(%rbp), %rdi
callq 0x2120
movq %r13, %rdi
callq 0x2120
movq -0x80(%rbp), %rsi
incq %rsi
testb %bl, %bl
leaq -0xe8(%rbp), %r15
je 0x9dcd
jmp 0x9f93
leaq -0xc8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2330
leaq -0xc8(%rbp), %rsi
movq %r12, %rdi
callq 0xb178
leaq -0xc8(%rbp), %rdi
callq 0x2120
movq -0x70(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
movq %r12, %rsi
callq 0xac6e
leaq -0xa8(%rbp), %rbx
leaq -0x78(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb402
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
callq 0x2120
movq %r14, %rdi
callq 0x2120
leaq -0x58(%rbp), %rdi
callq 0x2120
jmp 0x9f93
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf021(%rip), %r14      # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
leaq 0x9c91(%rip), %rsi      # 0x13c56
leaq 0x9d1e(%rip), %rdx      # 0x13cea
leaq 0x94b9(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x34f, %r8d            # imm = 0x34F
movq %rax, %r9
xorl %eax, %eax
callq 0x2360
movq 0xefbb(%rip), %rax      # 0x18fa8
movq (%rax), %rdi
callq 0x22c0
movq (%r14), %rdi
callq 0x22c0
pushq $0x1
popq %rdi
callq 0x22e0
jmp 0xa046
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0xa03b
jmp 0xa046
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0xa056
jmp 0xa046
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0xa03b
jmp 0xa046
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x2120
jmp 0xa049
jmp 0xa046
jmp 0xa046
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x2120
leaq -0x58(%rbp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x2400
nop