// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/src/util.c
// Function: memtoll
long long memtoll(const char *p, int *err) {
    const char *u;
    char buf[128];
    long mul; /* unit multiplier */
    long long val;
    unsigned int digits;

    if (err) *err = 0;
    /* Search the first non digit character. */
    u = p;
    if (*u == '-') u++;
    while(*u && isdigit(*u)) u++;
    if (*u == '\0' || !strcasecmp(u,"b")) {
        mul = 1;
    } else if (!strcasecmp(u,"k")) {
        mul = 1000;
    } else if (!strcasecmp(u,"kb")) {
        mul = 1024;
    } else if (!strcasecmp(u,"m")) {
        mul = 1000*1000;
    } else if (!strcasecmp(u,"mb")) {
        mul = 1024*1024;
    } else if (!strcasecmp(u,"g")) {
        mul = 1000L*1000*1000;
    } else if (!strcasecmp(u,"gb")) {
        mul = 1024L*1024*1024;
    } else {
        if (err) *err = 1;
        mul = 1;
    }
    digits = u-p;
    if (digits >= sizeof(buf)) {
        if (err) *err = 1;
        return LLONG_MAX;
    }
    memcpy(buf,p,digits);
    buf[digits] = '\0';
    val = strtoll(buf,NULL,10);
    return val*mul;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0x250e0
movl $0x0, (%rbx)
xorl %r13d, %r13d
cmpb $0x2d, (%r14)
sete %r13b
leaq (%r14,%r13), %r15
movsbq (%r14,%r13), %r12
movl $0x1, %eax
movq %rax, 0x8(%rsp)
testq %r12, %r12
sete %bpl
je 0x25223
callq 0x129b0
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r12,2)
je 0x25140
leaq (%r14,%r13), %r15
incq %r15
movsbq (%r15), %rcx
testq %rcx, %rcx
sete %bpl
je 0x25223
incq %r15
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x25122
decq %r15
testb %bpl, %bpl
jne 0x25223
leaq 0x2f6ae(%rip), %rsi     # 0x547fe
movq %r15, %rdi
callq 0x12090
testl %eax, %eax
je 0x25223
leaq 0x35202(%rip), %rsi     # 0x5a369
movq %r15, %rdi
callq 0x12090
testl %eax, %eax
je 0x251fd
leaq 0x30c95(%rip), %rsi     # 0x55e13
movq %r15, %rdi
callq 0x12090
testl %eax, %eax
je 0x25204
leaq 0x33683(%rip), %rsi     # 0x58814
movq %r15, %rdi
callq 0x12090
testl %eax, %eax
je 0x2520b
leaq 0x30c68(%rip), %rsi     # 0x55e0c
movq %r15, %rdi
callq 0x12090
testl %eax, %eax
je 0x25212
leaq 0x2faa1(%rip), %rsi     # 0x54c58
movq %r15, %rdi
callq 0x12090
testl %eax, %eax
je 0x25219
leaq 0x30c3b(%rip), %rsi     # 0x55e05
movq %r15, %rdi
callq 0x12090
testl %eax, %eax
movl $0x40000000, %ecx       # imm = 0x40000000
movl $0x1, %edx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%rsp)
testq %rbx, %rbx
je 0x25223
testl %eax, %eax
je 0x25223
movl $0x1, (%rbx)
movl $0x1, %eax
jmp 0x2521e
movl $0x3e8, %eax            # imm = 0x3E8
jmp 0x2521e
movl $0x400, %eax            # imm = 0x400
jmp 0x2521e
movl $0xf4240, %eax          # imm = 0xF4240
jmp 0x2521e
movl $0x100000, %eax         # imm = 0x100000
jmp 0x2521e
movl $0x3b9aca00, %eax       # imm = 0x3B9ACA00
movq %rax, 0x8(%rsp)
subl %r14d, %r15d
cmpl $0x80, %r15d
jb 0x25246
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
testq %rbx, %rbx
je 0x25274
movl $0x1, (%rbx)
jmp 0x25274
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x12520
movb $0x0, 0x10(%rsp,%r15)
movq %rbx, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x124c0
imulq 0x8(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq