// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x473a4
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x473c4
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x473c6
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xc1(%rbp)
je 0x47401
callq 0x26550
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
setne %al
movb %al, -0xc1(%rbp)
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x4740d
jmp 0x4741b
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x473c6
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x4743c
movq -0x20(%rbp), %rdi
leaq 0x104379(%rip), %rsi    # 0x14b7ab
callq 0x26300
cmpl $0x0, %eax
jne 0x4744c
movq $0x1, -0xa8(%rbp)
jmp 0x4754b
movq -0x20(%rbp), %rdi
leaq 0x106aae(%rip), %rsi    # 0x14df05
callq 0x26300
cmpl $0x0, %eax
jne 0x47471
movq $0x3e8, -0xa8(%rbp) # imm = 0x3E8
jmp 0x47549
movq -0x20(%rbp), %rdi
leaq 0xf7d06(%rip), %rsi     # 0x13f182
callq 0x26300
cmpl $0x0, %eax
jne 0x47496
movq $0x400, -0xa8(%rbp) # imm = 0x400
jmp 0x47547
movq -0x20(%rbp), %rdi
leaq 0x101b83(%rip), %rsi    # 0x149024
callq 0x26300
cmpl $0x0, %eax
jne 0x474bb
movq $0xf4240, -0xa8(%rbp) # imm = 0xF4240
jmp 0x47545
movq -0x20(%rbp), %rdi
leaq 0xfabb8(%rip), %rsi     # 0x14207e
callq 0x26300
cmpl $0x0, %eax
jne 0x474dd
movq $0x100000, -0xa8(%rbp) # imm = 0x100000
jmp 0x47543
movq -0x20(%rbp), %rdi
leaq 0xfd1d4(%rip), %rsi     # 0x1446bc
callq 0x26300
cmpl $0x0, %eax
jne 0x474ff
movq $0x3b9aca00, -0xa8(%rbp) # imm = 0x3B9ACA00
jmp 0x47541
movq -0x20(%rbp), %rdi
leaq 0xf7c6a(%rip), %rsi     # 0x13f174
callq 0x26300
cmpl $0x0, %eax
jne 0x47521
movq $0x40000000, -0xa8(%rbp) # imm = 0x40000000
jmp 0x4753f
cmpq $0x0, -0x18(%rbp)
je 0x47532
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x47629
jmp 0x47541
jmp 0x47543
jmp 0x47545
jmp 0x47547
jmp 0x47549
jmp 0x4754b
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpq $0x80, %rax
jb 0x47588
cmpq $0x0, -0x18(%rbp)
je 0x4757b
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x47629
leaq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0xb4(%rbp), %eax
movl %eax, %edx
callq 0x26c60
movl -0xb4(%rbp), %eax
movb $0x0, -0xa0(%rbp,%rax)
callq 0x26880
movl $0x0, (%rax)
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
movl $0xa, %edx
callq 0x26af0
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x475ec
callq 0x26880
cmpl $0x16, (%rax)
je 0x475fb
movq -0xc0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x47616
cmpq $0x0, -0x18(%rbp)
je 0x4760c
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x47629
movq -0xb0(%rbp), %rax
imulq -0xa8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)