// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/frontend/parser_string.c
// Function: prv_val_int
static subtilis_exp_t *prv_val_int(subtilis_parser_t *p, subtilis_token_t *t,
				   subtilis_exp_t **e, subtilis_error_t *err)
{
	const char *str;
	size_t str_size;
	int32_t retval;
	long val;
	bool hex;
	subtilis_exp_t *res = NULL;

	if (e[0]->type.type != SUBTILIS_TYPE_CONST_STRING &&
	    e[0]->type.type != SUBTILIS_TYPE_STRING) {
		subtilis_error_set_string_expected(err, p->l->stream->name,
						   p->l->line);
		goto cleanup;
	}

	e[1] = subtilis_type_if_to_int(p, e[1], err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (e[1]->type.type == SUBTILIS_TYPE_CONST_INTEGER) {
		if ((e[1]->exp.ir_op.integer != 16) &&
		    (e[1]->exp.ir_op.integer < 2 ||
		     e[1]->exp.ir_op.integer > 10)) {
			subtilis_error_set_bad_val_arg(err, p->l->stream->name,
						       p->l->line);
			goto cleanup;
		}

		retval = 0;
		if (e[0]->type.type == SUBTILIS_TYPE_CONST_STRING) {
			str = subtilis_buffer_get_string(&e[0]->exp.str);
			str_size = subtilis_buffer_get_size(&e[0]->exp.str) - 1;
			if (str_size < 2 ||
			    (!isspace(str[0]) && strcmp(str, "0x") &&
			     strcmp(str, "0X"))) {
				val =
				    strtol(str, NULL, e[1]->exp.ir_op.integer);
				if (errno == ERANGE || val < INT32_MIN ||
				    val > INT32_MAX) {
					subtilis_error_set_number_too_long(
					    err, str, p->l->stream->name,
					    p->l->line);
					goto cleanup;
				}
				retval = (int32_t)val;
			}
			res = subtilis_exp_new_int32(retval, err);
			goto cleanup;
		}

		hex = e[1]->exp.ir_op.integer == 16;

		if (hex) {
			res = subtilis_builtin_ir_call_hexstr_to_int32(
			    p, e[0]->exp.ir_op.reg, err);
		} else {
			e[1] = subtilis_type_if_exp_to_var(p, e[1], err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
			res = subtilis_builtin_ir_call_str_to_int32(
			    p, e[0]->exp.ir_op.reg, e[1]->exp.ir_op.reg, err);
		}
	} else {
		if (e[0]->type.type == SUBTILIS_TYPE_CONST_STRING) {
			str = subtilis_buffer_get_string(&e[0]->exp.str);
			str_size = subtilis_buffer_get_size(&e[0]->exp.str) - 1;
			if (str_size == 0) {
				res = subtilis_exp_new_int32(0, err);
				goto cleanup;
			}
			e[0] = subtilis_type_if_exp_to_var(p, e[0], err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
		}
		res = prv_call_val_int(p, e[0]->exp.ir_op.reg,
				       e[1]->exp.ir_op.reg, err);
	}

cleanup:

	subtilis_exp_delete(e[0]);
	subtilis_exp_delete(e[1]);

	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq (%rsi), %rax
movl (%rax), %eax
orl $0x4, %eax
cmpl $0x7, %eax
jne 0x28b6c
movq 0x8(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x367cf
movq %rax, 0x8(%rbx)
cmpl $0x0, (%r14)
jne 0x28b90
cmpl $0x1, (%rax)
jne 0x28bb6
movl 0x148(%rax), %ecx
cmpl $0x10, %ecx
jne 0x28be4
movq (%rbx), %rdi
cmpl $0x3, (%rdi)
je 0x28f67
movq 0x148(%rdi), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x339f2
jmp 0x2904d
movq (%r15), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4af4d(%rip), %r8      # 0x73aca
movq %r14, %rdi
movl $0x49, %esi
movl $0x285, %r9d            # imm = 0x285
callq 0x145c8
xorl %r14d, %r14d
movq (%rbx), %rdi
callq 0x2b166
movq 0x8(%rbx), %rdi
callq 0x2b166
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rdi
cmpl $0x3, (%rdi)
jne 0x28c36
movl $0x148, %r12d           # imm = 0x148
addq %r12, %rdi
callq 0x14db1
addq (%rbx), %r12
movq %r12, %rdi
callq 0x14b57
cmpq $0x1, %rax
jne 0x28c14
xorl %edi, %edi
jmp 0x29045
addl $-0xb, %ecx
cmpl $-0xa, %ecx
ja 0x28f5b
movq (%r15), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4aec9(%rip), %r8      # 0x73aca
movq %r14, %rdi
movl $0x4c, %esi
movl $0x292, %r9d            # imm = 0x292
jmp 0x28b8b
movq (%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x36119
movq %rax, (%rbx)
cmpl $0x0, (%r14)
jne 0x28b90
movq %rax, %rdi
movq 0x8(%rbx), %rax
movq 0x148(%rdi), %rcx
movq %rcx, 0x20(%rsp)
movq 0x148(%rax), %r13
movq 0x48(%r15), %rdi
movq 0x18(%rdi), %r12
leaq 0x1(%r12), %rax
movq %rax, 0x18(%rdi)
callq 0x2cc99
movq %rax, 0x10(%rsp)
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, 0x30(%rsp)
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, 0x28(%rsp)
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, 0x40(%rsp)
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, 0x38(%rsp)
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %rbp
movq 0x48(%r15), %rdi
movl $0x10, %ecx
movl $0x31, %esi
movq %r13, %rdx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x28b90
movq %r13, 0x18(%rsp)
movq %rbp, (%rsp)
movq %r12, 0x8(%rsp)
movq 0x48(%r15), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x38(%rsp), %r12
movq %r12, %rcx
movq 0x40(%rsp), %r13
movq %r13, %r8
movq %r14, %r9
callq 0x2bd42
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movl $0x1, %ecx
movl $0x35, %esi
movq 0x18(%rsp), %rbp
movq %rbp, %rdx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x30(%rsp), %rcx
movq 0x10(%rsp), %r8
movq %r14, %r9
callq 0x2bd42
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movq 0x30(%rsp), %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movl $0xa, %ecx
movl $0x39, %esi
movq %rbp, %rdx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x28(%rsp), %rcx
movq 0x10(%rsp), %r8
movq %r14, %r9
callq 0x2bd42
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movq 0x28(%rsp), %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x28b90
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rcx
callq 0x33c59
cmpl $0x0, (%r14)
jne 0x28b90
movq %rax, %r12
movq 0x48(%r15), %rdi
movq 0x148(%rax), %rcx
movl $0x1d, %esi
movq 0x8(%rsp), %rdx
movq %r14, %r8
callq 0x2be2c
movq %r12, %rdi
callq 0x2b166
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movl $0x45, %esi
movq (%rsp), %rdx
movq %r14, %rcx
callq 0x2be1f
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x28b90
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq %r14, %rdx
callq 0x339f2
cmpl $0x0, (%r14)
jne 0x28b90
movq %rax, %r12
movq 0x48(%r15), %rdi
movq 0x148(%rax), %rcx
movl $0x1d, %esi
movq 0x8(%rsp), %rdx
movq %r14, %r8
callq 0x2be2c
movq %r12, %rdi
callq 0x2b166
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movl $0x45, %esi
movq (%rsp), %rdx
movq %r14, %rcx
callq 0x2be1f
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x28b90
movl $0x1f, %edi
movq %r14, %rsi
callq 0x2b7af
cmpl $0x0, (%r14)
jne 0x28b90
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x2ba50
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x48(%r15), %rdi
movq (%rsp), %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x28b90
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2b71f
jmp 0x2904d
movq (%rbx), %rdi
cmpl $0x3, (%rdi)
jne 0x29055
movl $0x148, %r13d           # imm = 0x148
addq %r13, %rdi
callq 0x14db1
movq %rax, %r12
addq (%rbx), %r13
movq %r13, %rdi
callq 0x14b57
decq %rax
cmpq $0x2, %rax
jae 0x28ffb
movq 0x8(%rbx), %rax
movl 0x148(%rax), %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x121a0
movq %rax, %r13
callq 0x12040
cmpl $0x22, (%rax)
je 0x28fc3
leaq -0x80000000(%r13), %rax
movabsq $-0x100000001, %rcx     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rcx, %rax
ja 0x29042
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4aaf5(%rip), %rax     # 0x73aca
leaq 0x4ae39(%rip), %rcx     # 0x73e15
movq %r14, %rdi
movl $0x8, %esi
movq %r12, %rdx
pushq $0x2a3                  # imm = 0x2A3
pushq %rax
callq 0x143da
addq $0x10, %rsp
jmp 0x28b90
callq 0x122b0
movq (%rax), %rcx
movsbq (%r12), %rax
xorl %r13d, %r13d
testb $0x20, 0x1(%rcx,%rax,2)
jne 0x29042
cmpb $0x30, %al
jne 0x28f8c
cmpb $0x78, 0x1(%r12)
jne 0x2902a
cmpb $0x0, 0x2(%r12)
je 0x29042
cmpb $0x58, 0x1(%r12)
jne 0x28f8c
cmpb $0x0, 0x2(%r12)
jne 0x28f8c
movl %r13d, %edi
movq %r14, %rsi
callq 0x2b7af
movq %rax, %r14
jmp 0x28b93
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x36119
movq %rax, 0x8(%rbx)
cmpl $0x0, (%r14)
jne 0x28b90
movq (%rbx), %rcx
movq 0x148(%rcx), %rsi
movq 0x148(%rax), %rdx
movq %r15, %rdi
movq %r14, %rcx
callq 0x33c59
jmp 0x2904d
nop