// File: /workspace/github_c_makefile_star2_O0/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: str_to_uint32
int str_to_uint32(uint32_t* out, const char* str) {
	uint32_t value = 0;
	uint32_t digit_mult = 0;
	if (str[0] == '0') {
		if (str[1] == 'x' || str[1] == 'X') {
			digit_mult = 16;
			str += 2;
		} else if (str[1] == 'b' || str[1]== 'B') {
			digit_mult = 2;
			str += 2;
		} else if (str[1] == '\0') {
			*out = 0;
			return 1;
		} else {
			digit_mult = 8;
			str += 1;
		}
	} else {
		digit_mult = 10;
	}
	while (*str != '\0') {
		uint32_t digit_value = 0;
		if ('0' <= *str && *str <= '9') digit_value = *str - '0';
		else if ('a' <= *str && *str <= 'z') digit_value = *str - 'a' + 10;
		else if ('A' <= *str && *str <= 'Z') digit_value = *str - 'A' + 10;
		else return 0; /* 不正な文字 */
		if (digit_value >= digit_mult) return 0; /* 進数に対して大きすぎる数字 */
		if (UINT32_MAX / digit_mult < value) return 0; /* オーバーフロー */
		value *= digit_mult;
		if (UINT32_MAX - digit_value < value) return 0; /* オーバーフロー */
		value += digit_value;
		str++;
	}
	*out = value;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x6ca4
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x78, %eax
je 0x6c24
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x58, %eax
jne 0x6c39
movl $0x10, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
jmp 0x6ca2
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x62, %eax
je 0x6c53
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x42, %eax
jne 0x6c68
movl $0x2, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x18(%rbp)
jmp 0x6ca0
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x6c8b
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x6dcb
movl $0x8, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x6ca0
jmp 0x6ca2
jmp 0x6cab
movl $0xa, -0x20(%rbp)
jmp 0x6cad
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x6dbb
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x30, %eax
cmpl %ecx, %eax
jg 0x6cef
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jg 0x6cef
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
movl %eax, -0x24(%rbp)
jmp 0x6d58
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x61, %eax
cmpl %ecx, %eax
jg 0x6d1d
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7a, %eax
jg 0x6d1d
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
subl $0x61, %eax
addl $0xa, %eax
movl %eax, -0x24(%rbp)
jmp 0x6d56
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x41, %eax
cmpl %ecx, %eax
jg 0x6d4b
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5a, %eax
jg 0x6d4b
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
subl $0x41, %eax
addl $0xa, %eax
movl %eax, -0x24(%rbp)
jmp 0x6d54
movl $0x0, -0x4(%rbp)
jmp 0x6dcb
jmp 0x6d56
jmp 0x6d58
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jb 0x6d69
movl $0x0, -0x4(%rbp)
jmp 0x6dcb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %edx, %edx
divl -0x20(%rbp)
cmpl -0x1c(%rbp), %eax
jae 0x6d81
movl $0x0, -0x4(%rbp)
jmp 0x6dcb
movl -0x20(%rbp), %eax
imull -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x6da1
movl $0x0, -0x4(%rbp)
jmp 0x6dcb
movl -0x24(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x6cad
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq