// File: /workspace/github_cpp_makefile_star2_O2/FFY00[P]uicc/include/uicc.h
// Function: SIM::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;

        unsigned char size=( unsigned char)content[0].size();
        uint16_t fileSize=ntohs(curFile.size);

        if (curFile.structure==0 && records==false) { // binary (flat)
            Assert(size <= 256, "Not developped: write binary files > 256 bytes");
            string command(u8"\xa0\xd6\x00\x00",4);
            string good(u8"\x90\x00",2);

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

            command+=content[0];

            if (fillIt)
                for (int j=size; j < 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"\xa0\xdc",2);
                string good(u8"\x90\x00",2);
                command+=(unsigned char) i+1;
                command+='\x04';
                command+=curFile.record_length; //record lenght;
                command+=content[i];

                for (int j=content[i].size(); j< curFile.record_length ; 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 $0xd8, %rsp
movl %r8d, %r12d
movl %ecx, %r15d
movq %rdx, %r14
movq %rdi, %rbx
leaq -0xf8(%rbp), %r13
movq %r13, %rdi
callq 0x2330
movq %rbx, %rdi
movq %r13, %rsi
callq 0xae28
movl %eax, %r13d
leaq -0xf8(%rbp), %rdi
callq 0x2120
testb %r13b, %r13b
je 0x958f
movq %r14, -0x38(%rbp)
cmpb $0x0, 0x15(%rbx)
sete %al
xorb $0x1, %r12b
testb %r12b, %al
jne 0x959b
leaq -0x58(%rbp), %r12
leaq 0xa891(%rip), %r13      # 0x13cf4
xorl %r15d, %r15d
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq %rax, %r15
setae %al
jae 0x96a6
movl %eax, -0x2c(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movw $0xdca0, -0x48(%rbp)    # imm = 0xDCA0
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)
leal 0x1(%r15), %eax
movsbl %al, %esi
movq %r12, %rdi
callq 0x21f0
movq %r12, %rdi
pushq $0x4
popq %rsi
callq 0x21f0
movsbl 0x16(%rbx), %esi
movq %r12, %rdi
callq 0x21f0
movq %r15, %r14
shlq $0x5, %r14
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r14, %rsi
movq %r12, %rdi
callq 0x2470
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax,%r14), %r14d
movzbl 0x16(%rbx), %eax
cmpl %eax, %r14d
jge 0x9517
movq %r12, %rdi
movq %r13, %rsi
callq 0x2440
incl %r14d
jmp 0x94fe
leaq -0xb8(%rbp), %rdi
movq %r12, %rsi
callq 0x2330
movq %rbx, %rdi
leaq -0xb8(%rbp), %r14
movq %r14, %rsi
callq 0xb178
movq %r14, %rdi
callq 0x2120
movq -0x70(%rbp), %rdx
leaq -0xd8(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xac6e
movq %r14, %rdi
leaq -0x78(%rbp), %rsi
callq 0xa602
movq %r14, %rdi
movl %eax, %r14d
callq 0x2120
leaq -0x78(%rbp), %rdi
callq 0x2120
movq %r12, %rdi
callq 0x2120
incq %r15
testb %r14b, %r14b
je 0x9466
jmp 0x96ab
movl $0x0, -0x2c(%rbp)
jmp 0x96ab
movzwl 0xa(%rbx), %r14d
rolw $0x8, %r14w
movq -0x38(%rbp), %r13
movq (%r13), %rax
movl 0x8(%rax), %r12d
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movl $0xd6a0, (%rax)         # imm = 0xD6A0
movq $0x4, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, 0x4(%rax)
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
movw $0x90, (%rax)
movq $0x2, -0x8(%rax)
movb %cl, 0x2(%rax)
testb %r15b, %r15b
movl %r14d, %eax
cmovel %r12d, %eax
movsbl %al, %esi
leaq -0x58(%rbp), %rdi
callq 0x21f0
movq (%r13), %rsi
leaq -0x58(%rbp), %rdi
callq 0x2470
testb %r15b, %r15b
je 0x9634
movzbl %r12b, %r12d
movzwl %r14w, %r13d
leaq 0xa6d9(%rip), %r14      # 0x13cf4
leaq -0x58(%rbp), %r15
cmpl %r13d, %r12d
jae 0x9634
movq %r15, %rdi
movq %r14, %rsi
callq 0x2440
incl %r12d
jmp 0x961f
leaq -0x98(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2330
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0xb178
leaq -0x98(%rbp), %rdi
callq 0x2120
movq -0x70(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
movq %rbx, %rsi
callq 0xac6e
leaq -0xd8(%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 0x96ab
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x96f3
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
jmp 0x96e8
jmp 0x96f3
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
jmp 0x9703
jmp 0x96f3
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x2120
jmp 0x96f6
jmp 0x96f3
jmp 0x96f3
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x2120
leaq -0x58(%rbp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x2400