// File: FFY00[P]uicc/include/uicc.h
// Function: UICC::read[abi:cxx11](unsigned long)
string read(size_t s = 1024) {
        size_t got=0;
        string data="";

        while (got < s) {
            int ret;
            char buf;
            Assert( (ret=::read(fd, &buf, 1)) >= 0, "Error from read");

            switch (ret) {
            case 1:
                got++;
                data+=buf;
                break;

            case 0: // for time out: no more data
                if (debug)
                    dump_hex("Received", data);

                return data;
                break;

            default:
                fprintf(stderr,"Error from read > 1 char\n");
            }
        }

        if (debug)
            dump_hex("Received", data);

        return data;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0xe8(%rbp)
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq $0x0, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
leaq -0x22(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x34d0
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x11c30(%rip), %rsi     # 0x25c64
callq 0x33e0
jmp 0x1403b
leaq -0x22(%rbp), %rdi
callq 0x3300
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x14269
jmp 0x14054
movq -0xf0(%rbp), %rax
movl 0x4(%rax), %edi
leaq -0x39(%rbp), %rsi
movl $0x1, %edx
callq 0x3420
movq %rax, -0x100(%rbp)
jmp 0x14075
movq -0x100(%rbp), %rax
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
jge 0x14128
movq 0x1af41(%rip), %rax     # 0x2efd0
movq (%rax), %rax
movq %rax, -0x108(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x30d0
movq -0x108(%rbp), %rdi
movq %rax, %r9
leaq 0x118ae(%rip), %rsi     # 0x25964
leaq 0x1192f(%rip), %rdx     # 0x259ec
leaq 0x117a2(%rip), %rcx     # 0x25866
xorl %eax, %eax
movl $0xeb, %r8d
callq 0x3410
movq 0x1aec8(%rip), %rax     # 0x2efa0
movq (%rax), %rdi
callq 0x3350
jmp 0x140e2
movq 0x1aee7(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3350
jmp 0x140f3
movl $0x1, %edi
callq 0x3370
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x22(%rbp), %rdi
callq 0x3300
jmp 0x14382
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x14376
jmp 0x1412a
jmp 0x1412c
movl -0x38(%rbp), %eax
movl %eax, -0x10c(%rbp)
testl %eax, %eax
je 0x1416e
jmp 0x1413b
movl -0x10c(%rbp), %eax
subl $0x1, %eax
jne 0x1424c
jmp 0x1414c
movq -0xe8(%rbp), %rdi
movq -0x20(%rbp), %rax
incq %rax
movq %rax, -0x20(%rbp)
movsbl -0x39(%rbp), %esi
callq 0x31b0
jmp 0x14169
jmp 0x14264
movq -0xf0(%rbp), %rax
testb $0x1, (%rax)
je 0x14239
leaq -0x61(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x34d0
movq -0x118(%rbp), %rdx
leaq 0x11855(%rip), %rsi     # 0x259f1
leaq -0x60(%rbp), %rdi
callq 0x33e0
jmp 0x141a7
movq -0xe8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x3120
jmp 0x141bc
leaq -0x60(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0xd1b0
jmp 0x141ce
leaq -0x88(%rbp), %rdi
callq 0x31a0
leaq -0x60(%rbp), %rdi
callq 0x31a0
leaq -0x61(%rbp), %rdi
callq 0x3300
jmp 0x14239
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1422b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x14222
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31a0
leaq -0x60(%rbp), %rdi
callq 0x31a0
leaq -0x61(%rbp), %rdi
callq 0x3300
jmp 0x14376
movb $0x1, -0x21(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x14354
movq 0x1ad7d(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
leaq 0x1179d(%rip), %rsi     # 0x259fa
movb $0x0, %al
callq 0x3410
jmp 0x14044
movq -0xf0(%rbp), %rax
testb $0x1, (%rax)
je 0x14346
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x34d0
movq -0x120(%rbp), %rdx
leaq 0x11757(%rip), %rsi     # 0x259f1
leaq -0xb0(%rbp), %rdi
callq 0x33e0
jmp 0x142a8
movq -0xe8(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x3120
jmp 0x142bd
leaq -0xb0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xd1b0
jmp 0x142d2
leaq -0xd8(%rbp), %rdi
callq 0x31a0
leaq -0xb0(%rbp), %rdi
callq 0x31a0
leaq -0xb1(%rbp), %rdi
callq 0x3300
jmp 0x14346
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x14338
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1432c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x31a0
leaq -0xb0(%rbp), %rdi
callq 0x31a0
leaq -0xb1(%rbp), %rdi
callq 0x3300
jmp 0x14376
movb $0x1, -0x21(%rbp)
movl $0x1, -0x8c(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x14366
movq -0xe8(%rbp), %rdi
callq 0x31a0
movq -0xf8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0xe8(%rbp), %rdi
callq 0x31a0
movq -0x30(%rbp), %rdi
callq 0x34b0
nopl (%rax,%rax)