// File: /workspace/github_c_makefile_star2_O0/joncampbell123[P]swfhax/sliding_window.c
// Function: sliding_window_v4_safe_strtoui
int sliding_window_v4_safe_strtoui(sliding_window_v4 *w,unsigned int *ret,int base) {
	unsigned char *scan,digit;

	if (sliding_window_v4_data_available(w) == 0) return 0;

	*ret = 0;
	scan = w->data;
	if (base == 0) {
		/* assume decimal */
		base = 10;

		/* starts with 0, then it's octal */
		if (*(w->data) == '0') {
			base = 8;
			scan++;
		}
		else {
			if (sliding_window_v4_data_available(w) < 2) return 0;
			if (!memcmp(w->data,"0x",2)) {
				scan += 2;
				base = 16;
			}
		}
	}

	do {
		if (scan >= w->end) return 0;

		if (*scan >= '0' && *scan <= '9')
			digit = *scan - '0';
		else if (*scan >= 'a' && *scan <= 'f')
			digit = *scan + 10 - 'a';
		else if (*scan >= 'A' && *scan <= 'F')
			digit = *scan + 10 - 'A';
		else
			break;

		if (digit >= (unsigned char)base)
			break;

		/* TODO: Overflow detect */
		*ret = (*ret * (unsigned int)base) + (unsigned int)digit;
		scan++;
	} while (1);

	w->data = scan;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7260
cmpq $0x0, %rax
jne 0x74ce
movl $0x0, -0x4(%rbp)
jmp 0x7650
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x7562
movl $0xa, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x30, %eax
jne 0x7516
movl $0x8, -0x1c(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x7560
movq -0x10(%rbp), %rdi
callq 0x7260
cmpq $0x2, %rax
jae 0x7531
movl $0x0, -0x4(%rbp)
jmp 0x7650
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movw (%rax), %ax
subw $0x7830, %ax            # imm = 0x7830
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x755e
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movl $0x10, -0x1c(%rbp)
jmp 0x7560
jmp 0x7562
jmp 0x7564
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jb 0x757e
movl $0x0, -0x4(%rbp)
jmp 0x7650
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x30, %eax
jl 0x75a5
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x39, %eax
jg 0x75a5
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
subl $0x30, %eax
movb %al, -0x29(%rbp)
jmp 0x75ff
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x61, %eax
jl 0x75cf
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x66, %eax
jg 0x75cf
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
addl $0xa, %eax
subl $0x61, %eax
movb %al, -0x29(%rbp)
jmp 0x75fd
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x41, %eax
jl 0x75f9
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x46, %eax
jg 0x75f9
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
addl $0xa, %eax
subl $0x41, %eax
movb %al, -0x29(%rbp)
jmp 0x75fb
jmp 0x763d
jmp 0x75fd
jmp 0x75ff
movzbl -0x29(%rbp), %eax
movl -0x1c(%rbp), %ecx
movzbl %cl, %ecx
cmpl %ecx, %eax
jl 0x760f
jmp 0x763d
movq -0x18(%rbp), %rax
movl (%rax), %ecx
imull -0x1c(%rbp), %ecx
movzbl -0x29(%rbp), %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x7564
jmp 0x763d
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq