// File: /workspace/github_cpp_makefile_star2_O3/FFY00[P]uicc/include/uicc.h
// Function: USIM::openUSIM()
bool openUSIM() {
        vector<string> res;
        // Read card description
        res=readFile("EFDIR");
        string Appli=extractTLV(res[0], "Application Template");
        string AID=extractTLV(Appli, "AID");
        //Instead of first AID, we should look for AID starting by: a000000087 (3GPP) 1002 (USIM)
        //dump_hex("AID", AID);
        //printf("card supplier id: %s\n", extractTLV(Appli, "Card").c_str());
        string order(u8"\x00\xa4\x04\x0c",4);
        order+=(char)AID.size();
        order+=AID;
        string answer (u8"\x90\x00",2);
        return send_check(order, answer);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x190(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xcc60(%rip), %rsi      # 0x1879c
leaq 0xcc5e(%rip), %rdx      # 0x187a1
leaq -0x1a0(%rbp), %rdi
callq 0x139ec
leaq -0x60(%rbp), %rdi
leaq -0x1a0(%rbp), %rdx
movq %rbx, %rsi
callq 0xb46e
movaps -0x40(%rbp), %xmm0
movq -0x30(%rbp), %rax
leaq -0x60(%rbp), %r14
movaps (%r14), %xmm1
movaps %xmm1, -0x40(%rbp)
movq 0x10(%r14), %rcx
movq %rcx, -0x30(%rbp)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
callq 0xb2cc
movq %r14, %rdi
callq 0xb2cc
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
je 0xbbb9
callq 0x2220
movq -0x40(%rbp), %rax
leaq -0x170(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x180(%rbp), %rdi
callq 0x1394e
leaq -0x150(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xd00a(%rip), %rsi      # 0x18bfa
leaq 0xd017(%rip), %rdx      # 0x18c0e
leaq -0x160(%rbp), %rdi
callq 0x139ec
leaq -0xa0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
leaq -0x160(%rbp), %rdx
callq 0xa7da
movq -0x160(%rbp), %rdi
cmpq %r15, %rdi
je 0xbc2e
callq 0x2220
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
je 0xbc3f
callq 0x2220
leaq -0x130(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %rdi
callq 0x1394e
leaq -0x110(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xcf96(%rip), %rsi      # 0x18c0f
leaq 0xcf92(%rip), %rdx      # 0x18c12
leaq -0x120(%rbp), %rdi
callq 0x139ec
leaq -0x60(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0xa7da
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0xbcb4
callq 0x2220
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
je 0xbcc5
callq 0x2220
leaq -0x70(%rbp), %r14
movq %r14, -0x10(%r14)
movl $0xc04a400, (%r14)      # imm = 0xC04A400
movq $0x4, -0x8(%r14)
movb $0x0, 0x4(%r14)
movsbl -0x58(%rbp), %esi
leaq -0x80(%rbp), %rdi
callq 0x2200
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x20d0
leaq -0xf0(%rbp), %r15
movq %r15, -0x10(%r15)
movw $0x90, (%r15)
movq $0x2, -0x8(%r15)
movb $0x0, 0x2(%r15)
leaq -0xd0(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rdi
callq 0x1394e
leaq -0xb0(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x1394e
leaq -0xe0(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
movq %rbx, %rdi
callq 0xeb32
movl %eax, %ebx
movq -0xc0(%rbp), %rdi
cmpq %r13, %rdi
je 0xbd91
callq 0x2220
movq -0xe0(%rbp), %rdi
cmpq %r12, %rdi
je 0xbda2
callq 0x2220
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0xbdb3
callq 0x2220
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xbdc1
callq 0x2220
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbdd3
callq 0x2220
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbde8
callq 0x2220
leaq -0x40(%rbp), %rdi
callq 0xb2cc
movl %ebx, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r13, %rdi
je 0xbe1e
callq 0x2220
jmp 0xbe1e
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r12, %rdi
je 0xbe34
callq 0x2220
jmp 0xbe34
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0xbeb5
callq 0x2220
jmp 0xbeb5
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0xbe60
callq 0x2220
jmp 0xbe60
movq %rax, %rbx
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
jne 0xbed0
jmp 0xbed5
movq %rax, %rbx
jmp 0xbed5
movq %rax, %rbx
movq -0x160(%rbp), %rdi
cmpq %r15, %rdi
je 0xbe8c
callq 0x2220
jmp 0xbe8c
movq %rax, %rbx
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
jne 0xbee5
jmp 0xbeea
jmp 0xbead
movq %rax, %rbx
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
jne 0xbee5
jmp 0xbeea
movq %rax, %rbx
jmp 0xbeea
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xbec3
callq 0x2220
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbed5
callq 0x2220
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbeea
callq 0x2220
leaq -0x40(%rbp), %rdi
callq 0xb2cc
movq %rbx, %rdi
callq 0x2400
nop