// File: 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
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdx, -0x1a8(%rbp)
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %cl
movb %cl, -0x21(%rbp)
andb $0x1, %al
movb %al, -0x22(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x3120
movq -0x1a0(%rbp), %rdi
movq -0x198(%rbp), %rsi
callq 0x14410
movb %al, -0x189(%rbp)
jmp 0x10a82
movb -0x189(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1a9(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x31a0
movb -0x1a9(%rbp), %al
testb $0x1, %al
jne 0x10aa5
jmp 0x10ac8
movb $0x0, -0x1(%rbp)
jmp 0x110b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x31a0
jmp 0x110be
movq -0x1a8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf690
movq %rax, %rdi
callq 0x31f0
movq %rax, %rcx
movq -0x1a0(%rbp), %rax
movb %cl, -0x55(%rbp)
movzwl 0xa(%rax), %edi
callq 0x34f0
movw %ax, %cx
movq -0x1a0(%rbp), %rax
movw %cx, -0x58(%rbp)
movzbl 0x15(%rax), %eax
cmpl $0x0, %eax
jne 0x10dd4
movb -0x22(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x10dd4
jmp 0x10b24
movzbl -0x55(%rbp), %eax
cmpl $0x100, %eax            # imm = 0x100
jle 0x10ba0
movq 0x1e49a(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0x1b8(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0x1b8(%rbp), %rdi
movq %rax, %r9
leaq 0x15606(%rip), %rsi     # 0x26163
leaq 0x15693(%rip), %rdx     # 0x261f7
leaq 0x14cfb(%rip), %rcx     # 0x25866
movl $0x27a, %r8d            # imm = 0x27A
movb $0x0, %al
callq 0x3410
movq 0x1e421(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
movq 0x1e442(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
movl $0x1, %edi
callq 0x3370
jmp 0x10ba2
leaq -0x79(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x34d0
movq -0x1c0(%rbp), %rcx
leaq 0x12710(%rip), %rsi     # 0x232d0
leaq -0x78(%rbp), %rdi
movl $0x4, %edx
callq 0x3330
jmp 0x10bd0
leaq -0x79(%rbp), %rdi
callq 0x3300
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x34d0
movq -0x1c8(%rbp), %rcx
leaq 0x1266b(%rip), %rsi     # 0x23265
leaq -0xa0(%rbp), %rdi
movl $0x2, %edx
callq 0x3330
jmp 0x10c0d
leaq -0xa1(%rbp), %rdi
callq 0x3300
testb $0x1, -0x21(%rbp)
je 0x10c78
movsbl -0x58(%rbp), %esi
leaq -0x78(%rbp), %rdi
callq 0x31b0
jmp 0x10c2e
jmp 0x10c89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x3300
jmp 0x110be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa1(%rbp), %rdi
callq 0x3300
jmp 0x10dc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10dba
movsbl -0x55(%rbp), %esi
leaq -0x78(%rbp), %rdi
callq 0x31b0
jmp 0x10c87
jmp 0x10c89
movq -0x1a8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf690
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x33b0
jmp 0x10ca7
testb $0x1, -0x21(%rbp)
je 0x10cec
movzbl -0x55(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
movzwl -0x58(%rbp), %ecx
cmpl %ecx, %eax
jge 0x10cea
leaq 0x15535(%rip), %rsi     # 0x26201
leaq -0x78(%rbp), %rdi
callq 0x3280
jmp 0x10cd7
jmp 0x10cd9
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x10cb7
jmp 0x10cec
leaq -0xc8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3120
jmp 0x10cfe
movq -0x1a0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x14a30
jmp 0x10d13
leaq -0xc8(%rbp), %rdi
callq 0x31a0
leaq -0xa0(%rbp), %rdi
callq 0x31f0
movq -0x1a0(%rbp), %rsi
movq %rax, %rdx
leaq -0xe8(%rbp), %rdi
callq 0x13fd0
jmp 0x10d43
leaq -0xe8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x14ed0
testb $0x1, %al
jne 0x10d5c
jmp 0x10d86
movb $0x1, -0x1(%rbp)
movl $0x1, -0xec(%rbp)
jmp 0x10d94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x31a0
jmp 0x10dba
movb $0x0, -0x1(%rbp)
movl $0x1, -0xec(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x31a0
leaq -0xa0(%rbp), %rdi
callq 0x31a0
leaq -0x78(%rbp), %rdi
callq 0x31a0
jmp 0x110b0
leaq -0xa0(%rbp), %rdi
callq 0x31a0
leaq -0x78(%rbp), %rdi
callq 0x31a0
jmp 0x110be
movq $0x0, -0xf8(%rbp)
movq -0x1a8(%rbp), %rdi
movq -0xf8(%rbp), %rax
movq %rax, -0x1d0(%rbp)
callq 0x12e20
movq %rax, %rcx
movq -0x1d0(%rbp), %rax
cmpq %rcx, %rax
jae 0x110aa
leaq -0x119(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x34d0
movq -0x1d8(%rbp), %rcx
leaq 0x153d6(%rip), %rsi     # 0x26203
leaq -0x118(%rbp), %rdi
movl $0x2, %edx
callq 0x3330
jmp 0x10e40
leaq -0x119(%rbp), %rdi
callq 0x3300
leaq -0x141(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x34d0
movq -0x1e0(%rbp), %rcx
leaq 0x123f8(%rip), %rsi     # 0x23265
leaq -0x140(%rbp), %rdi
movl $0x2, %edx
callq 0x3330
jmp 0x10e80
leaq -0x141(%rbp), %rdi
callq 0x3300
movl -0xf8(%rbp), %eax
incl %eax
movsbl %al, %esi
leaq -0x118(%rbp), %rdi
callq 0x31b0
jmp 0x10ea5
leaq -0x118(%rbp), %rdi
movl $0x4, %esi
callq 0x31b0
jmp 0x10eb8
movq -0x1a0(%rbp), %rax
movsbl 0x16(%rax), %esi
leaq -0x118(%rbp), %rdi
callq 0x31b0
jmp 0x10ed1
movq -0x1a8(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0xf690
movq %rax, %rsi
leaq -0x118(%rbp), %rdi
callq 0x33b0
jmp 0x10ef5
movq -0x1a8(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0xf690
movq %rax, %rdi
callq 0x31f0
movl %eax, -0x148(%rbp)
movq -0x1a0(%rbp), %rcx
movl -0x148(%rbp), %eax
movzbl 0x16(%rcx), %ecx
cmpl %ecx, %eax
jge 0x10f9e
leaq 0x152cf(%rip), %rsi     # 0x26201
leaq -0x118(%rbp), %rdi
callq 0x3280
jmp 0x10f40
jmp 0x10f42
movl -0x148(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x148(%rbp)
jmp 0x10f16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x119(%rbp), %rdi
callq 0x3300
jmp 0x110be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x141(%rbp), %rdi
callq 0x3300
jmp 0x1109c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x11090
leaq -0x168(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x3120
jmp 0x10fb3
movq -0x1a0(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x14a30
jmp 0x10fc8
leaq -0x168(%rbp), %rdi
callq 0x31a0
leaq -0x140(%rbp), %rdi
callq 0x31f0
movq -0x1a0(%rbp), %rsi
movq %rax, %rdx
leaq -0x188(%rbp), %rdi
callq 0x13fd0
jmp 0x10ff8
leaq -0x188(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x12e40
testb $0x1, %al
jne 0x11011
jmp 0x1103b
movb $0x0, -0x1(%rbp)
movl $0x1, -0xec(%rbp)
jmp 0x11045
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x31a0
jmp 0x11090
movl $0x0, -0xec(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x31a0
leaq -0x140(%rbp), %rdi
callq 0x31a0
leaq -0x118(%rbp), %rdi
callq 0x31a0
movl -0xec(%rbp), %eax
testl %eax, %eax
je 0x11077
jmp 0x11075
jmp 0x110b0
jmp 0x11079
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
jmp 0x10ddf
leaq -0x140(%rbp), %rdi
callq 0x31a0
leaq -0x118(%rbp), %rdi
callq 0x31a0
jmp 0x110be
jmp 0x110ac
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x34b0
nopw (%rax,%rax)