// File: 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 %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x8(%rbp)
cmpb $0x0, 0x2ba3a(%rip)     # 0x72cc0
jne 0x47449
leaq 0x2ba2d(%rip), %rdi     # 0x72cc0
callq 0x5640
cmpl $0x0, %eax
je 0x47449
leaq -0x198(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq 0x78b4(%rip), %rsi      # 0x4eb6a
leaq 0x78ef(%rip), %rdx      # 0x4ebac
callq 0x48c70
jmp 0x472c4
leaq -0x158(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq 0x7897(%rip), %rsi      # 0x4eb70
leaq 0x78d0(%rip), %rdx      # 0x4ebb0
callq 0x48c70
jmp 0x472e7
leaq -0x118(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq 0x787a(%rip), %rsi      # 0x4eb76
leaq 0x6958(%rip), %rdx      # 0x4dc5b
callq 0x48d50
jmp 0x4730a
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq 0x785a(%rip), %rsi      # 0x4eb79
leaq 0x788e(%rip), %rdx      # 0x4ebb4
callq 0x48d50
jmp 0x4732d
leaq -0x98(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq 0x783d(%rip), %rsi      # 0x4eb7f
leaq 0x786f(%rip), %rdx      # 0x4ebb8
callq 0x48d50
jmp 0x47350
leaq -0x58(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq 0x7824(%rip), %rsi      # 0x4eb86
leaq 0x7853(%rip), %rdx      # 0x4ebbc
callq 0x48d50
jmp 0x47370
leaq -0x198(%rbp), %rax
movq %rax, -0x18(%rbp)
movq $0x6, -0x10(%rbp)
leaq -0x1af(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x48f40
movq -0x1d0(%rbp), %rcx
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0x2b8d6(%rip), %rdi     # 0x72c88
xorl %eax, %eax
movl %eax, %ecx
leaq -0x1ad(%rbp), %r8
leaq -0x1ae(%rbp), %r9
callq 0x48f60
jmp 0x473cb
leaq -0x1af(%rbp), %rdi
callq 0x48fc0
leaq -0x198(%rbp), %rax
movq %rax, -0x1e0(%rbp)
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x48f10
movq -0x1e0(%rbp), %rcx
movq -0x1e8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1d8(%rbp)
jne 0x473f2
leaq 0x1bb6(%rip), %rdi      # 0x48fe0
leaq 0x2b857(%rip), %rsi     # 0x72c88
leaq 0x2af28(%rip), %rdx     # 0x72360
callq 0x52a0
leaq 0x2b87c(%rip), %rdi     # 0x72cc0
callq 0x5210
movq -0x8(%rbp), %rdi
callq 0x49030
movq %rax, %rdi
addq $0x8, %rdi
callq 0x55b0
testb $0x1, %al
jne 0x476cf
movq -0x8(%rbp), %rdi
callq 0x49030
movq %rax, %rdx
addq $0x8, %rdx
leaq -0x1c8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x485f0
leaq 0x2b1a0(%rip), %rdi     # 0x72630
leaq 0x77c8(%rip), %rsi      # 0x4ec5f
callq 0x52f0
movq %rax, -0x1f0(%rbp)
jmp 0x474a5
leaq -0x1c8(%rbp), %rdi
movl $0x1, %esi
callq 0x49050
movq %rax, %rsi
leaq 0x2b7c8(%rip), %rdi     # 0x72c88
callq 0x49000
movq %rax, -0x1f8(%rbp)
jmp 0x474ce
movq -0x1f8(%rbp), %rsi
movq -0x1f0(%rbp), %rdi
callq 0x52b0
movq %rax, -0x200(%rbp)
jmp 0x474ea
movq -0x200(%rbp), %rdi
leaq 0x7767(%rip), %rsi      # 0x4ec5f
callq 0x52f0
movq %rax, -0x208(%rbp)
jmp 0x47506
xorl %eax, %eax
movl %eax, %esi
leaq -0x1c8(%rbp), %rdi
callq 0x49050
movq -0x208(%rbp), %rdi
movq %rax, %rsi
callq 0x52b0
movq %rax, -0x210(%rbp)
jmp 0x4752e
movq -0x210(%rbp), %rdi
leaq 0x76ba(%rip), %rsi      # 0x4ebf6
callq 0x52f0
movq %rax, -0x218(%rbp)
jmp 0x4754a
leaq -0x1c8(%rbp), %rdi
movl $0x2, %esi
callq 0x49050
movq -0x218(%rbp), %rdi
movq %rax, %rsi
callq 0x52b0
movq %rax, -0x220(%rbp)
jmp 0x47573
movq -0x220(%rbp), %rdi
leaq 0x763f(%rip), %rsi      # 0x4ebc0
callq 0x52f0
movq %rax, -0x228(%rbp)
jmp 0x4758f
movq -0x8(%rbp), %rdi
callq 0x49030
movq -0x228(%rbp), %rdi
movl 0x28(%rax), %esi
callq 0x55f0
movq %rax, -0x230(%rbp)
jmp 0x475b0
movq -0x230(%rbp), %rdi
leaq 0x6682(%rip), %rsi      # 0x4dc40
callq 0x52f0
jmp 0x475c5
leaq -0x1c8(%rbp), %rdi
callq 0x24080
jmp 0x47710
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
movq -0x1a0(%rbp), %rax
leaq -0x198(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x238(%rbp)
je 0x47633
movq -0x238(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x240(%rbp)
callq 0x48f10
movq -0x240(%rbp), %rax
leaq -0x198(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x238(%rbp)
jne 0x47602
jmp 0x476a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x1af(%rbp), %rdi
callq 0x48fc0
leaq -0x198(%rbp), %rax
movq %rax, -0x250(%rbp)
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x258(%rbp)
callq 0x48f10
movq -0x250(%rbp), %rcx
movq -0x258(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x248(%rbp)
jne 0x4766e
jmp 0x476a1
leaq 0x2b618(%rip), %rdi     # 0x72cc0
callq 0x5200
jmp 0x47719
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x24080
jmp 0x47719
leaq 0x2af5a(%rip), %rdi     # 0x72630
leaq 0x74e8(%rip), %rsi      # 0x4ebc5
callq 0x52f0
movq %rax, -0x260(%rbp)
movq -0x8(%rbp), %rdi
callq 0x49030
movq -0x260(%rbp), %rdi
movl 0x28(%rax), %esi
callq 0x55f0
movq %rax, %rdi
leaq 0x6535(%rip), %rsi      # 0x4dc40
callq 0x52f0
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
movq -0x1a8(%rbp), %rdi
callq 0x5610
nopw %cs:(%rax,%rax)