// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/rec_type.c
// Function: prv_rec_swap_32
static void prv_rec_swap_32(subtilis_parser_t *p, size_t size, size_t reg1,
			    size_t reg2, subtilis_error_t *err)
{
	subtilis_ir_operand_t start;
	subtilis_ir_operand_t body;
	subtilis_ir_operand_t end;
	subtilis_ir_operand_t four;
	subtilis_ir_operand_t sizeop;
	subtilis_ir_operand_t counter;
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t ptr1;
	subtilis_ir_operand_t ptr2;

	/*
	 * We're just going to do a memcpy, copying 4 bytes at a time
	 * until we run out of space.  Copying the fields individually
	 * will generate too much code and doing a memcpy might require
	 * too much stack data, as we'd need a temporary buffer the size
	 * of the type.
	 */

	start.label = subtilis_ir_section_new_label(p->current);
	body.label = subtilis_ir_section_new_label(p->current);
	end.label = subtilis_ir_section_new_label(p->current);
	ptr1.reg = reg1;
	ptr2.reg = reg2;

	sizeop.integer = (int32_t)size;
	counter.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, ptr1, sizeop, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_ir_section_add_label(p->current, start.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	four.integer = 4;
	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LT_I32, ptr1, counter, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, body, end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_ir_section_add_label(p->current, body.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_exp_swap_int32_mem(p, ptr1.reg, ptr2.reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, ptr1, ptr1, four, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, ptr2, ptr2, four, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_JMP,
					     start, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_ir_section_add_label(p->current, end.label, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x68(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x9, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x62f06
jmp 0x6306c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x62f29
jmp 0x6306c
movl $0x4, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x68(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl $0x3b, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x62f60
jmp 0x6306c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x60(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x62f90
jmp 0x6306c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x62fb3
jmp 0x6306c
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x28(%rbp), %r8
xorl %ecx, %ecx
callq 0x25f50
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x62fd8
jmp 0x6306c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x68(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %r8
movl $0x9, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63005
jmp 0x6306c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x70(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq -0x48(%rbp), %r8
movl $0x9, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63032
jmp 0x6306c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63057
jmp 0x6306c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)