// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movabsq $0x1, %r8
xorl %r12d, %r12d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x67e7(%rip), %rdx      # 0x131b0
movabsq $0x1999999999999999, %r9 # imm = 0x1999999999999999
movabsq $0x2f, %rax
movl $0x3, %ebx
movl $0x4, %ebp
movl $0x5, %r14d
movl %r12d, %r11d
movslq (%rdx,%r11,4), %r11
addq %rdx, %r11
jmpq *%r11
andq $0x0, (%rsi)
movb (%rdi), %r15b
leal -0x3a(%r15), %r11d
cmpb $-0xa, %r11b
jae 0xca18
jmp 0xcb08
movb (%rdi), %r15b
jmp 0xca76
movb (%rdi), %r15b
leal -0x30(%r15), %r11d
cmpb $0x9, %r11b
ja 0xca6b
movq (%rsi), %r11
movq %r11, %r13
movl %ecx, %r12d
cmpq %r9, %r11
ja 0xca40
imulq $0xa, %r11, %r13
movq %r13, (%rsi)
movb (%rdi), %r15b
movl $0x1, %r12d
movsbq %r15b, %r15
movq %rax, %r10
subq %r15, %r10
cmpq %r10, %r13
ja 0xcb08
leaq (%r15,%r13), %r10
addq $-0x30, %r10
movq %r10, (%rsi)
cmpq %r9, %r11
jbe 0xcadf
jmp 0xcb08
movb (%rdi), %r15b
cmpb $0x20, %r15b
jne 0xca76
movl %ebx, %r12d
jmp 0xcadf
cmpb $0x6b, %r15b
je 0xcac1
movzbl %r15b, %r11d
cmpl $0x47, %r11d
je 0xcab3
cmpl $0x4d, %r11d
je 0xcaba
cmpl $0x50, %r11d
je 0xcaa5
cmpl $0x54, %r11d
je 0xcaac
cmpl $0x45, %r11d
jne 0xcaef
imulq $0x3e8, %r8, %r8        # imm = 0x3E8
imulq $0x3e8, %r8, %r8        # imm = 0x3E8
imulq $0x3e8, %r8, %r8        # imm = 0x3E8
imulq $0x3e8, %r8, %r8        # imm = 0x3E8
imulq $0x3e8, %r8, %r8        # imm = 0x3E8
imulq $0x3e8, %r8, %r8        # imm = 0x3E8
movl %ebp, %r12d
jmp 0xcadf
movb (%rdi), %r15b
movq %r8, %r11
movq %r11, %r8
movl %r14d, %r12d
cmpb $0x42, %r15b
jne 0xcb0c
cmpb $0x0, 0x1(%rdi)
leaq 0x1(%rdi), %rdi
jne 0xc9ed
jmp 0xcb04
movabsq $0x1, %r11
movl %ebp, %r12d
cmpq $0x1, %r8
je 0xcad3
jmp 0xcadf
xorl %edi, %edi
jmp 0xcb11
movl %ecx, %edi
jmp 0xcb11
movl %ecx, %edi
movq %r11, %r8
movq (%rsi), %r9
movq %r8, %rax
mulq %r9
jo 0xcb25
imulq %r8, %r9
movq %r9, (%rsi)
movl %edi, %ecx
movl %ecx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop