// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: subtilis_builtins_ir_inkey
void subtilis_builtins_ir_inkey(subtilis_ir_section_t *current,
				subtilis_error_t *err)
{
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t cond;
	subtilis_ir_operand_t true_label;
	subtilis_ir_operand_t false_label;
	subtilis_ir_operand_t end_label;

	op0.reg = current->reg_counter++;

	op1.reg = SUBTILIS_IR_REG_TEMP_START;
	op2.integer = 0;
	cond.reg = subtilis_ir_section_add_instr(
	    current, SUBTILIS_OP_INSTR_GTEI_I32, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	true_label.reg = subtilis_ir_section_new_label(current);
	false_label.reg = subtilis_ir_section_new_label(current);
	end_label.reg = subtilis_ir_section_new_label(current);

	subtilis_ir_section_add_instr_reg(current, SUBTILIS_OP_INSTR_JMPC, cond,
					  true_label, false_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(current, true_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg2(current, SUBTILIS_OP_INSTR_GET_TO,
					      op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg(current, SUBTILIS_OP_INSTR_JMP,
					     end_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(current, false_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op2.integer = -256;
	cond.reg = subtilis_ir_section_add_instr(
	    current, SUBTILIS_OP_INSTR_EQI_I32, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	true_label.reg = subtilis_ir_section_new_label(current);
	false_label.reg = subtilis_ir_section_new_label(current);
	subtilis_ir_section_add_instr_reg(current, SUBTILIS_OP_INSTR_JMPC, cond,
					  true_label, false_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(current, true_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg(
	    current, SUBTILIS_OP_INSTR_OS_BYTE_ID, op0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg(current, SUBTILIS_OP_INSTR_JMP,
					     end_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(current, false_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg2(current, SUBTILIS_OP_INSTR_INKEY,
					      op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(current, end_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg(current, SUBTILIS_OP_INSTR_RET_I32,
					     op0, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x18(%rcx)
movq %rax, -0x18(%rbp)
movq $0x4, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r8
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x41, %esi
callq 0x38230
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x40152
jmp 0x4037f
movq -0x8(%rbp), %rdi
callq 0x39940
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x39940
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r9
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x401a5
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x39960
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x401c4
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r8
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl $0x6d, %esi
callq 0x385a0
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x401ec
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x48(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x40210
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x39960
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4022f
jmp 0x4037f
movl $0xffffff00, -0x28(%rbp) # imm = 0xFFFFFF00
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r8
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x2d, %esi
callq 0x38230
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x40262
jmp 0x4037f
movq -0x8(%rbp), %rdi
callq 0x39940
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r9
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x402a8
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x39960
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x402c7
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rdx
movl $0x6f, %esi
callq 0x38540
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x402eb
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x48(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4030c
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x39960
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x40328
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %r8
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl $0x6e, %esi
callq 0x385a0
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x4034d
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x39960
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x40369
jmp 0x4037f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rdx
movl $0x47, %esi
callq 0x38540
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)