// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %rdi, %rbx
leaq 0x4(%rsp), %r15
movq %rsp, %r12
andl $0x0, (%r12)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movl $0x1, (%r15)
movb $0x0, (%rax)
xorl %eax, %eax
leaq 0x3d55(%rip), %r13      # 0xcf00
leaq 0x8(%rsp), %r14
xorl %ebp, %ebp
movq %rax, 0x8(%rsp)
cmpq 0x8(%rbx), %rax
jae 0x928c
movl (%rsp), %edx
cmpq $0x3, %rdx
ja 0x9284
movq (%rbx), %rcx
movzbl (%rcx,%rax), %ecx
movslq (%r13,%rdx,4), %rdx
addq %r13, %rdx
jmpq *%rdx
addb $-0x3a, %cl
cmpb $-0xb, %cl
jbe 0x92fe
movl $0x1, (%rsp)
jmp 0x9284
xorl %ebp, %ebp
cmpl $0x62, %ecx
sete %bpl
movl $0x3, (%rsp)
jmp 0x9284
movq %r15, 0x30(%rsp)
movq %r12, 0x38(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %rbx, 0x48(%rsp)
movq %r14, 0x50(%rsp)
leal -0x30(%rcx), %eax
cmpb $0xa, %al
jb 0x927f
movl %ecx, %eax
andl $-0x21, %eax
cmpl $0x47, %eax
je 0x9250
cmpl $0x4d, %eax
je 0x9249
cmpl $0x4b, %eax
jne 0x9261
movl $0x400, %esi            # imm = 0x400
jmp 0x9255
movl $0x100000, %esi         # imm = 0x100000
jmp 0x9255
movl $0x40000000, %esi       # imm = 0x40000000
leaq 0x30(%rsp), %rdi
callq 0x938c
jmp 0x927f
movl %ecx, %eax
orl $0x20, %eax
cmpl $0x62, %eax
jne 0x932e
xorl %ebp, %ebp
cmpl $0x62, %ecx
sete %bpl
movl $0x3, (%rsp)
movq 0x8(%rsp), %rax
incq %rax
jmp 0x91b2
cmpq $0x0, 0x18(%rsp)
jne 0x92a1
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x2120
leaq 0x10(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0xacfc
movslq 0x4(%rsp), %rcx
imulq %rcx, %rax
movq %rax, %rbx
shrq $0x3, %rbx
testl %ebp, %ebp
cmoveq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20e0
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %r14
leaq 0x3d4e(%rip), %rsi      # 0xd042
movq %rax, %rdi
callq 0x2090
jmp 0x9318
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %r14
leaq 0x3d10(%rip), %rsi      # 0xd020
movq %rax, %rdi
callq 0x2090
movq 0x8cd1(%rip), %rsi      # 0x11ff0
movq 0x8c7a(%rip), %rdx      # 0x11fa0
movq %r14, %rdi
callq 0x2360
pushq $0x10
popq %rdi
callq 0x2100
movq %rax, %r14
leaq 0x3ced(%rip), %rsi      # 0xd02d
movq %rax, %rdi
callq 0x2090
movq 0x8ca1(%rip), %rsi      # 0x11ff0
movq 0x8c4a(%rip), %rdx      # 0x11fa0
movq %r14, %rdi
callq 0x2360
jmp 0x9377
jmp 0x936a
jmp 0x9377
jmp 0x9377
jmp 0x9377
jmp 0x936a
movq %rax, %rbx
movq %r14, %rdi
callq 0x2160
jmp 0x937a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2380