// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/util/humansize.c
// Function: humansize_parse
int
humansize_parse(const char * s, uint64_t * size)
{
	int state = 0;
	uint64_t multiplier = 1;

	do {
		switch (state) {
		case -1:
			/* Error state. */
			break;
		case 0:
			/* Initial state. */
			*size = 0;

			/* We must start with at least one digit. */
			if ((*s < '0') || (*s > '9')) {
				state = -1;
				break;
			}

			/* FALLTHROUGH */
		case 1:
			/* We're now processing digits. */
			state = 1;

			/* Digit-parsing state. */
			if (('0' <= *s) && (*s <= '9')) {
				if (*size > UINT64_MAX / 10)
					state = -1;
				else
					*size *= 10;
				if (*size > UINT64_MAX - (uint64_t)(*s - '0'))
					state = -1;
				else
					*size += (uint64_t)(*s - '0');
				break;
			}

			/* FALLTHROUGH */
		case 2:
			/* We move into state 3 after an optional ' '. */
			state = 3;
			if (*s == ' ')
				break;

			/* FALLTHROUGH */
		case 3:
			/* We may have one SI prefix. */
			switch (*s) {
			case 'E':
				multiplier *= 1000;
				/* FALLTHROUGH */
			case 'P':
				multiplier *= 1000;
				/* FALLTHROUGH */
			case 'T':
				multiplier *= 1000;
				/* FALLTHROUGH */
			case 'G':
				multiplier *= 1000;
				/* FALLTHROUGH */
			case 'M':
				multiplier *= 1000;
				/* FALLTHROUGH */
			case 'k':
				multiplier *= 1000;
				break;
			}

			/* We move into state 4 after the optional prefix. */
			state = 4;
			if (multiplier != 1)
				break;

			/* FALLTHROUGH */
		case 4:
			/* We move into state 5 after an optional 'B'. */
			state = 5;
			if (*s == 'B')
				break;

			/* FALLTHROUGH */
		case 5:
			/* We have trailing garbage. */
			state = -1;
			break;
		}

		/* Move on to the next character. */
		s++;
	} while ((state != -1) && (*s != '\0'));

	/* Multiply by multiplier. */
	if (*size > UINT64_MAX / multiplier)
		state = -1;
	else
		*size *= multiplier;

	/* Anything other than state -1 is success. */
	return ((state == -1) ? -1 : 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq $0x1, -0x20(%rbp)
movl -0x14(%rbp), %eax
incl %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x6, %eax
ja 0x15af8
movq -0x28(%rbp), %rax
leaq 0xacf6(%rip), %rcx      # 0x20660
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x15af8
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x1599b
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jle 0x159a7
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x15af8
jmp 0x159a9
movl $0x1, -0x14(%rbp)
movq -0x8(%rbp), %rax
movsbl (%rax), %ecx
movl $0x30, %eax
cmpl %ecx, %eax
jg 0x15a3b
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jg 0x15a3b
movq -0x10(%rbp), %rax
movabsq $0x1999999999999999, %rcx # imm = 0x1999999999999999
cmpq %rcx, (%rax)
jbe 0x159e8
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x159f3
movq -0x10(%rbp), %rax
imulq $0xa, (%rax), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movsbl (%rcx), %ecx
subl $0x30, %ecx
movslq %ecx, %rdx
movq $-0x1, %rcx
subq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x15a1f
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x15a36
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
movslq %eax, %rcx
movq -0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x15af8
jmp 0x15a3d
movl $0x3, -0x14(%rbp)
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0x15a55
jmp 0x15af8
jmp 0x15a57
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
addl $-0x45, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x26, %eax
ja 0x15ac8
movq -0x30(%rbp), %rax
leaq 0xac05(%rip), %rcx      # 0x2067c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0x20(%rbp)
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0x20(%rbp)
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0x20(%rbp)
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0x20(%rbp)
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0x20(%rbp)
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0x20(%rbp)
movl $0x4, -0x14(%rbp)
cmpq $0x1, -0x20(%rbp)
je 0x15ad8
jmp 0x15af8
jmp 0x15ada
movl $0x5, -0x14(%rbp)
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x42, %eax
jne 0x15aef
jmp 0x15af8
jmp 0x15af1
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
xorl %eax, %eax
cmpl $-0x1, -0x14(%rbp)
movb %al, -0x31(%rbp)
je 0x15b1f
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x1594b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq $-0x1, %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x20(%rbp)
movq %rax, %rcx
movq -0x40(%rbp), %rax
cmpq %rcx, %rax
jbe 0x15b59
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x15b68
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
imulq (%rax), %rcx
movq %rcx, (%rax)
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $-0x1, %edx
cmovel %ecx, %eax
popq %rbp
retq
nopw (%rax,%rax)