// File: /workspace/github_cpp_makefile_star2_O2/lhydave[P]SysYCompilerLab/back/riscv/emit_riscv.cpp
// Function: riscv::emit_goto(std::shared_ptr<tigger::goto_stmt> const&)
void emit_goto(const shared_ptr<tigger::goto_stmt> &stmt)
{
	static unordered_map<string, string> convert = {{"<", "blt"}, {">", "bgt"},
		{"<=", "ble"}, {">=", "bge"}, {"!=", "bne"}, {"==", "beq"}};
	auto f = [](const string &cond) {
		std::istringstream temp(cond);
		vector<string> ret(3);
		temp >> ret[0] >> ret[1] >> ret[2];
		return ret;
	};
	if (!stmt->cond.empty())
	{
		auto split = f(stmt->cond);
		riscv_dst << "\t" << convert[split[1]] << "\t" << split[0] << ", "
				  << split[2] << ", .l" << stmt->goto_label << "\n";
	}
	else
		riscv_dst << "\tj\t.l" << stmt->goto_label << "\n";
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, %rbx
movb 0x13e20(%rip), %al      # 0x2ec00
testb %al, %al
je 0x1af3b
movq (%rbx), %rsi
cmpq $0x0, 0x10(%rsi)
je 0x1aefe
addq $0x8, %rsi
leaq 0x30(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x5480
leaq 0x18(%rsp), %rdi
pushq $0x3
popq %rsi
leaq 0x16(%rsp), %rdx
callq 0x1b95e
movq 0x18(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x5310
movq 0x18(%rsp), %rsi
addq $0x20, %rsi
movq %rax, %rdi
callq 0x5310
movq 0x18(%rsp), %rsi
addq $0x40, %rsi
movq %rax, %rdi
callq 0x5310
leaq 0x30(%rsp), %rdi
callq 0x5550
leaq 0x1371d(%rip), %rdi     # 0x2e578
leaq 0x4ab9(%rip), %rsi      # 0x1f91b
callq 0x5230
movq %rax, %r14
movq 0x18(%rsp), %rsi
addq $0x20, %rsi
leaq 0x13d4e(%rip), %rdi     # 0x2ebc8
callq 0x1bf0e
movq %r14, %rdi
movq %rax, %rsi
callq 0x5210
leaq 0x4a8a(%rip), %rsi      # 0x1f91b
movq %rax, %rdi
callq 0x5230
movq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x5210
leaq 0x4a05(%rip), %rsi      # 0x1f8b2
movq %rax, %rdi
callq 0x5230
movq 0x18(%rsp), %rsi
addq $0x40, %rsi
movq %rax, %rdi
callq 0x5210
leaq 0x49af(%rip), %rsi      # 0x1f87c
movq %rax, %rdi
callq 0x5230
movq (%rbx), %rcx
movl 0x28(%rcx), %esi
movq %rax, %rdi
callq 0x54a0
leaq 0x3af2(%rip), %rsi      # 0x1e9dc
movq %rax, %rdi
callq 0x5230
leaq 0x18(%rsp), %rdi
callq 0x112b6
jmp 0x1af2e
leaq 0x13673(%rip), %rdi     # 0x2e578
leaq 0x4975(%rip), %rsi      # 0x1f881
callq 0x5230
movq (%rbx), %rcx
movl 0x28(%rcx), %esi
movq %rax, %rdi
callq 0x54a0
leaq 0x3ab6(%rip), %rsi      # 0x1e9dc
movq %rax, %rdi
callq 0x5230
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r14
popq %r15
retq
leaq 0x13cbe(%rip), %rdi     # 0x2ec00
callq 0x54e0
testl %eax, %eax
je 0x1ade8
leaq 0x48d0(%rip), %rsi      # 0x1f826
leaq 0x490b(%rip), %rdx      # 0x1f868
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x1b7b0
leaq 0x70(%rsp), %r15
leaq 0x48b6(%rip), %rsi      # 0x1f82c
leaq 0x48ef(%rip), %rdx      # 0x1f86c
movq %r15, %rdi
callq 0x1b7b0
leaq 0xb0(%rsp), %r15
leaq 0x489e(%rip), %rsi      # 0x1f832
leaq 0x3a5c(%rip), %rdx      # 0x1e9f7
movq %r15, %rdi
callq 0x1b7f0
leaq 0xf0(%rsp), %r15
leaq 0x4883(%rip), %rsi      # 0x1f835
leaq 0x48b7(%rip), %rdx      # 0x1f870
movq %r15, %rdi
callq 0x1b7f0
leaq 0x130(%rsp), %r15
leaq 0x486b(%rip), %rsi      # 0x1f83b
leaq 0x489d(%rip), %rdx      # 0x1f874
movq %r15, %rdi
callq 0x1b7f0
leaq 0x170(%rsp), %r15
leaq 0x4854(%rip), %rsi      # 0x1f842
leaq 0x4883(%rip), %rdx      # 0x1f878
movq %r15, %rdi
callq 0x1b7f0
leaq 0x1b0(%rsp), %rdx
leaq 0x17(%rsp), %rax
movq %rax, (%rsp)
leaq 0x13bb3(%rip), %rdi     # 0x2ebc8
leaq 0x30(%rsp), %rsi
leaq 0x18(%rsp), %r8
leaq 0x16(%rsp), %r9
xorl %ecx, %ecx
callq 0x1ba2a
movl $0x140, %r14d           # imm = 0x140
leaq (%rsp,%r14), %rdi
addq $0x30, %rdi
callq 0x1b870
addq $-0x40, %r14
cmpq $-0x40, %r14
jne 0x1b031
leaq 0x837(%rip), %rdi       # 0x1b886
leaq 0x13b72(%rip), %rsi     # 0x2ebc8
leaq 0x1324b(%rip), %rdx     # 0x2e2a8
callq 0x5200
leaq 0x13b97(%rip), %rdi     # 0x2ec00
callq 0x5190
jmp 0x1ade8
movq %rax, %rbx
movl $0x140, %r14d           # imm = 0x140
leaq (%rsp,%r14), %rdi
addq $0x30, %rdi
callq 0x1b870
addq $-0x40, %r14
cmpq $-0x40, %r14
jne 0x1b07c
jmp 0x1b0ae
movq %rax, %rbx
jmp 0x1b0ae
movq %rax, %rbx
addq $-0x40, %r15
movq %r15, %rdi
callq 0x1b870
cmpq %r14, %r15
jne 0x1b09d
leaq 0x13b4b(%rip), %rdi     # 0x2ec00
callq 0x5180
jmp 0x1b0e7
movq %rax, %rbx
jmp 0x1b0ce
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x112b6
leaq 0x30(%rsp), %rdi
callq 0x5550
jmp 0x1b0e7
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x112b6
movq %rbx, %rdi
callq 0x54c0