// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/int32_type.c
// Function: prv_sgn
static subtilis_exp_t *prv_sgn(subtilis_parser_t *p, subtilis_exp_t *e,
			       subtilis_error_t *err)
{
	subtilis_ir_operand_t less_zero;
	subtilis_ir_operand_t gte_zero;
	size_t reg;
	size_t reg2;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;

	less_zero.label = subtilis_ir_section_new_label(p->current);
	gte_zero.label = subtilis_ir_section_new_label(p->current);

	op2.integer = 0;
	reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LTI_I32, e->exp.ir_op, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.reg = reg;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  op1, less_zero, gte_zero, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, gte_zero.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	reg2 = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_GTI_I32, e->exp.ir_op, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	e->exp.ir_op.reg = reg2;
	e = prv_abs(p, e, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	prv_assign_to_reg(p, reg, e, err);
	e = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, less_zero.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	return subtilis_exp_new_int32_var(reg, err);

cleanup:

	subtilis_exp_delete(e);

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x30(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %r8
movq 0x148(%rax), %rdx
movq -0x50(%rbp), %rcx
movl $0x3d, %esi
callq 0x38230
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x50834
jmp 0x50952
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5086c
jmp 0x50952
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x39960
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5088f
jmp 0x50952
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %r8
movq 0x148(%rax), %rdx
movq -0x50(%rbp), %rcx
movl $0x35, %esi
callq 0x38230
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x508c6
jmp 0x50952
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x148(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x506c0
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x508f5
jmp 0x50952
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x4f640
movq $0x0, -0x18(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5091d
jmp 0x50952
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x39960
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x5093d
jmp 0x50952
movq -0x38(%rbp), %rax
movl %eax, %edi
movq -0x20(%rbp), %rsi
callq 0x37770
movq %rax, -0x8(%rbp)
jmp 0x50963
movq -0x18(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)