// File: /workspace/github_cpp_makefile_star2_O1/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 0xe775
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xa28f(%rip), %rsi      # 0x18970
leaq 0xa28f(%rip), %rdx      # 0x18977
leaq -0x58(%rbp), %rdi
callq 0x137c4
leaq -0x68(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %rdi
callq 0x1372a
movq -0x58(%rbp), %rsi
leaq 0xa6c1(%rip), %rdi      # 0x18dd8
xorl %eax, %eax
callq 0x2060
cmpq $0x0, -0x70(%rbp)
je 0xe74b
leaq 0x984e(%rip), %r15      # 0x17f7a
xorl %r12d, %r12d
movq -0x78(%rbp), %rax
movsbl (%rax,%r12), %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2060
incq %r12
cmpq -0x70(%rbp), %r12
jb 0xe72f
movl $0xa, %edi
callq 0x2340
movq -0x78(%rbp), %rdi
cmpq %r13, %rdi
je 0xe763
callq 0x2220
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xe775
callq 0x2220
movq 0x8(%rbx), %r15
cmpq $0x5, %r15
jb 0xe883
xorl %r13d, %r13d
leaq -0x29(%rbp), %r12
movl 0x4(%r14), %edi
movq (%rbx), %rsi
addq %r13, %rsi
movl $0x1, %edx
callq 0x20f0
movl 0x4(%r14), %edi
movl $0x1, %edx
movq %r12, %rsi
callq 0x2370
cmpq $0x1, %rax
jne 0xe879
incq %r13
cmpq $0x5, %r13
jne 0xe78a
movq (%rbx), %rax
movzbl (%rax), %eax
testl %eax, %eax
je 0xe7d3
cmpl $0xa0, %eax
jne 0xe801
movl 0x4(%r14), %edi
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x2370
cmpl $0x1, %eax
jne 0xe7f5
movb -0x29(%rbp), %al
movq (%rbx), %rcx
cmpb 0x1(%rcx), %al
je 0xe80d
leaq -0x29(%rbp), %rdi
movq %rbx, %rsi
callq 0x3bfe
leaq 0xa7fc(%rip), %rdi      # 0x19004
callq 0x23c0
movq %r15, -0x38(%rbp)
cmpq $0x5, %r15
je 0xe866
movq -0x38(%rbp), %rax
cmpq $0x7, %rax
movl $0x6, %r13d
cmovaeq %rax, %r13
movl $0x5, %r15d
leaq -0x29(%rbp), %r12
movl 0x4(%r14), %edi
movq (%rbx), %rsi
addq %r15, %rsi
movl $0x1, %edx
callq 0x20f0
movl 0x4(%r14), %edi
movl $0x1, %edx
movq %r12, %rsi
callq 0x2370
cmpq $0x1, %rax
jne 0xe87e
incq %r15
cmpq %r15, %r13
jne 0xe833
movq -0x38(%rbp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3b9a
callq 0x3c80
callq 0x3b36
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xe89d
callq 0x2220
movq %rbx, %rdi
callq 0x2400
nop