// File: /workspace/github_c_makefile_star2_O1/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 0x28dde
movq 0x8(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x3691f
movq %rax, 0x8(%rbx)
cmpl $0x0, (%r14)
jne 0x28e02
cmpl $0x1, (%rax)
jne 0x28e28
movl 0x148(%rax), %ecx
cmpl $0x10, %ecx
sete %dl
leal -0xb(%rcx), %esi
cmpl $-0x9, %esi
setae %sil
orb %dl, %sil
jne 0x28e5e
movq (%r15), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4acde(%rip), %r8      # 0x73aac
movq %r14, %rdi
movl $0x4c, %esi
movl $0x292, %r9d            # imm = 0x292
jmp 0x28dfd
movq (%r15), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4acbd(%rip), %r8      # 0x73aac
movq %r14, %rdi
movl $0x49, %esi
movl $0x285, %r9d            # imm = 0x285
callq 0x14618
xorl %r14d, %r14d
movq (%rbx), %rdi
callq 0x2b4c3
movq 0x8(%rbx), %rdi
callq 0x2b4c3
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 0x28f21
movl $0x148, %r12d           # imm = 0x148
addq %r12, %rdi
callq 0x14dfb
addq (%rbx), %r12
movq %r12, %rdi
callq 0x14ba1
cmpq $0x1, %rax
jne 0x28f06
xorl %edi, %edi
jmp 0x292d4
movq (%rbx), %rdi
cmpl $0x3, (%rdi)
jne 0x2924d
movl $0x148, %r13d           # imm = 0x148
addq %r13, %rdi
callq 0x14dfb
movq %rax, %r12
addq (%rbx), %r13
movq %r13, %rdi
callq 0x14ba1
decq %rax
cmpq $0x2, %rax
jae 0x29290
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 0x28ece
leaq -0x80000000(%r13), %rax
movabsq $-0x100000001, %rcx     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rcx, %rax
ja 0x292d1
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4abcc(%rip), %rax     # 0x73aac
leaq 0x4af0e(%rip), %rcx     # 0x73df5
movq %r14, %rdi
movl $0x8, %esi
movq %r12, %rdx
pushq $0x2a3                  # imm = 0x2A3
pushq %rax
callq 0x1442a
addq $0x10, %rsp
jmp 0x28e02
movq (%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x36269
movq %rax, (%rbx)
cmpl $0x0, (%r14)
jne 0x28e02
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq 0x148(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x148(%rcx), %r13
movq 0x48(%r15), %rdi
movq 0x18(%rdi), %r12
leaq 0x1(%r12), %rax
movq %rax, 0x18(%rdi)
callq 0x2d00a
movq %rax, 0x10(%rsp)
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, 0x30(%rsp)
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, 0x28(%rsp)
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, 0x40(%rsp)
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, 0x38(%rsp)
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, %rbp
movq 0x48(%r15), %rdi
movl $0x10, %ecx
movl $0x31, %esi
movq %r13, %rdx
movq %r14, %r8
callq 0x2c00f
cmpl $0x0, (%r14)
jne 0x28e02
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 0x2c0c2
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movl $0x1, %ecx
movl $0x35, %esi
movq 0x18(%rsp), %rbp
movq %rbp, %rdx
movq %r14, %r8
callq 0x2c00f
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x30(%rsp), %rcx
movq 0x10(%rsp), %r8
movq %r14, %r9
callq 0x2c0c2
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movq 0x30(%rsp), %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movl $0xa, %ecx
movl $0x39, %esi
movq %rbp, %rdx
movq %r14, %r8
callq 0x2c00f
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x28(%rsp), %rcx
movq 0x10(%rsp), %r8
movq %r14, %r9
callq 0x2c0c2
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movq 0x28(%rsp), %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
jne 0x28e02
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rcx
callq 0x33df7
cmpl $0x0, (%r14)
jne 0x28e02
movq %rax, %r12
movq 0x48(%r15), %rdi
movq 0x148(%rax), %rcx
movl $0x1d, %esi
movq 0x8(%rsp), %rdx
movq %r14, %r8
callq 0x2c1ac
movq %r12, %rdi
callq 0x2b4c3
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movl $0x45, %esi
movq (%rsp), %rdx
movq %r14, %rcx
callq 0x2c19f
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
jne 0x28e02
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq %r14, %rdx
callq 0x33b98
cmpl $0x0, (%r14)
jne 0x28e02
movq %rax, %r12
movq 0x48(%r15), %rdi
movq 0x148(%rax), %rcx
movl $0x1d, %esi
movq 0x8(%rsp), %rdx
movq %r14, %r8
callq 0x2c1ac
movq %r12, %rdi
callq 0x2b4c3
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movl $0x45, %esi
movq (%rsp), %rdx
movq %r14, %rcx
callq 0x2c19f
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
jne 0x28e02
movl $0x1f, %edi
movq %r14, %rsi
callq 0x2bb29
cmpl $0x0, (%r14)
jne 0x28e02
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x2bdd4
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x48(%r15), %rdi
movq (%rsp), %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
jne 0x28e02
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2ba99
jmp 0x292f0
cmpl $0x10, %ecx
je 0x292de
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x36269
movq %rax, 0x8(%rbx)
cmpl $0x0, (%r14)
jne 0x28e02
movq (%rbx), %rcx
movq 0x148(%rcx), %rsi
movq 0x148(%rax), %rdx
movq %r15, %rdi
movq %r14, %rcx
callq 0x33df7
jmp 0x292f0
callq 0x122b0
movq (%rax), %rax
movsbq (%r12), %rcx
xorl %r13d, %r13d
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x292d1
leaq 0x4a81e(%rip), %rsi     # 0x73acc
movq %r12, %rdi
callq 0x12160
testl %eax, %eax
je 0x292d1
leaq 0x4a80e(%rip), %rsi     # 0x73acf
movq %r12, %rdi
callq 0x12160
testl %eax, %eax
jne 0x28e93
movl %r13d, %edi
movq %r14, %rsi
callq 0x2bb29
jmp 0x292f0
movq 0x148(%rdi), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x33b98
movq %rax, %r14
jmp 0x28e05