// File: /workspace/github_cpp_makefile_star2_O1/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, -0x38(%rbp)
movq %rdi, %rbx
leaq -0xe8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq -0xf8(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x1372a
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe130
movl %eax, %r13d
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0xbd61
callq 0x2220
testb %r13b, %r13b
je 0xbf3a
cmpb $0x0, 0x15(%rbx)
sete %al
xorb $0x1, %r12b
testb %r12b, %al
jne 0xbf46
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
sete %al
movl %eax, -0x2c(%rbp)
je 0xc0ab
leaq -0x58(%rbp), %r12
leaq 0xcf74(%rip), %r13      # 0x18d14
xorl %r14d, %r14d
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movw $0xdca0, -0x48(%rbp)    # imm = 0xDCA0
movl $0x2, %edx
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(%r14), %eax
movsbl %al, %esi
movq %r12, %rdi
callq 0x2200
movq %r12, %rdi
movl $0x4, %esi
callq 0x2200
movsbl 0x16(%rbx), %esi
movq %r12, %rdi
callq 0x2200
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %r14, %r15
shlq $0x5, %r15
movq (%rax,%r15), %rsi
movq 0x8(%rax,%r15), %rdx
movq %r12, %rdi
callq 0x20d0
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax,%r15), %r15d
movzbl 0x16(%rbx), %eax
cmpl %eax, %r15d
jge 0xbe40
movq %r12, %rdi
movq %r13, %rsi
callq 0x2450
incl %r15d
jmp 0xbe27
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xb8(%rbp), %rdi
callq 0x1372a
movq %rbx, %rdi
leaq -0xb8(%rbp), %rsi
callq 0xe6b2
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0xbe8c
callq 0x2220
movq -0x70(%rbp), %rdx
leaq -0x98(%rbp), %rdi
movq %rbx, %rsi
callq 0xde7c
movq -0x90(%rbp), %rdx
movb $0x1, %r15b
cmpq -0x70(%rbp), %rdx
jne 0xbecf
testq %rdx, %rdx
je 0xbecc
movq -0x78(%rbp), %rsi
movq -0x98(%rbp), %rdi
callq 0x2260
testl %eax, %eax
setne %r15b
jmp 0xbecf
xorl %r15d, %r15d
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xbee7
callq 0x2220
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xbef9
callq 0x2220
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xbf0b
callq 0x2220
testb %r15b, %r15b
jne 0xc0ab
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
incq %r14
sarq $0x5, %rax
cmpq %rax, %r14
setae %al
movl %eax, -0x2c(%rbp)
jb 0xbda3
jmp 0xc0ab
movl $0x0, -0x2c(%rbp)
jmp 0xc0ab
movzwl 0xa(%rbx), %r14d
rolw $0x8, %r14w
movq -0x38(%rbp), %r13
movq (%r13), %rax
movl 0x8(%rax), %r12d
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movl $0xd6a0, (%rcx)         # imm = 0xD6A0
movq $0x4, -0x8(%rcx)
xorl %eax, %eax
movb %al, 0x4(%rcx)
leaq -0x68(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movw $0x90, (%rcx)
movq $0x2, -0x8(%rcx)
movb %al, 0x2(%rcx)
testb %r15b, %r15b
movl %r14d, %eax
cmovel %r12d, %eax
movsbl %al, %esi
leaq -0x58(%rbp), %rdi
callq 0x2200
movq (%r13), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq -0x58(%rbp), %rdi
callq 0x20d0
testb %r15b, %r15b
je 0xbfe6
movzbl %r12b, %eax
movzwl %r14w, %r12d
subl %eax, %r12d
jbe 0xbfe6
leaq 0xcd42(%rip), %r14      # 0x18d14
leaq -0x58(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2450
decl %r12d
jne 0xbfd6
leaq -0xc8(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %rdi
callq 0x1372a
leaq -0xd8(%rbp), %rsi
movq %rbx, %rdi
callq 0xe6b2
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0xc028
callq 0x2220
movq -0x70(%rbp), %rdx
leaq -0x98(%rbp), %rdi
movq %rbx, %rsi
callq 0xde7c
movq -0x90(%rbp), %rdx
cmpq -0x70(%rbp), %rdx
jne 0xc064
testq %rdx, %rdx
je 0xc06d
movq -0x78(%rbp), %rsi
movq -0x98(%rbp), %rdi
callq 0x2260
testl %eax, %eax
sete %al
jmp 0xc06f
movl $0x0, -0x2c(%rbp)
jmp 0xc072
movb $0x1, %al
movl %eax, -0x2c(%rbp)
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc087
callq 0x2220
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xc099
callq 0x2220
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xc0ab
callq 0x2220
movl -0x2c(%rbp), %eax
andb $0x1, %al
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc10b
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
jne 0xc102
jmp 0xc10e
jmp 0xc10b
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
jne 0xc12d
jmp 0xc132
jmp 0xc10b
jmp 0xc10b
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0xc10e
callq 0x2220
jmp 0xc10e
jmp 0xc10b
movq %rax, %rbx
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xc120
callq 0x2220
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xc132
callq 0x2220
movq %rbx, %rdi
callq 0x2400