// File: /workspace/github_cpp_makefile_star2_O1/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 0xcf22(%rip), %rsi      # 0x1879c
leaq 0xcf20(%rip), %rdx      # 0x187a1
leaq -0x1a0(%rbp), %rdi
callq 0x137c4
leaq -0x60(%rbp), %rdi
leaq -0x1a0(%rbp), %rdx
movq %rbx, %rsi
callq 0xb168
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %rdi
movaps %xmm0, (%rdi)
movaps -0x40(%rbp), %xmm0
movq -0x30(%rbp), %rax
leaq -0x60(%rbp), %r14
movups (%r14), %xmm1
movaps %xmm1, -0x40(%rbp)
movq 0x10(%r14), %rcx
movq %rcx, -0x30(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%r14)
movq $0x0, 0x10(%r14)
callq 0xafd4
movq %r14, %rdi
callq 0xafd4
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
je 0xb8fd
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 0x1372a
leaq -0x150(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xd2c6(%rip), %rsi      # 0x18bfa
leaq 0xd2d3(%rip), %rdx      # 0x18c0e
leaq -0x160(%rbp), %rdi
callq 0x137c4
leaq -0xa0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
leaq -0x160(%rbp), %rdx
callq 0xa4e9
movq -0x160(%rbp), %rdi
cmpq %r15, %rdi
je 0xb972
callq 0x2220
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
je 0xb983
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 0x1372a
leaq -0x110(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xd252(%rip), %rsi      # 0x18c0f
leaq 0xd24e(%rip), %rdx      # 0x18c12
leaq -0x120(%rbp), %rdi
callq 0x137c4
leaq -0x60(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0xa4e9
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0xb9f8
callq 0x2220
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
je 0xba09
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 0x1372a
leaq -0xb0(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x1372a
leaq -0xe0(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
movq %rbx, %rdi
callq 0xe8a6
movl %eax, %ebx
movq -0xc0(%rbp), %rdi
cmpq %r13, %rdi
je 0xbad5
callq 0x2220
movq -0xe0(%rbp), %rdi
cmpq %r12, %rdi
je 0xbae6
callq 0x2220
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0xbaf7
callq 0x2220
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xbb05
callq 0x2220
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbb17
callq 0x2220
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbb2c
callq 0x2220
leaq -0x40(%rbp), %rdi
callq 0xafd4
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 0xbb62
callq 0x2220
jmp 0xbb62
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r12, %rdi
je 0xbb78
callq 0x2220
jmp 0xbb78
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0xbbf9
callq 0x2220
jmp 0xbbf9
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0xbba4
callq 0x2220
jmp 0xbba4
movq %rax, %rbx
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
jne 0xbc14
jmp 0xbc19
movq %rax, %rbx
jmp 0xbc19
movq %rax, %rbx
movq -0x160(%rbp), %rdi
cmpq %r15, %rdi
je 0xbbd0
callq 0x2220
jmp 0xbbd0
movq %rax, %rbx
movq -0x180(%rbp), %rdi
cmpq %r14, %rdi
jne 0xbc29
jmp 0xbc2e
jmp 0xbbf1
movq %rax, %rbx
movq -0x1a0(%rbp), %rdi
cmpq %r15, %rdi
jne 0xbc29
jmp 0xbc2e
movq %rax, %rbx
jmp 0xbc2e
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0xbc07
callq 0x2220
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbc19
callq 0x2220
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbc2e
callq 0x2220
leaq -0x40(%rbp), %rdi
callq 0xafd4
movq %rbx, %rdi
callq 0x2400
nop