// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r15
movb 0x14c73(%rip), %al      # 0x1f470
testb %al, %al
je 0xa890
leaq 0x14c34(%rip), %rdi     # 0x1f440
movq %r13, %rsi
callq 0x13634
leaq 0x14c2d(%rip), %rcx     # 0x1f448
cmpq %rcx, %rax
je 0xa84c
movq 0x8(%r12), %rcx
testq %rcx, %rcx
je 0xa84c
movb 0x40(%rax), %sil
movq (%r12), %rax
xorl %edx, %edx
cmpb %sil, (%rax,%rdx)
je 0xa877
movsbq 0x1(%rax,%rdx), %rdi
addq %rdi, %rdx
addq $0x2, %rdx
cmpq %rcx, %rdx
jb 0xa834
leaq 0x10(%r15), %rax
movq %rax, (%r15)
leaq 0xdb58(%rip), %rdx      # 0x183b2
movq %r15, %rdi
movq %rdx, %rsi
callq 0x139ec
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbq 0x1(%rax,%rdx), %rax
addq $0x2, %rdx
movl %eax, %ecx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2270
jmp 0xa865
leaq 0x14bd9(%rip), %rdi     # 0x1f470
callq 0x2430
testl %eax, %eax
je 0xa805
leaq -0x36(%rbp), %rdx
movb $0x61, (%rdx)
leaq 0xe348(%rip), %rsi      # 0x18bfa
leaq -0x218(%rbp), %rbx
movq %rbx, %rdi
callq 0x13012
leaq -0x1f0(%rbp), %r14
leaq -0x35(%rbp), %rdx
movb $0x62, (%rdx)
leaq 0xe2f6(%rip), %rsi      # 0x18bcc
movq %r14, %rdi
callq 0x13054
leaq -0x1c8(%rbp), %r14
leaq -0x34(%rbp), %rdx
movb $0x4f, (%rdx)
leaq 0xe31c(%rip), %rsi      # 0x18c0f
movq %r14, %rdi
callq 0x13096
leaq -0x1a0(%rbp), %r14
leaq -0x33(%rbp), %rdx
movb $0x50, (%rdx)
leaq 0xe303(%rip), %rsi      # 0x18c13
movq %r14, %rdi
callq 0x130d8
leaq -0x178(%rbp), %r14
leaq -0x32(%rbp), %rdx
movb $-0x80, (%rdx)
leaq 0xe2bc(%rip), %rsi      # 0x18be9
movq %r14, %rdi
callq 0x1311a
leaq -0x150(%rbp), %r14
leaq -0x31(%rbp), %rdx
movb $-0x7f, (%rdx)
leaq 0xe2ce(%rip), %rsi      # 0x18c18
movq %r14, %rdi
callq 0x1315c
leaq -0x128(%rbp), %r14
leaq -0x30(%rbp), %rdx
movb $-0x7e, (%rdx)
leaq 0xe272(%rip), %rsi      # 0x18bd9
movq %r14, %rdi
callq 0x1319e
leaq -0x100(%rbp), %r14
leaq -0x2f(%rbp), %rdx
movb $-0x7d, (%rdx)
leaq 0xe2a6(%rip), %rsi      # 0x18c2a
movq %r14, %rdi
callq 0x1319e
leaq -0xd8(%rbp), %r14
leaq -0x2e(%rbp), %rdx
movb $-0x7b, (%rdx)
leaq 0xe299(%rip), %rsi      # 0x18c3a
movq %r14, %rdi
callq 0x131e0
leaq -0xb0(%rbp), %r14
leaq -0x2d(%rbp), %rdx
movb $-0x76, (%rdx)
leaq 0xe28a(%rip), %rsi      # 0x18c48
movq %r14, %rdi
callq 0x1315c
leaq -0x88(%rbp), %r14
leaq -0x2c(%rbp), %rdx
movb $-0x75, (%rdx)
leaq 0xe27f(%rip), %rsi      # 0x18c5a
movq %r14, %rdi
callq 0x13222
leaq -0x60(%rbp), %r14
leaq -0x2b(%rbp), %rdx
movb $-0x78, (%rdx)
leaq 0xe27d(%rip), %rsi      # 0x18c72
movq %r14, %rdi
callq 0x13096
leaq 0x14a3c(%rip), %rdi     # 0x1f440
leaq -0x218(%rbp), %rsi
leaq -0x2a(%rbp), %rcx
leaq -0x29(%rbp), %r8
movl $0xc, %edx
callq 0x13264
leaq -0x50(%rbp), %rbx
xorl %r14d, %r14d
movq -0x60(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xaa37
callq 0x2220
addq $-0x28, %r14
cmpq $-0x1e0, %r14           # imm = 0xFE20
jne 0xaa24
leaq 0x889d(%rip), %rdi      # 0x132e8
leaq 0x149ee(%rip), %rsi     # 0x1f440
leaq 0x147ef(%rip), %rdx     # 0x1f248
callq 0x2210
leaq 0x14a0b(%rip), %rdi     # 0x1f470
callq 0x2180
jmp 0xa805
movq %rax, %r15
movq $-0x1e0, %r12           # imm = 0xFE20
leaq -0x50(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0xaa8b
callq 0x2220
addq $-0x28, %r13
addq $0x28, %r12
jne 0xaa7d
movb $0x1, %al
jmp 0xaab2
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
jmp 0xaaad
movq %rax, %r15
xorl %eax, %eax
cmpq %r14, %rbx
sete %cl
testb %al, %al
jne 0xaadb
testb %cl, %cl
jne 0xaadb
movq -0x28(%r14), %rdi
leaq -0x18(%r14), %rax
cmpq %rdi, %rax
je 0xaad2
callq 0x2220
addq $-0x28, %r14
cmpq %rbx, %r14
jne 0xaac0
leaq 0x1498e(%rip), %rdi     # 0x1f470
callq 0x2170
movq %r15, %rdi
callq 0x2400
movq %rax, %r15
jmp 0xaadb