// File: phillip-h[P]fractal-gen/fractalgen.cpp
// Function: htoi(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
unsigned char htoi(std::string str)
{
    if (str.size() != 2)
        return 0;
    unsigned char res = 0;
    unsigned char c = str.at(0);
    if (c >= '0' && c <= '9')
        res += (c - 0x30) * 16;
    else if (c >= 'a' && c <= 'f')
        res += (c - 'a' + 10) * 16;
    else if (c >= 'A' && c <= 'F')
        res += (c - 'A' + 10) * 16;
    else
        cout << "unknown hex char '" << c << "'.\n";

    c = str.at(1);
    if (c >= '0' && c <= '9')
        res += (c - 0x30) * 1;
    else if (c >= 'a' && c <= 'f')
        res += (c - 'a' + 10) * 1;
    else if (c >= 'A' && c <= 'F')
        res += (c - 'A' + 10) * 1;
    else
        cout << "unknown hex char '" << c << "'.\n";

    return res;
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
callq 0x3120
cmpq $0x2, %rax
je 0x3783
movb $0x0, 0x27(%rsp)
jmp 0x3939
movq 0x8(%rsp), %rdi
movb $0x0, 0x17(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x33e0
movb (%rax), %al
movb %al, 0x16(%rsp)
movzbl 0x16(%rsp), %eax
cmpl $0x30, %eax
jl 0x37cb
movzbl 0x16(%rsp), %eax
cmpl $0x39, %eax
jg 0x37cb
movzbl 0x16(%rsp), %ecx
subl $0x30, %ecx
shll $0x4, %ecx
movzbl 0x17(%rsp), %eax
addl %ecx, %eax
movb %al, 0x17(%rsp)
jmp 0x385c
movzbl 0x16(%rsp), %eax
cmpl $0x61, %eax
jl 0x37fa
movzbl 0x16(%rsp), %eax
cmpl $0x66, %eax
jg 0x37fa
movzbl 0x16(%rsp), %ecx
subl $0x61, %ecx
addl $0xa, %ecx
shll $0x4, %ecx
movzbl 0x17(%rsp), %eax
addl %ecx, %eax
movb %al, 0x17(%rsp)
jmp 0x385a
movzbl 0x16(%rsp), %eax
cmpl $0x41, %eax
jl 0x3829
movzbl 0x16(%rsp), %eax
cmpl $0x46, %eax
jg 0x3829
movzbl 0x16(%rsp), %ecx
subl $0x41, %ecx
addl $0xa, %ecx
shll $0x4, %ecx
movzbl 0x17(%rsp), %eax
addl %ecx, %eax
movb %al, 0x17(%rsp)
jmp 0x3858
movq 0x1e7a8(%rip), %rdi     # 0x21fd8
leaq 0x187ec(%rip), %rsi     # 0x1c023
callq 0x31c0
movq %rax, %rdi
movzbl 0x16(%rsp), %esi
callq 0x3310
movq %rax, %rdi
leaq 0x188bb(%rip), %rsi     # 0x1c10e
callq 0x31c0
jmp 0x385a
jmp 0x385c
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0x33e0
movb (%rax), %al
movb %al, 0x16(%rsp)
movzbl 0x16(%rsp), %eax
cmpl $0x30, %eax
jl 0x38a0
movzbl 0x16(%rsp), %eax
cmpl $0x39, %eax
jg 0x38a0
movzbl 0x16(%rsp), %ecx
subl $0x30, %ecx
shll $0x0, %ecx
movzbl 0x17(%rsp), %eax
addl %ecx, %eax
movb %al, 0x17(%rsp)
jmp 0x3931
movzbl 0x16(%rsp), %eax
cmpl $0x61, %eax
jl 0x38cf
movzbl 0x16(%rsp), %eax
cmpl $0x66, %eax
jg 0x38cf
movzbl 0x16(%rsp), %ecx
subl $0x61, %ecx
addl $0xa, %ecx
shll $0x0, %ecx
movzbl 0x17(%rsp), %eax
addl %ecx, %eax
movb %al, 0x17(%rsp)
jmp 0x392f
movzbl 0x16(%rsp), %eax
cmpl $0x41, %eax
jl 0x38fe
movzbl 0x16(%rsp), %eax
cmpl $0x46, %eax
jg 0x38fe
movzbl 0x16(%rsp), %ecx
subl $0x41, %ecx
addl $0xa, %ecx
shll $0x0, %ecx
movzbl 0x17(%rsp), %eax
addl %ecx, %eax
movb %al, 0x17(%rsp)
jmp 0x392d
movq 0x1e6d3(%rip), %rdi     # 0x21fd8
leaq 0x18717(%rip), %rsi     # 0x1c023
callq 0x31c0
movq %rax, %rdi
movzbl 0x16(%rsp), %esi
callq 0x3310
movq %rax, %rdi
leaq 0x187e6(%rip), %rsi     # 0x1c10e
callq 0x31c0
jmp 0x392f
jmp 0x3931
movb 0x17(%rsp), %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)