// File: FFY00[P]uicc/include/uicc.h
// Function: extractTLV(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
static inline string extractTLV(string in, string TLVname) {
    static const map<string,char> Tags= {
        {"Application Template", '\x61'},
        {"FCP Template", '\x62'},
        {"AID", '\x4f'},
        {"Card", '\x50' },
        {"File Size - Data", '\x80'},
        {"File Size - Total", '\x81'},
        {"File Descriptor", '\x82'},
        {"File Identifier", '\x83'},
        {"DF Name (AID)", '\x85'},
        {"Life Cycle Status", '\x8a'},
        {"Security attribute data", '\x8b'},
        {"SFI", '\x88'},
    };
    auto it=Tags.find(TLVname);

    if (it != Tags.end()) {
        char tag=it->second;
        size_t index=0;

        while (index < in.size()) {
            if (in[index]==tag)
                return in.substr(index+2, (unsigned)in[index+1]);

            index+=in[index+1]+2;
        }
    }

    return "";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdx, -0x280(%rbp)
movq %rsi, -0x278(%rbp)
movq %rdi, -0x270(%rbp)
movq %rdi, %rax
movq %rax, -0x268(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpb $0x0, 0x21233(%rip)     # 0x2f4d0
jne 0xe572
leaq 0x21226(%rip), %rdi     # 0x2f4d0
callq 0x34e0
cmpl $0x0, %eax
je 0xe572
leaq -0x208(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $0x61, -0x211(%rbp)
leaq 0x17e13(%rip), %rsi     # 0x260e7
leaq -0x211(%rbp), %rdx
callq 0x1d410
jmp 0xe2e2
leaq -0x1e0(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $0x62, -0x225(%rbp)
leaq 0x17dbb(%rip), %rsi     # 0x260b9
leaq -0x225(%rbp), %rdx
callq 0x1d490
jmp 0xe30c
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $0x4f, -0x226(%rbp)
leaq 0x17dd4(%rip), %rsi     # 0x260fc
leaq -0x226(%rbp), %rdx
callq 0x1d510
jmp 0xe336
leaq -0x190(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $0x50, -0x227(%rbp)
leaq 0x17dae(%rip), %rsi     # 0x26100
leaq -0x227(%rbp), %rdx
callq 0x1d590
jmp 0xe360
leaq -0x168(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x80, -0x228(%rbp)
leaq 0x17d5a(%rip), %rsi     # 0x260d6
leaq -0x228(%rbp), %rdx
callq 0x1d610
jmp 0xe38a
leaq -0x140(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x7f, -0x229(%rbp)
leaq 0x17d5f(%rip), %rsi     # 0x26105
leaq -0x229(%rbp), %rdx
callq 0x1d690
jmp 0xe3b4
leaq -0x118(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x7e, -0x22a(%rbp)
leaq 0x17cf6(%rip), %rsi     # 0x260c6
leaq -0x22a(%rbp), %rdx
callq 0x1d710
jmp 0xe3de
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x7d, -0x22b(%rbp)
leaq 0x17d1d(%rip), %rsi     # 0x26117
leaq -0x22b(%rbp), %rdx
callq 0x1d710
jmp 0xe408
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x7b, -0x22c(%rbp)
leaq 0x17d03(%rip), %rsi     # 0x26127
leaq -0x22c(%rbp), %rdx
callq 0x1d790
jmp 0xe432
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x76, -0x22d(%rbp)
leaq 0x17ce7(%rip), %rsi     # 0x26135
leaq -0x22d(%rbp), %rdx
callq 0x1d690
jmp 0xe45c
leaq -0x78(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x75, -0x22e(%rbp)
leaq 0x17cd2(%rip), %rsi     # 0x26147
leaq -0x22e(%rbp), %rdx
callq 0x1d810
jmp 0xe483
leaq -0x50(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movb $-0x78, -0x22f(%rbp)
leaq 0x17cc3(%rip), %rsi     # 0x2615f
leaq -0x22f(%rbp), %rdx
callq 0x1d510
jmp 0xe4aa
leaq -0x208(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0xc, -0x20(%rbp)
leaq -0x231(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0x1d8b0
movq -0x288(%rbp), %r8
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq 0x20fba(%rip), %rdi     # 0x2f4a0
leaq -0x230(%rbp), %rcx
callq 0x1d8d0
jmp 0xe4f4
leaq -0x231(%rbp), %rdi
callq 0x1d9a0
leaq -0x208(%rbp), %rax
movq %rax, -0x298(%rbp)
addq $0x1e0, %rax            # imm = 0x1E0
movq %rax, -0x290(%rbp)
movq -0x290(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x1d890
movq -0x298(%rbp), %rcx
movq -0x2a0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x290(%rbp)
jne 0xe51b
leaq 0xf46d(%rip), %rdi      # 0x1d9c0
leaq 0x20f46(%rip), %rsi     # 0x2f4a0
leaq 0x20d47(%rip), %rdx     # 0x2f2a8
callq 0x3250
leaq 0x20f63(%rip), %rdi     # 0x2f4d0
callq 0x31d0
movq -0x280(%rbp), %rsi
leaq 0x20f20(%rip), %rdi     # 0x2f4a0
callq 0x1d9e0
movq %rax, -0x240(%rbp)
leaq 0x20f0d(%rip), %rdi     # 0x2f4a0
callq 0x1da40
movq %rax, -0x248(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x1da10
testb $0x1, %al
jne 0xe5bb
jmp 0xe78c
leaq -0x240(%rbp), %rdi
callq 0x1da70
movb 0x20(%rax), %al
movb %al, -0x249(%rbp)
movq $0x0, -0x258(%rbp)
movq -0x278(%rbp), %rdi
movq -0x258(%rbp), %rax
movq %rax, -0x2a8(%rbp)
callq 0x31f0
movq %rax, %rcx
movq -0x2a8(%rbp), %rax
cmpq %rcx, %rax
jae 0xe78a
movq -0x278(%rbp), %rdi
movq -0x258(%rbp), %rsi
callq 0x3520
movsbl (%rax), %eax
movsbl -0x249(%rbp), %ecx
cmpl %ecx, %eax
jne 0xe758
movq -0x278(%rbp), %rdi
movq -0x258(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x2b0(%rbp)
movq -0x258(%rbp), %rsi
addq $0x1, %rsi
callq 0x3520
movq -0x270(%rbp), %rdi
movq -0x278(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
movsbl (%rax), %eax
movl %eax, %eax
movl %eax, %ecx
callq 0x32c0
jmp 0xe7e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
movq -0x210(%rbp), %rax
leaq -0x208(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x2b8(%rbp)
je 0xe6d9
movq -0x2b8(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x1d890
movq -0x2c0(%rbp), %rax
leaq -0x208(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x2b8(%rbp)
jne 0xe6a8
jmp 0xe747
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x231(%rbp), %rdi
callq 0x1d9a0
leaq -0x208(%rbp), %rax
movq %rax, -0x2d0(%rbp)
addq $0x1e0, %rax            # imm = 0x1E0
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x1d890
movq -0x2d0(%rbp), %rcx
movq -0x2d8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2c8(%rbp)
jne 0xe714
jmp 0xe747
leaq 0x20d82(%rip), %rdi     # 0x2f4d0
callq 0x31c0
jmp 0xe7f9
movq -0x278(%rbp), %rdi
movq -0x258(%rbp), %rsi
addq $0x1, %rsi
callq 0x3520
movsbl (%rax), %eax
addl $0x2, %eax
cltq
addq -0x258(%rbp), %rax
movq %rax, -0x258(%rbp)
jmp 0xe5db
jmp 0xe78c
leaq -0x259(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x34d0
movq -0x270(%rbp), %rdi
movq -0x2e0(%rbp), %rdx
leaq 0x174b0(%rip), %rsi     # 0x25c64
callq 0x33e0
jmp 0xe7bb
leaq -0x259(%rbp), %rdi
callq 0x3300
jmp 0xe7e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x259(%rbp), %rdi
callq 0x3300
jmp 0xe7f9
movq -0x268(%rbp), %rax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x220(%rbp), %rdi
callq 0x34b0
nopw %cs:(%rax,%rax)