// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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;
        return 0;
    }

    /* Copy the digits into a buffer, we'll use strtoll() to convert
     * the digit (without the unit) into a number. */
    digits = u-p;
    if (digits >= sizeof(buf)) {
        if (err) *err = 1;
        return 0;
    }
    memcpy(buf,p,digits);
    buf[digits] = '\0';

    char *endptr;
    errno = 0;
    val = strtoll(buf,&endptr,10);
    if ((val == 0 && errno == EINVAL) || *endptr != '\0') {
        if (err) *err = 1;
        return 0;
    }
    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 0x4316c
movl $0x0, (%rbx)
xorl %r12d, %r12d
cmpb $0x2d, (%r14)
sete %r12b
leaq (%r14,%r12), %r15
movsbq (%r14,%r12), %r13
movl $0x1, %eax
movq %rax, (%rsp)
testq %r13, %r13
sete %bpl
je 0x4328d
callq 0x26570
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r13,2)
je 0x431cb
leaq (%r12,%r14), %r15
incq %r15
movsbq (%r15), %rcx
testq %rcx, %rcx
sete %bpl
je 0x4328d
incq %r15
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x431ad
decq %r15
testb %bpl, %bpl
jne 0x4328d
leaq 0x91550(%rip), %rsi     # 0xd472b
movq %r15, %rdi
callq 0x26300
testl %eax, %eax
je 0x4328d
leaq 0x94a17(%rip), %rsi     # 0xd7c09
movq %r15, %rdi
callq 0x26300
testl %eax, %eax
je 0x43268
leaq 0x84a65(%rip), %rsi     # 0xc7c6a
movq %r15, %rdi
callq 0x26300
testl %eax, %eax
je 0x4326f
leaq 0x8ef2c(%rip), %rsi     # 0xd2144
movq %r15, %rdi
callq 0x26300
testl %eax, %eax
je 0x43276
leaq 0x87d4a(%rip), %rsi     # 0xcaf75
movq %r15, %rdi
callq 0x26300
testl %eax, %eax
je 0x4327d
leaq 0x8a4c6(%rip), %rsi     # 0xcd704
movq %r15, %rdi
callq 0x26300
testl %eax, %eax
je 0x43284
leaq 0x84a0b(%rip), %rsi     # 0xc7c5c
movq %r15, %rdi
callq 0x26300
testl %eax, %eax
jne 0x432e7
movl $0x40000000, %eax       # imm = 0x40000000
jmp 0x43289
movl $0x3e8, %eax            # imm = 0x3E8
jmp 0x43289
movl $0x400, %eax            # imm = 0x400
jmp 0x43289
movl $0xf4240, %eax          # imm = 0xF4240
jmp 0x43289
movl $0x100000, %eax         # imm = 0x100000
jmp 0x43289
movl $0x3b9aca00, %eax       # imm = 0x3B9ACA00
movq %rax, (%rsp)
subl %r14d, %r15d
cmpl $0x80, %r15d
jae 0x432e7
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x26c60
movb $0x0, 0x10(%rsp,%r15)
callq 0x26890
movq %rax, %r14
movl $0x0, (%rax)
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
movl $0xa, %edx
callq 0x26b00
testq %rax, %rax
jne 0x432dd
cmpl $0x16, (%r14)
je 0x432e7
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x43306
testq %rbx, %rbx
je 0x432f2
movl $0x1, (%rbx)
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
imulq (%rsp), %rax
jmp 0x432f4