// File: /workspace/github_cpp_makefile_star2_O2/FFY00[P]uicc/include/uicc.h
// Function: UICC::open[abi:cxx11](char*)
string open(char *portname) {
        Assert( (fd=::open(portname, O_RDWR | O_NOCTTY | O_SYNC)) >=0,
                "Failed to open %s", portname);
        struct termios tty;
        Assert (tcgetattr(fd, &tty) >= 0, "");
        tty.c_cflag &= ~( CSIZE );
        tty.c_cflag |= CLOCAL | CREAD | CS8 | PARENB | CSTOPB | HUPCL ;
        /* setup for non-canonical mode */
        tty.c_iflag &= ~(IGNBRK | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
        tty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
        tty.c_oflag &= ~OPOST;
        /* fetch bytes as they become available */
        tty.c_cc[VMIN] = 0;
        tty.c_cc[VTIME] = 1;
        cfsetispeed(&tty, (speed_t)B9600);
        cfsetospeed(&tty, (speed_t)B9600);
        Assert (tcsetattr(fd, TCSANOW, &tty) == 0,"");
        // reset the UICC
        int iFlags;
        iFlags = 0 ;
        // turn off DTR
        ioctl(fd, TIOCMSET, &iFlags);
        struct timespec t= {0,1000*1000*100};
        nanosleep(&t,NULL);
        iFlags = 0xFFFF;
        // turn on DTR
        //iFlags = TIOCM_CTS  ;
        //ioctl(fd, TIOCMSET, &iFlags);
        return this->read();
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rdx, %rdi
movl $0x101102, %esi         # imm = 0x101102
xorl %eax, %eax
callq 0x21b0
movl %eax, 0x4(%r14)
testl %eax, %eax
js 0x84a2
leaq -0x7c(%rbp), %rsi
movl %eax, %edi
callq 0x22a0
testl %eax, %eax
js 0x84dc
leaq -0x7c(%rbp), %r15
orl $0xdf0, 0x8(%r15)       # imm = 0xDF0
andl $0xfffffa16, (%r15)     # imm = 0xFFFFFA16
andl $0xffff7fb4, 0xc(%r15)  # imm = 0xFFFF7FB4
andb $-0x2, 0x4(%r15)
movw $0x1, 0x16(%r15)
pushq $0xd
popq %r12
movq %r15, %rdi
movl %r12d, %esi
callq 0x2160
movq %r15, %rdi
movl %r12d, %esi
callq 0x2290
movl 0x4(%r14), %edi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2310
testl %eax, %eax
jne 0x8512
leaq -0x24(%rbp), %r15
andl $0x0, (%r15)
movl 0x4(%r14), %edi
movl $0x5418, %esi           # imm = 0x5418
movq %r15, %rdx
xorl %eax, %eax
callq 0x2350
movups 0xbbc3(%rip), %xmm0     # 0x14030
leaq -0x40(%rbp), %rdi
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x20b0
movl $0xffff, (%r15)         # imm = 0xFFFF
movl $0x400, %edx            # imm = 0x400
movq %rbx, %rdi
movq %r14, %rsi
callq 0xac6e
movq %rbx, %rax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x10b27(%rip), %r14     # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
movq %r15, (%rsp)
leaq 0xaf23(%rip), %rsi      # 0x133e6
leaq 0xafbd(%rip), %rdx      # 0x13487
leaq 0xafbb(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x12b, %r8d            # imm = 0x12B
jmp 0x8546
movq 0x10aed(%rip), %r14     # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
leaq 0xafa2(%rip), %rsi      # 0x1349b
leaq 0xaf87(%rip), %rdx      # 0x13487
leaq 0xaf85(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x12d, %r8d            # imm = 0x12D
jmp 0x8546
movq 0x10ab7(%rip), %r14     # 0x18fd0
movq (%r14), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x20c0
leaq 0xafdf(%rip), %rsi      # 0x1350e
leaq 0xaf51(%rip), %rdx      # 0x13487
leaq 0xaf4f(%rip), %rcx      # 0x1348c
movq %rbx, %rdi
movl $0x139, %r8d            # imm = 0x139
movq %rax, %r9
xorl %eax, %eax
callq 0x2360
movq 0x10a51(%rip), %rax     # 0x18fa8
movq (%rax), %rdi
callq 0x22c0
movq (%r14), %rdi
callq 0x22c0
pushq $0x1
popq %rdi
callq 0x22e0
nop