// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/arch/arm32/arm_mem.c
// Function: subtilis_arm_mem_memcmp
void subtilis_arm_mem_memcmp(subtilis_ir_section_t *s,
			     subtilis_arm_section_t *arm_s,
			     subtilis_error_t *err)
{
	size_t i;
	const size_t a1_reg = 0;
	const size_t a2_reg = 1;
	const size_t size = 2;
	const size_t stm_end_reg = 10;
	const size_t end_reg = 11;
	const size_t words_reg = 9;
	subtilis_arm_instr_t *instr;
	subtilis_arm_stran_instr_t *stran;
	subtilis_arm_br_instr_t *br;
	subtilis_arm_data_instr_t *datai;
	size_t eq_label = arm_s->label_counter++;
	size_t not_eq_label = arm_s->label_counter++;
	size_t start_label = arm_s->label_counter++;
	size_t start_small_label = arm_s->label_counter++;
	size_t start_tiny_label = arm_s->label_counter++;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_ADD, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	datai = &instr->operands.data;
	datai->status = false;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->dest = end_reg;
	datai->op1 = a1_reg;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = size;

	subtilis_arm_add_sub_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false,
				 stm_end_reg, end_reg, 16, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
			     SUBTILIS_ARM_CCODE_AL, a1_reg, stm_end_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_GT;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = start_small_label;

	subtilis_arm_section_add_label(arm_s, start_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mtran(arm_s, SUBTILIS_ARM_INSTR_LDM,
			       SUBTILIS_ARM_CCODE_AL, a1_reg, 0x3c,
			       SUBTILIS_ARM_MTRAN_IA, true, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mtran(arm_s, SUBTILIS_ARM_INSTR_LDM,
			       SUBTILIS_ARM_CCODE_AL, a2_reg, 0x3c0,
			       SUBTILIS_ARM_MTRAN_IA, true, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	for (i = 0; i < 4; i++) {
		subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
				     SUBTILIS_ARM_CCODE_AL, 2 + i, 6 + i, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		instr = subtilis_arm_section_add_instr(
		    arm_s, SUBTILIS_ARM_INSTR_B, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		br = &instr->operands.br;
		br->ccode = SUBTILIS_ARM_CCODE_NE;
		br->link = false;
		br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
		br->target.label = not_eq_label;
	}

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
			     SUBTILIS_ARM_CCODE_AL, a1_reg, stm_end_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_LT;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = start_label;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, words_reg,
				 end_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_section_add_label(arm_s, start_small_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_SUB, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	datai = &instr->operands.data;
	datai->status = false;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->dest = words_reg;
	datai->op1 = words_reg;
	datai->op2.type = SUBTILIS_ARM_OP2_I32;
	datai->op2.op.integer = 4;

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
			     SUBTILIS_ARM_CCODE_AL, a1_reg, words_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_GE;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = start_tiny_label;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_LDR, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	stran = &instr->operands.stran;
	stran->ccode = SUBTILIS_ARM_CCODE_AL;
	stran->dest = 2;
	stran->base = a1_reg;
	stran->offset.type = SUBTILIS_ARM_OP2_I32;
	stran->offset.op.integer = 4;
	stran->pre_indexed = false;
	stran->write_back = true;
	stran->subtract = false;
	stran->byte = false;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_LDR, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	stran = &instr->operands.stran;
	stran->ccode = SUBTILIS_ARM_CCODE_AL;
	stran->dest = 6;
	stran->base = a2_reg;
	stran->offset.type = SUBTILIS_ARM_OP2_I32;
	stran->offset.op.integer = 4;
	stran->pre_indexed = false;
	stran->write_back = true;
	stran->subtract = false;
	stran->byte = false;

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
			     SUBTILIS_ARM_CCODE_AL, 2, 6, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_NE;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = not_eq_label;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_AL;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = start_small_label;

	subtilis_arm_section_add_label(arm_s, start_tiny_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
			     SUBTILIS_ARM_CCODE_AL, a1_reg, end_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_GE;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = eq_label;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_LDR, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	stran = &instr->operands.stran;
	stran->ccode = SUBTILIS_ARM_CCODE_AL;
	stran->dest = 2;
	stran->base = a1_reg;
	stran->offset.type = SUBTILIS_ARM_OP2_I32;
	stran->offset.op.integer = 1;
	stran->pre_indexed = false;
	stran->write_back = true;
	stran->subtract = false;
	stran->byte = true;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_LDR, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	stran = &instr->operands.stran;
	stran->ccode = SUBTILIS_ARM_CCODE_AL;
	stran->dest = 6;
	stran->base = a2_reg;
	stran->offset.type = SUBTILIS_ARM_OP2_I32;
	stran->offset.op.integer = 1;
	stran->pre_indexed = false;
	stran->write_back = true;
	stran->subtract = false;
	stran->byte = true;

	subtilis_arm_add_cmp(arm_s, SUBTILIS_ARM_INSTR_CMP,
			     SUBTILIS_ARM_CCODE_AL, 2, 6, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_NE;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = not_eq_label;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_AL;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = start_tiny_label;

	subtilis_arm_section_add_label(arm_s, eq_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mvn_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, 0,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 15, 14,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_section_add_label(arm_s, not_eq_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, 0,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 15, 14,
				 err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq 0x10(%rsi), %r15
leaq 0x5(%r15), %rax
movq %rax, 0x10(%rsi)
movq %rsi, %rdi
movl $0x4, %esi
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movb $0x0, 0xc(%rax)
movl $0xe, 0x8(%rax)
movl $0xb, %r10d
movq %r10, 0x10(%rax)
movq $0x0, 0x18(%rax)
movl $0x0, 0x20(%rax)
movq $0x2, 0x28(%rax)
subq $0x8, %rsp
movl $0xa, %r9d
movq %r14, %rdi
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
pushq %rbx
pushq $0x10
pushq %r10
callq 0x4fd3f
addq $0x20, %rsp
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xa, %r8d
movq %r14, %rdi
movl $0xa, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rbx, %r9
callq 0x5099c
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
leaq 0x2(%r15), %r13
leaq 0x3(%r15), %rbp
movl $0xc, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq %rbp, 0x18(%rax)
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x4f530
cmpl $0x0, (%rbx)
jne 0x600fe
subq $0x8, %rsp
movl $0x3c, %r8d
movq %r14, %rdi
movl $0x14, %esi
movl $0xe, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
pushq %rbx
pushq $0x0
pushq $0x1
callq 0x509ef
addq $0x20, %rsp
cmpl $0x0, (%rbx)
jne 0x600fe
subq $0x8, %rsp
movl $0x1, %ecx
movl $0x3c0, %r8d            # imm = 0x3C0
movq %r14, %rdi
movl $0x14, %esi
movl $0xe, %edx
xorl %r9d, %r9d
pushq %rbx
pushq $0x0
pushq $0x1
callq 0x509ef
addq $0x20, %rsp
cmpl $0x0, (%rbx)
je 0x6010d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1(%r15), %rax
movq %rax, 0x8(%rsp)
leaq 0x4(%r15), %rax
movq %rax, 0x10(%rsp)
movl $0x2, %r12d
leaq 0x4(%r12), %r8
movq %r14, %rdi
movl $0xa, %esi
movl $0xe, %edx
movq %r12, %rcx
movq %rbx, %r9
callq 0x5099c
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0x1, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x18(%rax)
incq %r12
cmpq $0x6, %r12
jne 0x60125
movl $0xa, %r8d
movq %r14, %rdi
movl $0xa, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rbx, %r9
callq 0x5099c
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xb, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq %r13, 0x18(%rax)
subq $0x8, %rsp
movl $0x9, %r8d
movl $0xb, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x4f530
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x2, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movb $0x0, 0xc(%rax)
movl $0xe, 0x8(%rax)
movl $0x9, %ecx
movq %rcx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movl $0x1, 0x20(%rax)
movl $0x4, 0x28(%rax)
movl $0x9, %r8d
movq %r14, %rdi
movl $0xa, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rbx, %r9
callq 0x5099c
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xa, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %r14, %rdi
movl $0x12, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xe, 0x8(%rax)
movq $0x2, 0x10(%rax)
movq $0x0, 0x18(%rax)
movl $0x1, 0x20(%rax)
movl $0x4, 0x28(%rax)
movl $0x100, 0x48(%rax)      # imm = 0x100
movq %r14, %rdi
movl $0x12, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xe, 0x8(%rax)
movq $0x6, 0x10(%rax)
movq $0x1, 0x18(%rax)
movl $0x1, 0x20(%rax)
movl $0x4, 0x28(%rax)
movl $0x100, 0x48(%rax)      # imm = 0x100
movl $0x2, %ecx
movl $0x6, %r8d
movq %r14, %rdi
movl $0xa, %esi
movl $0xe, %edx
movq %rbx, %r9
callq 0x5099c
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0x1, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq %rbp, 0x18(%rax)
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x4f530
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xb, %r8d
movq %r14, %rdi
movl $0xa, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rbx, %r9
callq 0x5099c
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xa, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq %r15, 0x18(%rax)
movq %r14, %rdi
movl $0x12, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xe, 0x8(%rax)
movq $0x2, 0x10(%rax)
movq $0x0, 0x18(%rax)
movl $0x1, %ebp
movl %ebp, 0x20(%rax)
movl %ebp, 0x28(%rax)
movl $0x1000100, 0x48(%rax)  # imm = 0x1000100
movq %r14, %rdi
movl $0x12, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xe, 0x8(%rax)
movq $0x6, 0x10(%rax)
movq $0x1, 0x18(%rax)
movl %ebp, 0x20(%rax)
movl %ebp, 0x28(%rax)
movl $0x1000100, 0x48(%rax)  # imm = 0x1000100
movl $0x2, %ecx
movl $0x6, %r8d
movq %r14, %rdi
movl $0xa, %esi
movl $0xe, %edx
movq %rbx, %r9
callq 0x5099c
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0x1, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %r14, %rdi
movl $0x16, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x600fe
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4f530
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0xf, %esi
movl $0xd, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x0
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x600fe
subq $0x8, %rsp
movl $0xf, %r8d
movl $0xe, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x4f530
cmpl $0x0, (%rbx)
jne 0x600fe
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x0
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x600fe
subq $0x8, %rsp
movl $0xf, %r8d
movl $0xe, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
pushq %rbx
callq 0x504b3
addq $0x28, %rsp
jmp 0x60102