// File: /workspace/github_c_makefile_star2_O1/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 0x30197
movq %rax, %r15
cmpq $0x4, %rax
jb 0x46766
movq 0x48(%r14), %rdi
movl $0x1d, %esi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2c189
cmpl $0x0, (%rbx)
jne 0x467a0
movq %rax, %r12
movq 0x48(%r14), %rdi
movl $0x1d, %esi
movq (%rsp), %rdx
movq %rbx, %rcx
callq 0x2c189
movq %rax, (%rsp)
cmpl $0x0, (%rbx)
jne 0x467a0
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, %r13
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x10(%rsp)
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x8(%rsp)
movq 0x48(%r14), %rdi
movl %r15d, %ecx
andl $-0x4, %ecx
movl $0x9, %esi
movq %r12, %rdx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x46761
movq %rax, %rbp
movq 0x48(%r14), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x46761
movq 0x48(%r14), %rdi
movl $0x3b, %esi
movq %r12, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x46761
movq 0x48(%r14), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %r8
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x46761
movq 0x48(%r14), %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x46761
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x1f8bc
cmpl $0x0, (%rbx)
jne 0x46761
movq 0x48(%r14), %rdi
movl $0x4, %r8d
movl $0x9, %esi
movq %r12, %rdx
movq %r12, %rcx
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x46761
movq 0x48(%r14), %rdi
movl $0x4, %r8d
movl $0x9, %esi
movq (%rsp), %rcx
movq %rcx, %rdx
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x46761
movq 0x48(%r14), %rdi
movl $0x45, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x2c19f
cmpl $0x0, (%rbx)
jne 0x46761
movq 0x48(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x467a0
movq %r15, %r13
andq $-0x4, %r13
cmpq %r15, %r13
je 0x467a0
xorl %ebp, %ebp
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %rdx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x1f967
cmpl $0x0, (%rbx)
jne 0x467a0
leaq 0x1(,%rbp), %rax
addq %r13, %rax
incq %rbp
cmpq %r15, %rax
jb 0x46774
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop