// File: 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
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x20(%rbp), %rdi
callq 0xec50
leaq -0x59(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x34d0
movq -0x1d8(%rbp), %rdx
leaq 0x156a3(%rip), %rsi     # 0x25b84
leaq -0x58(%rbp), %rdi
callq 0x33e0
jmp 0x104ec
movq -0x1e0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0xf8b0
jmp 0x10502
leaq -0x20(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
leaq -0x38(%rbp), %rsi
movq %rsi, -0x1f0(%rbp)
callq 0x10470
movq -0x1f0(%rbp), %rdi
callq 0xf6b0
leaq -0x58(%rbp), %rdi
callq 0x31a0
leaq -0x59(%rbp), %rdi
callq 0x3300
movq -0x1e8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf690
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x3120
jmp 0x1055c
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x34d0
movq -0x1f8(%rbp), %rdx
leaq 0x15b6a(%rip), %rsi     # 0x260e7
leaq -0xd0(%rbp), %rdi
callq 0x33e0
jmp 0x1058b
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0xe260
jmp 0x105a7
leaq -0xd0(%rbp), %rdi
callq 0x31a0
leaq -0xd1(%rbp), %rdi
callq 0x3300
leaq -0xb0(%rbp), %rdi
callq 0x31a0
leaq -0x118(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3120
jmp 0x105e0
leaq -0x139(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x34d0
movq -0x200(%rbp), %rdx
leaq 0x15afb(%rip), %rsi     # 0x260fc
leaq -0x138(%rbp), %rdi
callq 0x33e0
jmp 0x1060f
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq -0x138(%rbp), %rdx
callq 0xe260
jmp 0x1062b
leaq -0x138(%rbp), %rdi
callq 0x31a0
leaq -0x139(%rbp), %rdi
callq 0x3300
leaq -0x118(%rbp), %rdi
callq 0x31a0
leaq -0x161(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x34d0
movq -0x208(%rbp), %rcx
leaq 0x12c58(%rip), %rsi     # 0x232c8
leaq -0x160(%rbp), %rdi
movl $0x4, %edx
callq 0x3330
jmp 0x10683
leaq -0x161(%rbp), %rdi
callq 0x3300
leaq -0xf8(%rbp), %rdi
callq 0x31f0
movsbl %al, %esi
leaq -0x160(%rbp), %rdi
callq 0x31b0
jmp 0x106ac
leaq -0x160(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x33b0
jmp 0x106c1
leaq -0x189(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x34d0
movq -0x210(%rbp), %rcx
leaq 0x12b83(%rip), %rsi     # 0x23265
leaq -0x188(%rbp), %rdi
movl $0x2, %edx
callq 0x3330
jmp 0x106f5
leaq -0x189(%rbp), %rdi
callq 0x3300
leaq -0x1b0(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x3120
jmp 0x10716
leaq -0x1d0(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x3120
jmp 0x1072b
movq -0x1e0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x14f60
movb %al, -0x211(%rbp)
jmp 0x1074d
leaq -0x1d0(%rbp), %rdi
callq 0x31a0
leaq -0x1b0(%rbp), %rdi
callq 0x31a0
leaq -0x188(%rbp), %rdi
callq 0x31a0
leaq -0x160(%rbp), %rdi
callq 0x31a0
leaq -0xf8(%rbp), %rdi
callq 0x31a0
leaq -0x90(%rbp), %rdi
callq 0x31a0
leaq -0x20(%rbp), %rdi
callq 0xf6b0
movb -0x211(%rbp), %al
andb $0x1, %al
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x107d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x31a0
leaq -0x59(%rbp), %rdi
callq 0x3300
jmp 0x1093d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1093d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x10817
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x31a0
leaq -0xd1(%rbp), %rdi
callq 0x3300
leaq -0xb0(%rbp), %rdi
callq 0x31a0
jmp 0x1093d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x10931
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1086b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x31a0
leaq -0x139(%rbp), %rdi
callq 0x3300
leaq -0x118(%rbp), %rdi
callq 0x31a0
jmp 0x10931
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x161(%rbp), %rdi
callq 0x3300
jmp 0x10925
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x10919
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x189(%rbp), %rdi
callq 0x3300
jmp 0x10919
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1090d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x10901
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x31a0
leaq -0x1b0(%rbp), %rdi
callq 0x31a0
leaq -0x188(%rbp), %rdi
callq 0x31a0
leaq -0x160(%rbp), %rdi
callq 0x31a0
leaq -0xf8(%rbp), %rdi
callq 0x31a0
leaq -0x90(%rbp), %rdi
callq 0x31a0
leaq -0x20(%rbp), %rdi
callq 0xf6b0
movq -0x68(%rbp), %rdi
callq 0x34b0
nop