// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x3, (%rax)
je 0x3393d
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x7, (%rax)
je 0x3393d
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %ecx
movl $0x49, %esi
leaq 0x771e3(%rip), %r8      # 0xaab10
movl $0x285, %r9d            # imm = 0x285
callq 0x15930
jmp 0x33c7a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x488b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3396b
jmp 0x33c7a
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1, (%rax)
jne 0x33bc9
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x10, 0x148(%rax)
je 0x339e4
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x2, 0x148(%rax)
jl 0x339af
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xa, 0x148(%rax)
jle 0x339e4
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %ecx
movl $0x4c, %esi
leaq 0x7713c(%rip), %r8      # 0xaab10
movl $0x292, %r9d            # imm = 0x292
callq 0x15930
jmp 0x33c7a
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x3, (%rax)
jne 0x33b2a
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x16760
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x16270
subq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpq $0x2, -0x30(%rbp)
jb 0x33a8a
callq 0x12280
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x33b15
movq -0x28(%rbp), %rdi
leaq 0x770cd(%rip), %rsi     # 0xaab30
callq 0x12140
cmpl $0x0, %eax
je 0x33b15
movq -0x28(%rbp), %rdi
leaq 0x770b7(%rip), %rsi     # 0xaab33
callq 0x12140
cmpl $0x0, %eax
je 0x33b15
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x148(%rax), %edx
xorl %eax, %eax
movl %eax, %esi
callq 0x12180
movq %rax, -0x40(%rbp)
callq 0x12030
cmpl $0x22, (%rax)
je 0x33ac7
cmpq $-0x80000000, -0x40(%rbp) # imm = 0x80000000
jl 0x33ac7
cmpq $0x7fffffff, -0x40(%rbp) # imm = 0x7FFFFFFF
jle 0x33b0e
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x8, %esi
leaq 0x77785(%rip), %rcx     # 0xab276
leaq 0x77018(%rip), %rax     # 0xaab10
movq %rax, (%rsp)
movl $0x2a3, 0x8(%rsp)       # imm = 0x2A3
callq 0x156d0
jmp 0x33c7a
movq -0x40(%rbp), %rax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
movq -0x20(%rbp), %rsi
callq 0x37800
movq %rax, -0x50(%rbp)
jmp 0x33c7a
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x10, 0x148(%rax)
sete %al
andb $0x1, %al
movb %al, -0x41(%rbp)
testb $0x1, -0x41(%rbp)
je 0x33b68
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x148(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x44050
movq %rax, -0x50(%rbp)
jmp 0x33bc4
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x47c10
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x33b96
jmp 0x33c7a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x148(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x148(%rax), %rdx
movq -0x20(%rbp), %rcx
callq 0x44420
movq %rax, -0x50(%rbp)
jmp 0x33c78
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x3, (%rax)
jne 0x33c4a
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x16760
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x16270
subq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x33c1f
movq -0x20(%rbp), %rsi
xorl %edi, %edi
callq 0x37800
movq %rax, -0x50(%rbp)
jmp 0x33c7a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x47c10
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x33c48
jmp 0x33c7a
jmp 0x33c4a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x148(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x148(%rax), %rdx
movq -0x20(%rbp), %rcx
callq 0x33ca0
movq %rax, -0x50(%rbp)
jmp 0x33c7a
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x36ee0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x36ee0
movq -0x50(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)