// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: prv_find_first_stop_prolog
static size_t prv_find_first_stop_prolog(subtilis_parser_t *p,
					 subtilis_ir_operand_t str_data,
					 subtilis_ir_operand_t str_len,
					 subtilis_ir_operand_t max_digit,
					 bool immediate_digit,
					 subtilis_ir_operand_t end_str,
					 subtilis_ir_operand_t *byte,
					 subtilis_ir_operand_t skip_sign_label,
					 subtilis_ir_operand_t first_end_label,
					 subtilis_ir_operand_t end_label,
					 subtilis_ir_operand_t *minus,
					 subtilis_ir_operand_t *loop_cond,
					 subtilis_error_t *err)
/* clang-format on */

{
	subtilis_ir_operand_t ptr;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t le_9;
	subtilis_ir_operand_t have_sign_label;
	subtilis_ir_operand_t check_for_minus_label;
	subtilis_ir_operand_t negative_label;
	subtilis_ir_operand_t whole_number_start_label;
	subtilis_ir_operand_t keep_looking_label;
	subtilis_ir_operand_t condee;

	check_for_minus_label.label = subtilis_ir_section_new_label(p->current);
	negative_label.label = subtilis_ir_section_new_label(p->current);
	have_sign_label.label = subtilis_ir_section_new_label(p->current);
	whole_number_start_label.label =
	    subtilis_ir_section_new_label(p->current);
	keep_looking_label.label = subtilis_ir_section_new_label(p->current);

	ptr.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOV, str_data, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = 1;
	minus->reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = 0;
	byte->reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I8, ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = '+';
	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_NEQI_I32, *byte, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, check_for_minus_label,
					  have_sign_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_label(p->current, check_for_minus_label.label,
				      err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = '-';
	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_EQI_I32, *byte, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, negative_label,
					  whole_number_start_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_label(p->current, negative_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = 0;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_RSUBI_I32, *minus, *minus, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_label(p->current, have_sign_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = 1;
	subtilis_ir_section_add_instr_reg(p->current,
					  SUBTILIS_OP_INSTR_ADDI_I32, str_data,
					  str_data, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_label(p->current, skip_sign_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = 1;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, ptr, ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LT_I32, ptr, end_str, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, keep_looking_label,
					  first_end_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_label(p->current, keep_looking_label.label,
				      err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = 0;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I8, *byte, ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	subtilis_ir_section_add_label(p->current,
				      whole_number_start_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	op1.integer = '0';
	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LTI_I32, *byte, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	le_9.reg = subtilis_ir_section_add_instr(
	    p->current, immediate_digit ? SUBTILIS_OP_INSTR_GTI_I32
					: SUBTILIS_OP_INSTR_GT_I32,
	    *byte, max_digit, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	loop_cond->reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_OR_I32, condee, le_9, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	return ptr.reg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x50(%rsp)
movq %r8, 0x38(%rsp)
movl %ecx, 0x14(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
movq 0xb0(%rsp), %r12
movq 0x48(%rdi), %rdi
callq 0x2b774
movq %rax, 0x48(%rsp)
movq 0x48(%r15), %rdi
callq 0x2b774
movq %rax, 0x40(%rsp)
movq 0x48(%r15), %rdi
callq 0x2b774
movq %rax, %r13
movq 0x48(%r15), %rdi
callq 0x2b774
movq %rax, %rbp
movq 0x48(%r15), %rdi
callq 0x2b774
movq %rax, %r14
movq %r15, (%rsp)
movq 0x48(%r15), %rdi
pushq $0x1d
popq %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2a981
pushq $-0x1
popq %rcx
cmpl $0x0, (%r12)
jne 0x339ec
movq 0x48(%rsp), %r15
movq %rbx, 0x28(%rsp)
movq %r14, 0x18(%rsp)
movq %rbp, 0x20(%rsp)
movq %rax, 0x8(%rsp)
movq 0x50(%rsp), %rbp
movq 0xa0(%rsp), %r14
movq (%rsp), %rbx
movq 0x48(%rbx), %rdi
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
movq 0xb0(%rsp), %r12
movq %r12, %rcx
callq 0x2a981
movq %rax, (%r14)
cmpl $0x0, (%r12)
jne 0x339e9
movq 0x48(%rbx), %rdi
pushq $0x11
popq %rsi
movq 0x8(%rsp), %rdx
xorl %ecx, %ecx
movq 0xb0(%rsp), %r12
movq %r12, %r8
callq 0x2a819
movq %rax, (%rbp)
cmpl $0x0, (%r12)
jne 0x339e9
movq %rbp, %r14
movq 0x48(%rbx), %rdi
pushq $0x31
popq %rsi
pushq $0x2b
popq %rcx
movq %rax, %rdx
movq 0xb0(%rsp), %r12
movq %r12, %r8
callq 0x2a819
cmpl $0x0, (%r12)
jne 0x339e9
movq 0x48(%rbx), %rdi
pushq $0x43
popq %rsi
movq %rax, %rdx
movq %r15, %rcx
movq %r13, %r8
movq 0xb0(%rsp), %r12
movq %r12, %r9
callq 0x2a8c1
cmpl $0x0, (%r12)
jne 0x339e9
movq 0x48(%rbx), %rdi
movq %r15, %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq (%r14), %rdx
pushq $0x2d
popq %rsi
pushq $0x2d
popq %rcx
movq 0xb0(%rsp), %rbx
movq %rbx, %r8
callq 0x2a819
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rcx
movq 0x48(%rcx), %rdi
pushq $0x43
popq %rsi
movq %rax, %rdx
movq 0x40(%rsp), %r14
movq %r14, %rcx
movq 0x20(%rsp), %r8
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq %r14, %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xa0(%rsp), %rax
movq (%rax), %rcx
pushq $0x21
popq %rsi
movq %rcx, %rdx
xorl %r8d, %r8d
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq %r13, %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
pushq $0x9
popq %rsi
pushq $0x1
popq %r8
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x339e9
movq 0x90(%rsp), %rsi
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
pushq $0x9
popq %rsi
pushq $0x1
popq %r8
movq 0x8(%rsp), %rcx
movq %rcx, %rdx
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
pushq $0x3b
popq %rsi
movq 0x8(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq 0xb0(%rsp), %rbx
movq %rbx, %r8
callq 0x2a819
cmpl $0x0, (%rbx)
jne 0x339e9
movq 0x98(%rsp), %r8
movq (%rsp), %rcx
movq 0x48(%rcx), %rdi
pushq $0x43
popq %rsi
movq %rax, %rdx
movq 0x18(%rsp), %rcx
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rsp), %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq (%rbp), %rdx
pushq $0x11
popq %rsi
movq 0x8(%rsp), %rcx
xorl %r8d, %r8d
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rsp), %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x339e9
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq (%rbp), %rdx
pushq $0x3d
popq %rsi
pushq $0x30
popq %rcx
movq 0xb0(%rsp), %r12
movq %r12, %r8
callq 0x2a819
cmpl $0x0, (%r12)
je 0x339fe
pushq $-0x1
popq %rcx
movq %rcx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movzbl 0x14(%rsp), %eax
leal 0x33(,%rax,2), %esi
movq (%rbp), %rdx
movq 0x30(%rsp), %rcx
movq 0xb0(%rsp), %r14
movq %r14, %r8
callq 0x2a819
cmpl $0x0, (%r14)
pushq $-0x1
popq %rcx
jne 0x339ec
movq 0xa8(%rsp), %r12
movq (%rsp), %rcx
movq 0x48(%rcx), %rdi
pushq $0x26
popq %rsi
movq %rbx, %rdx
movq %rax, %rcx
movq 0xb0(%rsp), %rbx
movq %rbx, %r8
callq 0x2a819
movq %rax, (%r12)
xorl %ecx, %ecx
cmpl (%rbx), %ecx
sbbq %rcx, %rcx
orq 0x8(%rsp), %rcx
jmp 0x339ec
nopl (%rax)