// File: FFY00[P]uicc/include/uicc.h
// Function: makeBcd(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, int)
static inline string makeBcd(string data, bool swap=true, int outputLength=0) {
    string tmp=data;
    string output;

    if (data.size()%2 == 1 )
        tmp+='f';

    if (swap)
        for(size_t i=0; i< tmp.size(); i+=2)
            output+=(char)( (mkDigit(tmp[i+1])<<4) + (mkDigit(tmp[i])) );
    else
        for(size_t i=0; i< tmp.size(); i+=2)
            output+=(char)( (mkDigit(tmp[i])<<4) + (mkDigit(tmp[i+1])) );

    for (int i=tmp.size()/2; i<outputLength; i++)
        output+='\xff';

    return output;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rsi, -0x70(%rbp)
movq %rdi, -0x78(%rbp)
movb %dl, %al
movq %rdi, %rdx
movq %rdx, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movl %ecx, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3120
movq -0x78(%rbp), %rdi
movb $0x0, -0x39(%rbp)
callq 0x33f0
movq -0x70(%rbp), %rdi
callq 0x31f0
andq $0x1, %rax
cmpq $0x1, %rax
jne 0x7d2a
leaq -0x38(%rbp), %rdi
movl $0x66, %esi
callq 0x31b0
jmp 0x7d05
jmp 0x7d2a
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x31a0
leaq -0x38(%rbp), %rdi
callq 0x31a0
jmp 0x7f38
testb $0x1, -0x11(%rbp)
je 0x7e09
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31f0
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x7e04
movq -0x58(%rbp), %rsi
incq %rsi
leaq -0x38(%rbp), %rdi
callq 0x3520
movq %rax, -0x90(%rbp)
jmp 0x7d7c
movq -0x90(%rbp), %rax
movzbl (%rax), %edi
callq 0xe8e0
movb %al, -0x91(%rbp)
jmp 0x7d93
movb -0x91(%rbp), %al
movzbl %al, %eax
shll $0x4, %eax
movl %eax, -0xa4(%rbp)
movq -0x58(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x3520
movq %rax, -0xa0(%rbp)
jmp 0x7dbb
movq -0xa0(%rbp), %rax
movzbl (%rax), %edi
callq 0xe8e0
movb %al, -0xa5(%rbp)
jmp 0x7dd2
movq -0x78(%rbp), %rdi
movl -0xa4(%rbp), %eax
movb -0xa5(%rbp), %cl
movzbl %cl, %ecx
addl %ecx, %eax
movsbl %al, %esi
callq 0x31b0
jmp 0x7df1
jmp 0x7df3
movq -0x58(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x58(%rbp)
jmp 0x7d3c
jmp 0x7edb
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31f0
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq %rcx, %rax
jae 0x7ed9
movq -0x60(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x3520
movq %rax, -0xb8(%rbp)
jmp 0x7e4e
movq -0xb8(%rbp), %rax
movzbl (%rax), %edi
callq 0xe8e0
movb %al, -0xb9(%rbp)
jmp 0x7e65
movb -0xb9(%rbp), %al
movzbl %al, %eax
shll $0x4, %eax
movl %eax, -0xcc(%rbp)
movq -0x60(%rbp), %rsi
incq %rsi
leaq -0x38(%rbp), %rdi
callq 0x3520
movq %rax, -0xc8(%rbp)
jmp 0x7e90
movq -0xc8(%rbp), %rax
movzbl (%rax), %edi
callq 0xe8e0
movb %al, -0xcd(%rbp)
jmp 0x7ea7
movq -0x78(%rbp), %rdi
movl -0xcc(%rbp), %eax
movb -0xcd(%rbp), %cl
movzbl %cl, %ecx
addl %ecx, %eax
movsbl %al, %esi
callq 0x31b0
jmp 0x7ec6
jmp 0x7ec8
movq -0x60(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x60(%rbp)
jmp 0x7e11
jmp 0x7edb
leaq -0x38(%rbp), %rdi
callq 0x31f0
shrq %rax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x7f0f
movq -0x78(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x31b0
jmp 0x7f02
jmp 0x7f04
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x7eea
movb $0x1, -0x39(%rbp)
testb $0x1, -0x39(%rbp)
jne 0x7f22
movq -0x78(%rbp), %rdi
callq 0x31a0
leaq -0x38(%rbp), %rdi
callq 0x31a0
movq -0x80(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x34b0
nopw %cs:(%rax,%rax)