// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/arch/arm32/arm_mem.c
// Function: subtilis_arm_mem_strcmp
void subtilis_arm_mem_strcmp(subtilis_ir_section_t *s,
			     subtilis_arm_section_t *arm_s,
			     subtilis_error_t *err)
{
	size_t i;
	const size_t a1_reg = 7;
	const size_t a1_len = 1;
	const size_t a2_reg = 2;
	const size_t a2_len = 3;
	const size_t size = 4;
	const size_t a1_val = 5;
	const size_t a2_val = 6;
	const size_t block_end_reg = 8;
	const size_t a1_byte_val = 9;
	const size_t a2_byte_val = 11;
	const size_t ff = 4;
	const size_t end_reg = 10;
	const size_t res = 0;
	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 block_eq_label = arm_s->label_counter++;
	size_t eq_label = arm_s->label_counter++;
	size_t start_label = arm_s->label_counter++;

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

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

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_LE, false, size,
				 a1_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_GT, false, size,
				 a2_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	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,
				 block_end_reg, end_reg, 4, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	subtilis_arm_section_add_label(arm_s, start_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, block_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 = block_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 = a1_val;
	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 = a2_val;
	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;

	for (i = 0; i < 4; i++) {
		instr = subtilis_arm_section_add_instr(
		    arm_s, SUBTILIS_ARM_INSTR_AND, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		datai = &instr->operands.data;
		datai->status = false;
		datai->ccode = SUBTILIS_ARM_CCODE_AL;
		datai->dest = a1_byte_val;
		datai->op1 = ff;
		datai->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
		datai->op2.op.shift.reg = a1_val;
		datai->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSR;
		datai->op2.op.shift.shift_reg = false;
		datai->op2.op.shift.shift.integer = i * 8;

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

		datai = &instr->operands.data;
		datai->status = false;
		datai->ccode = SUBTILIS_ARM_CCODE_AL;
		datai->dest = a2_byte_val;
		datai->op1 = ff;
		datai->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
		datai->op2.op.shift.reg = a2_val;
		datai->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSR;
		datai->op2.op.shift.shift_reg = false;
		datai->op2.op.shift.shift.integer = i * 8;

		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 = true;
		datai->ccode = SUBTILIS_ARM_CCODE_AL;
		datai->dest = res;
		datai->op1 = a1_byte_val;
		datai->op2.type = SUBTILIS_ARM_OP2_REG;
		datai->op2.op.reg = a2_byte_val;

		subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_NE, false,
					 15, 14, 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_AL;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = start_label;

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

	for (i = 0; i < 3; i++) {
		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 = a1_val;
		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 = a2_val;
		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;

		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 = true;
		datai->ccode = SUBTILIS_ARM_CCODE_AL;
		datai->dest = res;
		datai->op1 = a1_val;
		datai->op2.type = SUBTILIS_ARM_OP2_REG;
		datai->op2.op.reg = a2_val;

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

	subtilis_arm_section_add_label(arm_s, eq_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 = res;
	datai->op1 = a1_len;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = a2_len;

	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 $0x38, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq 0x10(%rsi), %r15
leaq 0x3(%r15), %rax
movq %rax, 0x10(%rsi)
movq %rdx, (%rsp)
pushq $0xd
popq %rsi
pushq $0xe
popq %rdx
pushq $0x7
popq %r8
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x4d518
cmpl $0x0, (%r14)
jne 0x5c452
pushq $0xa
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
pushq $0x3
popq %r8
movq %rbx, %rdi
movq %r14, %r9
callq 0x4d921
cmpl $0x0, (%r14)
jne 0x5c452
movq %r14, (%rsp)
pushq $0xd
popq %rdx
pushq $0x4
popq %r8
pushq $0x1
popq %r9
movq %rbx, %rdi
movl %edx, %esi
xorl %ecx, %ecx
callq 0x4d518
cmpl $0x0, (%r14)
jne 0x5c452
movq %r14, (%rsp)
pushq $0xd
popq %rsi
pushq $0xc
popq %rdx
pushq $0x4
popq %r8
pushq $0x3
popq %r9
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x4d518
cmpl $0x0, (%r14)
jne 0x5c452
pushq $0x4
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movb $0x0, 0xc(%rax)
movl $0xe, 0x8(%rax)
pushq $0xa
popq %rcx
movq %rcx, 0x10(%rax)
movq $0x7, 0x18(%rax)
andl $0x0, 0x20(%rax)
movq $0x4, 0x28(%rax)
movq %r14, 0x10(%rsp)
movq %rcx, (%rsp)
movl $0x4, 0x8(%rsp)
pushq $0x2
popq %r13
pushq $0x4
popq %rdx
pushq $0xe
popq %rcx
pushq $0x8
popq %r9
movq %rbx, %rdi
movl %r13d, %esi
xorl %r8d, %r8d
callq 0x4ced7
cmpl $0x0, (%r14)
jne 0x5c452
movq %r14, 0x8(%rsp)
movl $0xff, (%rsp)
pushq $0xd
popq %rsi
pushq $0xf
popq %rdx
pushq $0xe
popq %rcx
pushq $0x4
popq %r12
movq %rbx, %rdi
xorl %r8d, %r8d
movq %r12, %r9
callq 0x4d213
cmpl $0x0, (%r14)
jne 0x5c452
leaq 0x2(%r15), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x4c77f
cmpl $0x0, (%r14)
jne 0x5c452
pushq $0xa
popq %rsi
pushq $0xe
popq %rdx
pushq $0x7
popq %rcx
pushq $0x8
popq %r8
movq %rbx, %rdi
movq %r14, %r9
callq 0x4d921
cmpl $0x0, (%r14)
jne 0x5c452
pushq $0x16
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movl $0xc, 0x8(%rax)
movb $0x0, 0xc(%rax)
andl $0x0, 0x10(%rax)
movq %r15, 0x18(%rax)
pushq $0x12
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movl $0xe, 0x8(%rax)
movq $0x5, 0x10(%rax)
movq $0x7, 0x18(%rax)
movl $0x1, 0x20(%rax)
movl $0x4, 0x28(%rax)
movl $0x100, 0x48(%rax)      # imm = 0x100
pushq $0x12
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
je 0x5c461
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1(%r15), %rcx
movq %rcx, 0x20(%rsp)
movl $0xe, 0x8(%rax)
movq $0x6, 0x10(%rax)
movq $0x2, 0x18(%rax)
movl $0x1, 0x20(%rax)
movl $0x4, 0x28(%rax)
movl $0x100, 0x48(%rax)      # imm = 0x100
xorl %eax, %eax
movq %rax, 0x28(%rsp)
addq $0x8, %rax
movq %rax, 0x30(%rsp)
cmpq $0x28, %rax
je 0x5c5b4
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
xorl %ecx, %ecx
movb %cl, 0xc(%rax)
movl $0xe, 0x8(%rax)
movq $0x9, 0x10(%rax)
movq $0x4, 0x18(%rax)
movl %r13d, 0x20(%rax)
movq $0x5, 0x28(%rax)
movl %r13d, 0x30(%rax)
movb %cl, 0x40(%rax)
movq 0x28(%rsp), %rcx
movl %ecx, 0x38(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
xorl %ecx, %ecx
movb %cl, 0xc(%rax)
movl $0xe, 0x8(%rax)
movq $0xb, 0x10(%rax)
movq $0x4, 0x18(%rax)
movl %r13d, 0x20(%rax)
movq $0x6, 0x28(%rax)
movl %r13d, 0x30(%rax)
movb %cl, 0x40(%rax)
movq 0x28(%rsp), %rcx
movl %ecx, 0x38(%rax)
movq %rbx, %rdi
movl %r13d, %esi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movb $0x1, 0xc(%rax)
movl $0xe, 0x8(%rax)
andq $0x0, 0x10(%rax)
movq $0x9, 0x18(%rax)
andl $0x0, 0x20(%rax)
movq $0xb, 0x28(%rax)
movq %r14, (%rsp)
movq %rbx, %rdi
pushq $0xd
popq %rsi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
pushq $0xf
popq %r8
pushq $0xe
popq %r9
callq 0x4d518
cmpl $0x0, (%r14)
movq 0x30(%rsp), %rax
je 0x5c498
jmp 0x5c452
pushq $0x16
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
andl $0x0, 0x10(%rax)
movq %rbp, 0x18(%rax)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4c77f
cmpl $0x0, (%r14)
jne 0x5c452
pushq $0x7
popq %r13
pushq $0xa
popq %rbp
pushq $0x12
popq %r15
movq %rbx, %rdi
decq %r12
je 0x5c741
pushq $0xa
popq %rsi
pushq $0xe
popq %rdx
movq %r13, %rcx
movq %rbp, %r8
movq %r14, %r9
callq 0x4d921
cmpl $0x0, (%r14)
jne 0x5c452
movq %rbx, %rdi
pushq $0x16
popq %rsi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movl $0xa, 0x8(%rax)
movb $0x0, 0xc(%rax)
andl $0x0, 0x10(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movl $0xe, 0x8(%rax)
movq $0x5, 0x10(%rax)
movq $0x7, 0x18(%rax)
pushq $0x1
popq %rcx
movl %ecx, 0x20(%rax)
movl %ecx, 0x28(%rax)
movl $0x1000100, 0x48(%rax)  # imm = 0x1000100
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movl $0xe, 0x8(%rax)
movq $0x6, 0x10(%rax)
movq $0x2, 0x18(%rax)
pushq $0x1
popq %rcx
movl %ecx, 0x20(%rax)
movl %ecx, 0x28(%rax)
movl $0x1000100, 0x48(%rax)  # imm = 0x1000100
movq %rbx, %rdi
pushq $0x2
popq %rsi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movb $0x1, 0xc(%rax)
movl $0xe, 0x8(%rax)
andq $0x0, 0x10(%rax)
movq $0x5, 0x18(%rax)
andl $0x0, 0x20(%rax)
movq $0x6, 0x28(%rax)
movq %r14, (%rsp)
movq %rbx, %rdi
pushq $0xd
popq %rsi
pushq $0x1
popq %rdx
xorl %ecx, %ecx
pushq $0xf
popq %r8
pushq $0xe
popq %r9
callq 0x4d518
cmpl $0x0, (%r14)
je 0x5c602
jmp 0x5c452
movq 0x20(%rsp), %rsi
movq %r14, %rdx
callq 0x4c77f
cmpl $0x0, (%r14)
jne 0x5c452
pushq $0x2
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4c92b
cmpl $0x0, (%r14)
jne 0x5c452
movb $0x0, 0xc(%rax)
movl $0xe, 0x8(%rax)
andq $0x0, 0x10(%rax)
movq $0x1, 0x18(%rax)
andl $0x0, 0x20(%rax)
movq $0x3, 0x28(%rax)
movq %r14, (%rsp)
pushq $0xd
popq %rsi
pushq $0xe
popq %rdx
pushq $0xf
popq %r8
pushq $0xe
popq %r9
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x4d518
jmp 0x5c452
nopl (%rax)