// File: /workspace/github_cpp_makefile_star2_O3/occivink[P]pyct/pyct.cpp
// Function: size_to_number(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
u64 size_to_number(const std::string& s) {
    int bits = false;
    int mult = 1;
    enum {
        Num,
        NumOrUnitOrBit,
        Bit,
        Nothing,
    } expects = Num;
    std::string numPart;
    for (size_t i = 0; i < s.size(); ++i) {
        char c = s[i];
        if (expects == Num) {
            if (c < '0' or c > '9')
                throw std::runtime_error{"Not a number"};
            expects = NumOrUnitOrBit;
        } else if (expects == NumOrUnitOrBit) {
            auto readUnit = [&](int val){
                mult = val;
                expects = Bit;
                numPart = s.substr(0, i);
            };
            if (c >= '0' and c <= '9')
                {}
            else if (c == 'k' or c == 'K')
                readUnit(1024);
            else if (c == 'm' or c == 'M')
                readUnit(1024 * 1024);
            else if (c == 'g' or c == 'G')
                readUnit(1024 * 1024 * 1024);
            else if (c == 'b' or c == 'B') {
                bits = c == 'b';
                expects = Nothing;
            } else {
                throw std::runtime_error{"Not a number or unit"};
            }
        } else if (expects == Bit) {
            bits = c == 'b';
            expects = Nothing;
        } else if (expects == Nothing) {
            throw std::runtime_error{"Unexpected character"};
        }
    }
    if (numPart.empty())
        numPart = s;
    u64 num = stoull(numPart);
    if (bits)
        return num * mult / 8;
    else
        return num * mult;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpq $0x0, 0x8(%rdi)
je 0x9f04
leaq 0x38(%rsp), %r12
xorl %r14d, %r14d
movq (%rbx), %rax
movzbl (%rax,%r14), %ecx
movl %r14d, %eax
leaq 0x402e(%rip), %rbp      # 0xdf20
movslq (%rbp,%rax,4), %rdx
addq %rbp, %rdx
movl $0x1, %eax
xorl %r13d, %r13d
jmpq *%rdx
movl $0x1, %r13d
movb $0x1, 0x7(%rsp)
jmp 0xa0d5
addb $-0x3a, %cl
movl $0x1, %edx
cmpb $-0xb, %cl
ja 0xa094
movl $0x10, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x40f7(%rip), %rsi      # 0xe030
movq %rax, %rdi
callq 0x20b0
jmp 0xa18f
movq %rax, %rbx
movq %r14, %rdi
callq 0x2160
jmp 0xa1c9
leal -0x30(%rcx), %edx
cmpb $0xa, %dl
jae 0x9f68
movl $0x1, %edx
jmp 0xa094
movl %ecx, %edx
andl $-0x21, %edx
cmpl $0x47, %edx
je 0xa004
cmpl $0x4d, %edx
je 0x9fc4
cmpl $0x4b, %edx
jne 0xa049
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x2210
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %r15
movq %r15, %rsi
callq 0x2270
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x9fbd
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movl $0x400, %eax            # imm = 0x400
jmp 0xa042
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x2210
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %r15
movq %r15, %rsi
callq 0x2270
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x9ffd
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movl $0x100000, %eax         # imm = 0x100000
jmp 0xa042
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x2210
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %r15
movq %r15, %rsi
callq 0x2270
movq (%r15), %rdi
cmpq %r12, %rdi
je 0xa03d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movl $0x40000000, %eax       # imm = 0x40000000
movl $0x2, %edx
jmp 0xa094
movl %ecx, %edx
orl $0x20, %edx
cmpl $0x62, %edx
je 0xa0b1
movl $0x10, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x3fd6(%rip), %rsi      # 0xe03d
movq %rax, %rdi
callq 0x20b0
movq 0x7f7a(%rip), %rsi      # 0x11ff0
movq 0x7f33(%rip), %rdx      # 0x11fb0
movq %r14, %rdi
callq 0x2360
jmp 0xa1c6
jmp 0x9f46
jmp 0xa1c6
incq %r14
cmpq 0x8(%rbx), %r14
jae 0xa0c2
movq (%rbx), %rcx
movzbl (%rcx,%r14), %ecx
movl %edx, %edx
movslq (%rbp,%rdx,4), %rdx
addq %rbp, %rdx
jmpq *%rdx
xorl %r13d, %r13d
cmpl $0x62, %ecx
sete %r13b
movl $0x3, %edx
jmp 0xa094
testl %r13d, %r13d
sete 0x7(%rsp)
cmpq $0x0, 0x10(%rsp)
movl %eax, %r13d
jne 0xa0e2
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2110
movq 0x8(%rsp), %r15
callq 0x2040
movq %rax, %r14
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x28(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x22a0
cmpq %r15, (%r12)
je 0xa1a5
movq %rax, %rbx
movl (%r14), %eax
testl %eax, %eax
je 0xa131
cmpl $0x22, %eax
jne 0xa134
leaq 0x4792(%rip), %rdi      # 0xe8be
callq 0x22e0
movl %ebp, (%r14)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa150
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
imulq %r13, %rbx
movq %rbx, %rax
shrq $0x3, %rax
cmpb $0x0, 0x7(%rsp)
cmovneq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x3ecb(%rip), %rsi      # 0xe052
movq %rax, %rdi
callq 0x20b0
movq 0x7e5a(%rip), %rsi      # 0x11ff0
movq 0x7e13(%rip), %rdx      # 0x11fb0
movq %r14, %rdi
callq 0x2360
leaq 0x4712(%rip), %rdi      # 0xe8be
callq 0x2130
jmp 0xa1c6
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0xa1c9
movl %ebp, (%r14)
jmp 0xa1c9
jmp 0x9f46
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xa1e5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2380