// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/assembler/ins_enc.c
// Function: ins_enc_Jb
void ins_enc_Jb(
	Instruction *ins,
	InstructionEncoderData *data
) {
	_CHECK_PARAMS(1);

	ParserASTNode *ins_node = data->ins_node;

	ParserASTNode *node_label = data->ins_node->childs[0];

	uint64_t addr = asm_parser_get_symbol_by_token_key(data->ctx, node_label->token);

	EncoderInstruction enc_ins;
	
	ins_init(data->ctx, ins, ins_node, &enc_ins);

	enc_ins.disp_len = 1;
	enc_ins.disp = 0;

	uint8_t buffer[32];
	size_t len = enc_ins_encode(&enc_ins, buffer, sizeof(buffer));

	uint64_t ip = ASM_PARSER_CONTEXT_DATA_GET_ADDRESS_COUNTER(data->ctx) + len;
	uint64_t offset = addr - ip;
	enc_ins.disp = offset;

	len = enc_ins_encode(&enc_ins, buffer, sizeof(buffer));

	ASM_PARSER_CONTEXT_DATA_INC_ADDRESS_COUNTER(data->ctx, len);
	if (ASM_PARSER_CONTEXT_DATA_GET_STEP(data->ctx) == ASM_STEP_SCAN) {
		return;
	}

	fwrite(buffer, len, 1, ASM_PARSER_CONTEXT_DATA_GET_OUT(data->ctx));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x1fe3c
jmp 0x1fe5b
leaq 0x29cc3(%rip), %rdi     # 0x49b06
leaq 0x2b1d6(%rip), %rsi     # 0x4b020
movl $0x258, %edx            # imm = 0x258
leaq 0x2b654(%rip), %rcx     # 0x4b4aa
callq 0xa0b0
cmpq $0x0, -0x10(%rbp)
je 0x1fe64
jmp 0x1fe83
leaq 0x30184(%rip), %rdi     # 0x4ffef
leaq 0x2b1ae(%rip), %rsi     # 0x4b020
movl $0x258, %edx            # imm = 0x258
leaq 0x2b62c(%rip), %rcx     # 0x4b4aa
callq 0xa0b0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1fe8f
jmp 0x1feae
leaq 0x2b1e7(%rip), %rdi     # 0x4b07d
leaq 0x2b183(%rip), %rsi     # 0x4b020
movl $0x258, %edx            # imm = 0x258
leaq 0x2b601(%rip), %rcx     # 0x4b4aa
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x1, 0x44(%rax)
jne 0x1febd
jmp 0x1fedc
leaq 0x2b43a(%rip), %rdi     # 0x4b2fe
leaq 0x2b155(%rip), %rsi     # 0x4b020
movl $0x258, %edx            # imm = 0x258
leaq 0x2b5d3(%rip), %rcx     # 0x4b4aa
callq 0xa0b0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2a7f0
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x1a9e0
movb $0x1, -0x6a(%rbp)
movq $0x0, -0x68(%rbp)
leaq -0xb0(%rbp), %rsi
leaq -0x88(%rbp), %rdi
movl $0x20, %edx
callq 0x19210
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xc0(%rax), %rax
addq -0xb8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x28(%rbp), %rax
subq -0xc0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0xb0(%rbp), %rsi
leaq -0x88(%rbp), %rdi
movl $0x20, %edx
callq 0x19210
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
addq 0xc0(%rax), %rcx
movq %rcx, 0xc0(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1, 0xc8(%rax)
jne 0x1ffe2
jmp 0x20009
leaq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0xb8(%rax), %rcx
movl $0x1, %edx
callq 0xa190
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)