// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x1, (%rdi)
jne 0xb1d7
leaq 0x87b5(%rip), %rsi      # 0x13950
leaq -0x58(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x20f0
leaq -0x78(%rbp), %rdi
movq %rbx, %rsi
callq 0x2330
leaq -0x58(%rbp), %r15
leaq -0x78(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x7a66
movq %r12, %rdi
callq 0x2120
movq %r15, %rdi
callq 0x2120
movq 0x8(%rbx), %rax
movq %rax, -0x38(%rbp)
cmpq $0x5, %rax
jb 0xb3b8
xorl %r15d, %r15d
pushq $0x1
popq %r12
leaq -0x29(%rbp), %r13
cmpq $0x5, %r15
je 0xb22a
movl 0x4(%r14), %edi
movq (%rbx), %rsi
addq %r15, %rsi
movq %r12, %rdx
callq 0x20d0
movl 0x4(%r14), %edi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2370
cmpq $0x1, %rax
jne 0xb325
incq %r15
jmp 0xb1f4
movq (%rbx), %rax
movzbl (%rax), %eax
testl %eax, %eax
je 0xb23f
cmpl $0xa0, %eax
jne 0xb2c8
movl 0x4(%r14), %edi
leaq -0x29(%rbp), %r12
pushq $0x1
popq %rdx
movq %r12, %rsi
callq 0x2370
movsbl (%r12), %r12d
cmpl $0x1, %eax
jne 0xb265
movq (%rbx), %rax
cmpb 0x1(%rax), %r12b
je 0xb2d4
movq 0xdd64(%rip), %r15      # 0x18fd0
movq (%r15), %r14
callq 0x2040
movl (%rax), %edi
callq 0x20c0
movq (%rbx), %rcx
movsbl 0x1(%rcx), %r10d
leaq 0x87c3(%rip), %rsi      # 0x13a4d
leaq 0x872b(%rip), %rdx      # 0x139bc
leaq 0x81f4(%rip), %rcx      # 0x1348c
movq %r14, %rdi
movl $0x11a, %r8d            # imm = 0x11A
movq %rax, %r9
xorl %eax, %eax
pushq %r10
pushq %r12
callq 0x2360
popq %rcx
popq %rdx
movq 0xdcf0(%rip), %rax      # 0x18fa8
movq (%rax), %rdi
callq 0x22c0
movq (%r15), %rdi
jmp 0xb3ab
leaq 0x8d15(%rip), %rdi      # 0x13fe4
callq 0x23c0
pushq $0x5
popq %r15
pushq $0x1
popq %r12
leaq -0x29(%rbp), %r13
cmpq -0x38(%rbp), %r15
jae 0xb312
movl 0x4(%r14), %edi
movq (%rbx), %rsi
addq %r15, %rsi
movq %r12, %rdx
callq 0x20d0
movl 0x4(%r14), %edi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2370
cmpq $0x1, %rax
jne 0xb35b
incq %r15
jmp 0xb2e0
movq -0x38(%rbp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xdca4(%rip), %r14      # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
leaq 0x8680(%rip), %rsi      # 0x139c2
leaq 0x8673(%rip), %rdx      # 0x139bc
leaq 0x813c(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x112, %r8d            # imm = 0x112
jmp 0xb38f
movq 0xdc6e(%rip), %r14      # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
leaq 0x864a(%rip), %rsi      # 0x139c2
leaq 0x863d(%rip), %rdx      # 0x139bc
leaq 0x8106(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x122, %r8d            # imm = 0x122
movq %rax, %r9
xorl %eax, %eax
callq 0x2360
movq 0xdc08(%rip), %rax      # 0x18fa8
movq (%rax), %rdi
callq 0x22c0
movq (%r14), %rdi
callq 0x22c0
pushq $0x1
popq %rdi
callq 0x22e0
movq 0xdc11(%rip), %r14      # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
leaq 0x8583(%rip), %rsi      # 0x13958
leaq 0x85e0(%rip), %rdx      # 0x139bc
leaq 0x80a9(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x10a, %r8d            # imm = 0x10A
jmp 0xb38f
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x2400