// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/rec_type.c
// Function: subtilis_rec_type_swap
void subtilis_rec_type_swap(subtilis_parser_t *p, const subtilis_type_t *type,
			    size_t reg1, size_t reg2, subtilis_error_t *err)
{
	subtilis_ir_operand_t ptr1;
	subtilis_ir_operand_t ptr2;
	size_t offset;
	size_t i;
	size_t size = subtilis_type_rec_size(type);

	offset = size - (size & 3);
	if (size >= 4) {
		ptr1.reg = reg1;
		ptr2.reg = reg2;
		reg1 = subtilis_ir_section_add_instr2(
		    p->current, SUBTILIS_OP_INSTR_MOV, ptr1, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		reg2 = subtilis_ir_section_add_instr2(
		    p->current, SUBTILIS_OP_INSTR_MOV, ptr2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		prv_rec_swap_32(p, offset, reg1, reg2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	i = 0;
	for (; offset < size; offset++, i++) {
		subtilis_exp_swap_int8_mem(p, reg1, reg2, i, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, (%rsp)
movq %rdx, %r12
movq %rdi, %r14
movq %rsi, %rdi
callq 0x2e586
movq %rax, %r15
cmpq $0x4, %rax
jb 0x43e68
movq 0x48(%r14), %rdi
pushq $0x1d
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2a981
cmpl $0x0, (%rbx)
jne 0x43e59
movq %rax, %r12
movq 0x48(%r14), %rdi
pushq $0x1d
popq %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
callq 0x2a981
movq %rax, (%rsp)
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, %r13
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, 0x10(%rsp)
movq 0x48(%r14), %rdi
callq 0x2b774
movq %rax, 0x8(%rsp)
movq 0x48(%r14), %rdi
movl %r15d, %ecx
andl $-0x4, %ecx
pushq $0x9
popq %rsi
movq %r12, %rdx
movq %rbx, %r8
callq 0x2a819
cmpl $0x0, (%rbx)
jne 0x43e59
movq %rax, %rbp
movq 0x48(%r14), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
pushq $0x3b
popq %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x2a819
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
pushq $0x43
popq %rsi
movq %rax, %rdx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %r8
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
jne 0x43e59
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x1ec07
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
pushq $0x9
popq %rsi
pushq $0x4
popq %r8
movq %r12, %rdx
movq %r12, %rcx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
pushq $0x9
popq %rsi
pushq $0x4
popq %r8
movq (%rsp), %rcx
movq %rcx, %rdx
movq %rbx, %r9
callq 0x2a8c1
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
pushq $0x45
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x2a997
cmpl $0x0, (%rbx)
jne 0x43e59
movq 0x48(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x2b781
cmpl $0x0, (%rbx)
je 0x43e68
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %r13
andq $-0x4, %r13
xorl %ebp, %ebp
movq %r13, %rax
addq %rbp, %rax
cmpq %r15, %rax
jae 0x43e59
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %rdx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x1ecaa
cmpl $0x0, (%rbx)
jne 0x43e59
incq %rbp
jmp 0x43e71
nop