// File: /workspace/github_cpp_makefile_star2_O1/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 0x14f64(%rip), %al      # 0x1f470
testb %al, %al
je 0xa5a2
leaq 0x14f25(%rip), %rdi     # 0x1f440
movq %r13, %rsi
callq 0x13410
leaq 0x14f1e(%rip), %rcx     # 0x1f448
cmpq %rcx, %rax
je 0xa55b
movq 0x8(%r12), %rcx
testq %rcx, %rcx
je 0xa55b
movb 0x40(%rax), %sil
movq (%r12), %rax
xorl %edx, %edx
cmpb %sil, (%rax,%rdx)
je 0xa589
movsbq 0x1(%rax,%rdx), %rdi
addq %rdi, %rdx
addq $0x2, %rdx
cmpq %rcx, %rdx
jb 0xa543
leaq 0x10(%r15), %rax
movq %rax, (%r15)
leaq 0xde49(%rip), %rdx      # 0x183b2
movq %r15, %rdi
movq %rdx, %rsi
callq 0x137c4
movq %r15, %rax
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 0xa574
leaq 0x14ec7(%rip), %rdi     # 0x1f470
callq 0x2430
testl %eax, %eax
je 0xa514
leaq -0x36(%rbp), %rdx
movb $0x61, (%rdx)
leaq 0xe636(%rip), %rsi      # 0x18bfa
leaq -0x218(%rbp), %r14
movq %r14, %rdi
callq 0x12de4
leaq -0x1f0(%rbp), %rbx
leaq -0x35(%rbp), %rdx
movb $0x62, (%rdx)
leaq 0xe5e4(%rip), %rsi      # 0x18bcc
movq %rbx, %rdi
callq 0x12e26
leaq -0x1c8(%rbp), %rbx
leaq -0x34(%rbp), %rdx
movb $0x4f, (%rdx)
leaq 0xe60a(%rip), %rsi      # 0x18c0f
movq %rbx, %rdi
callq 0x12e68
leaq -0x1a0(%rbp), %rbx
leaq -0x33(%rbp), %rdx
movb $0x50, (%rdx)
leaq 0xe5f1(%rip), %rsi      # 0x18c13
movq %rbx, %rdi
callq 0x12eaa
leaq -0x178(%rbp), %rbx
leaq -0x32(%rbp), %rdx
movb $-0x80, (%rdx)
leaq 0xe5aa(%rip), %rsi      # 0x18be9
movq %rbx, %rdi
callq 0x12eec
leaq -0x150(%rbp), %rbx
leaq -0x31(%rbp), %rdx
movb $-0x7f, (%rdx)
leaq 0xe5bc(%rip), %rsi      # 0x18c18
movq %rbx, %rdi
callq 0x12f2e
leaq -0x128(%rbp), %rbx
leaq -0x30(%rbp), %rdx
movb $-0x7e, (%rdx)
leaq 0xe560(%rip), %rsi      # 0x18bd9
movq %rbx, %rdi
callq 0x12f70
leaq -0x100(%rbp), %rbx
leaq -0x2f(%rbp), %rdx
movb $-0x7d, (%rdx)
leaq 0xe594(%rip), %rsi      # 0x18c2a
movq %rbx, %rdi
callq 0x12f70
leaq -0xd8(%rbp), %rbx
leaq -0x2e(%rbp), %rdx
movb $-0x7b, (%rdx)
leaq 0xe587(%rip), %rsi      # 0x18c3a
movq %rbx, %rdi
callq 0x12fb2
leaq -0xb0(%rbp), %rbx
leaq -0x2d(%rbp), %rdx
movb $-0x76, (%rdx)
leaq 0xe578(%rip), %rsi      # 0x18c48
movq %rbx, %rdi
callq 0x12f2e
leaq -0x88(%rbp), %rbx
leaq -0x2c(%rbp), %rdx
movb $-0x75, (%rdx)
leaq 0xe56d(%rip), %rsi      # 0x18c5a
movq %rbx, %rdi
callq 0x12ff4
leaq -0x60(%rbp), %rbx
leaq -0x2b(%rbp), %rdx
movb $-0x78, (%rdx)
leaq 0xe56b(%rip), %rsi      # 0x18c72
movq %rbx, %rdi
callq 0x12e68
leaq 0x14d2a(%rip), %rdi     # 0x1f440
leaq -0x218(%rbp), %rsi
leaq -0x2a(%rbp), %rcx
leaq -0x29(%rbp), %r8
movl $0xc, %edx
callq 0x13036
leaq -0x50(%rbp), %rbx
xorl %r14d, %r14d
movq -0x60(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xa749
callq 0x2220
addq $-0x28, %r14
cmpq $-0x1e0, %r14           # imm = 0xFE20
jne 0xa736
leaq 0x895d(%rip), %rdi      # 0x130ba
leaq 0x14cdc(%rip), %rsi     # 0x1f440
leaq 0x14add(%rip), %rdx     # 0x1f248
callq 0x2210
leaq 0x14cf9(%rip), %rdi     # 0x1f470
callq 0x2180
jmp 0xa514
movq %rax, %r15
movq $-0x1e0, %r12           # imm = 0xFE20
leaq -0x50(%rbp), %r13
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0xa79d
callq 0x2220
addq $-0x28, %r13
addq $0x28, %r12
jne 0xa78f
movb $0x1, %al
jmp 0xa7c4
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
jmp 0xa7bf
movq %rax, %r15
xorl %eax, %eax
cmpq %rbx, %r14
sete %cl
testb %al, %al
jne 0xa7f4
testb %cl, %cl
jne 0xa7f4
leaq -0x218(%rbp), %r14
movq -0x28(%rbx), %rdi
leaq -0x18(%rbx), %rax
cmpq %rdi, %rax
je 0xa7eb
callq 0x2220
addq $-0x28, %rbx
cmpq %r14, %rbx
jne 0xa7d9
leaq 0x14c75(%rip), %rdi     # 0x1f470
callq 0x2170
movq %r15, %rdi
callq 0x2400
movq %rax, %r15
xorl %eax, %eax
movq %r14, %rbx
jmp 0xa7c4