// File: FFY00[P]uicc/include/uicc.h
// Function: UICC::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int write(string buf) {
        if (debug)
            dump_hex("Sending", buf);

        size_t size=buf.size();
        Assert( size >= 5, "");

        for (int i=0; i<5; i++ ) {
            ::write(fd, &buf[i], 1);
            // UICC have only one wire for Tx and Rx,
            // so over a RS232 we always receive back what we send
            char c;
            Assert(::read(fd, &c, 1)==1,
                   "All data sent must echo back" );
        }

        // Read UICC acknowledge the order
        if (buf[0] == (int8_t)'\xa0'|| buf[0] == (int8_t)'\x00' ) {
            char c;
            int ret=::read(fd, &c, 1);
            Assert( ret ==1 && c == buf[1],
                    "UICC answer is %02hhx instead of %02hhx",c, buf[1]);
        } else
            printf("WARNING: Non standard packet sent\n");

        for (size_t i=5; i<size; i++ ) {
            ::write(fd, &buf[i], 1);
            char c;
            Assert(::read(fd, &c, 1)==1,
                   "All data sent must echo back" );
        }

        return size;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rsi, -0xa0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
testb $0x1, (%rax)
je 0x14b0d
leaq -0x31(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x34d0
movq -0xa8(%rbp), %rdx
leaq 0x1135a(%rip), %rsi     # 0x25dd6
leaq -0x30(%rbp), %rdi
callq 0x33e0
jmp 0x14a87
movq -0xa0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x3120
jmp 0x14a99
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xd1b0
jmp 0x14aa8
leaq -0x68(%rbp), %rdi
callq 0x31a0
leaq -0x30(%rbp), %rdi
callq 0x31a0
leaq -0x31(%rbp), %rdi
callq 0x3300
jmp 0x14b0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x14aff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x14af6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x31a0
leaq -0x30(%rbp), %rdi
callq 0x31a0
leaq -0x31(%rbp), %rdi
callq 0x3300
jmp 0x14ec7
movq -0xa0(%rbp), %rdi
callq 0x31f0
movq %rax, -0x70(%rbp)
cmpq $0x5, -0x70(%rbp)
jae 0x14b95
movq 0x1a4a5(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0xb0(%rbp), %rdi
movq %rax, %r9
leaq 0x1128c(%rip), %rsi     # 0x25dde
leaq 0x112e9(%rip), %rdx     # 0x25e42
leaq 0x10d06(%rip), %rcx     # 0x25866
movl $0x10a, %r8d            # imm = 0x10A
movb $0x0, %al
callq 0x3410
movq 0x1a42c(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
movq 0x1a44d(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
movl $0x1, %edi
callq 0x3370
jmp 0x14b97
movl $0x0, -0x74(%rbp)
cmpl $0x5, -0x74(%rbp)
jge 0x14c7c
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xb4(%rbp)
movslq -0x74(%rbp), %rsi
callq 0x3520
movl -0xb4(%rbp), %edi
movq %rax, %rsi
movl $0x1, %edx
callq 0x30e0
movq -0x98(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x75(%rbp), %rsi
movl $0x1, %edx
callq 0x3420
cmpq $0x1, %rax
je 0x14c6a
movq 0x1a3d0(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0xc0(%rbp), %rdi
movq %rax, %r9
leaq 0x11221(%rip), %rsi     # 0x25e48
leaq 0x11214(%rip), %rdx     # 0x25e42
leaq 0x10c31(%rip), %rcx     # 0x25866
movl $0x112, %r8d            # imm = 0x112
movb $0x0, %al
callq 0x3410
movq 0x1a357(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
movq 0x1a378(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
movl $0x1, %edi
callq 0x3370
jmp 0x14c6c
jmp 0x14c6e
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x14b9e
movq -0xa0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3520
movsbl (%rax), %eax
cmpl $-0x60, %eax
je 0x14cb0
movq -0xa0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3520
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x14dad
movq -0x98(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x76(%rbp), %rsi
movl $0x1, %edx
callq 0x3420
movl %eax, -0x7c(%rbp)
cmpl $0x1, -0x7c(%rbp)
jne 0x14d00
movq -0xa0(%rbp), %rdi
movsbl -0x76(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl $0x1, %esi
callq 0x3520
movq %rax, %rcx
movl -0xc4(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x14da9
movq 0x1a2c9(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0xa0(%rbp), %rdi
movq %rax, -0xd0(%rbp)
movsbl -0x76(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl $0x1, %esi
callq 0x3520
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %r9
movl -0xc8(%rbp), %r10d
movsbl (%rax), %eax
leaq 0x11175(%rip), %rsi     # 0x25ed3
leaq 0x110dd(%rip), %rdx     # 0x25e42
leaq 0x10afa(%rip), %rcx     # 0x25866
movl $0x11a, %r8d            # imm = 0x11A
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x3410
movq 0x1a218(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
movq 0x1a239(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
movl $0x1, %edi
callq 0x3370
jmp 0x14dab
jmp 0x14dbb
leaq 0x111b7(%rip), %rdi     # 0x25f6b
movb $0x0, %al
callq 0x3050
movq $0x5, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x70(%rbp), %rax
jae 0x14eba
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xdc(%rbp)
movq -0x88(%rbp), %rsi
callq 0x3520
movl -0xdc(%rbp), %edi
movq %rax, %rsi
movl $0x1, %edx
callq 0x30e0
movq -0x98(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x89(%rbp), %rsi
movl $0x1, %edx
callq 0x3420
cmpq $0x1, %rax
je 0x14e9f
movq 0x1a19b(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0xe8(%rbp), %rdi
movq %rax, %r9
leaq 0x10fec(%rip), %rsi     # 0x25e48
leaq 0x10fdf(%rip), %rdx     # 0x25e42
leaq 0x109fc(%rip), %rcx     # 0x25866
movl $0x122, %r8d            # imm = 0x122
movb $0x0, %al
callq 0x3410
movq 0x1a122(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
movq 0x1a143(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
movl $0x1, %edi
callq 0x3370
jmp 0x14ea1
jmp 0x14ea3
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x14dc6
movq -0x70(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x34b0