// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/assembler.c
// Function: prv_get_op2
static void prv_get_op2(subtilis_arm_ass_context_t *c, subtilis_arm_op2_t *op2,
			subtilis_error_t *err)
{
	uint32_t encoded;
	int32_t num;
	subtilis_arm_exp_val_t *val;
	const char *tbuf;

	val = subtilis_arm_exp_val_get(c, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if ((val->type == SUBTILIS_ARM_EXP_TYPE_INT) ||
	    (val->type == SUBTILIS_ARM_EXP_TYPE_REAL)) {
		if (val->type == SUBTILIS_ARM_EXP_TYPE_REAL)
			num = (int32_t)val->val.real;
		else
			num = val->val.integer;
		if (!subtilis_arm_encode_imm(num, &encoded)) {
			subtilis_error_set_ass_integer_encode(
			    err, num, c->l->stream->name, c->l->line);
			goto cleanup;
		}
		op2->type = SUBTILIS_ARM_OP2_I32;
		op2->op.integer = encoded;
		goto cleanup;
	}

	if (val->type != SUBTILIS_ARM_EXP_TYPE_REG) {
		subtilis_error_set_expected(err, "register",
					    subtilis_arm_exp_type_name(val),
					    c->l->stream->name, c->l->line);
		goto cleanup;
	}

	op2->op.reg = val->val.reg;

	tbuf = subtilis_token_get_text(c->t);
	if (c->t->type != SUBTILIS_TOKEN_OPERATOR) {
		op2->type = SUBTILIS_ARM_OP2_REG;
		goto cleanup;
	}

	op2->type = SUBTILIS_ARM_OP2_SHIFTED;

	tbuf = subtilis_token_get_text(c->t);
	if (strcmp(tbuf, ",")) {
		op2->type = SUBTILIS_ARM_OP2_REG;
		goto cleanup;
	}

	subtilis_lexer_get(c->l, c->t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	tbuf = subtilis_token_get_text(c->t);
	if (c->t->type != SUBTILIS_TOKEN_KEYWORD) {
		subtilis_error_set_keyword_expected(
		    err, tbuf, c->l->stream->name, c->l->line);
		goto cleanup;
	}

	switch (c->t->tok.keyword.type) {
	case SUBTILIS_ARM_KEYWORD_ASR:
		op2->op.shift.type = SUBTILIS_ARM_SHIFT_ASR;
		break;
	case SUBTILIS_ARM_KEYWORD_LSL:
		op2->op.shift.type = SUBTILIS_ARM_SHIFT_LSL;
		break;
	case SUBTILIS_ARM_KEYWORD_LSR:
		op2->op.shift.type = SUBTILIS_ARM_SHIFT_LSR;
		break;
	case SUBTILIS_ARM_KEYWORD_ROR:
		op2->op.shift.type = SUBTILIS_ARM_SHIFT_ROR;
		break;
	case SUBTILIS_ARM_KEYWORD_RRX:
		op2->op.shift.type = SUBTILIS_ARM_SHIFT_RRX;
		break;
	default:
		subtilis_error_set_expected(
		    err, "ASR or LSL or LSR or ROR or RRX", tbuf,
		    c->l->stream->name, c->l->line);
		goto cleanup;
	}

	subtilis_arm_exp_val_free(val);
	val = subtilis_arm_exp_val_get(c, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (val->type == SUBTILIS_ARM_EXP_TYPE_INT) {
		op2->op.shift.shift.integer = val->val.integer;
		op2->op.shift.shift_reg = false;
	} else if (val->type == SUBTILIS_ARM_EXP_TYPE_REG) {
		op2->op.shift.shift.reg = val->val.reg;
		op2->op.shift.shift_reg = true;
	} else {
		subtilis_error_set_expected(err, "integer or register",
					    subtilis_arm_exp_type_name(val),
					    c->l->stream->name, c->l->line);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

cleanup:

	subtilis_arm_exp_val_free(val);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9b4f0
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x987d3
jmp 0x98b76
movq -0x28(%rbp), %rax
cmpl $0x6, (%rax)
je 0x987e9
movq -0x28(%rbp), %rax
cmpl $0x7, (%rax)
jne 0x98876
movq -0x28(%rbp), %rax
cmpl $0x7, (%rax)
jne 0x98800
movq -0x28(%rbp), %rax
cvttsd2si 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x9880a
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %edi
leaq -0x1c(%rbp), %rsi
callq 0x70e60
testb $0x1, %al
jne 0x9885d
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x59, %esi
xorl %ecx, %ecx
leaq 0x158d9(%rip), %rax     # 0xae120
movq %rax, (%rsp)
movl $0x1a2, 0x8(%rsp)       # imm = 0x1A2
callq 0x157b0
jmp 0x98b6d
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
jmp 0x98b6d
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
je 0x988d8
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x9b550
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x15915(%rip), %rdx     # 0xae1d0
leaq 0x1585e(%rip), %rax     # 0xae120
movq %rax, (%rsp)
movl $0x1ad, 0x8(%rsp)       # imm = 0x1AD
callq 0x156d0
jmp 0x98b6d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x2, (%rax)
je 0x98915
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
jmp 0x98b6d
movq -0x10(%rbp), %rax
movl $0x2, (%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x11c6e(%rip), %rsi     # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
je 0x98954
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
jmp 0x98b6d
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9897b
jmp 0x98b6d
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12d70
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x1, (%rax)
je 0x989e2
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x10, %esi
leaq 0x128b1(%rip), %rcx     # 0xab276
leaq 0x15754(%rip), %rax     # 0xae120
movq %rax, (%rsp)
movl $0x1c8, 0x8(%rsp)       # imm = 0x1C8
callq 0x156d0
jmp 0x98b6d
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x8(%rax), %eax
addl $-0x27, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x4, %eax
ja 0x98a50
movq -0x40(%rbp), %rax
leaq 0x156f2(%rip), %rcx     # 0xae0f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movl $0x3, 0x10(%rax)
jmp 0x98a99
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
jmp 0x98a99
movq -0x10(%rbp), %rax
movl $0x2, 0x10(%rax)
jmp 0x98a99
movq -0x10(%rbp), %rax
movl $0x4, 0x10(%rax)
jmp 0x98a99
movq -0x10(%rbp), %rax
movl $0x5, 0x10(%rax)
jmp 0x98a99
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x1577b(%rip), %rdx     # 0xae1f7
leaq 0x1569d(%rip), %rax     # 0xae120
movq %rax, (%rsp)
movl $0x1df, 0x8(%rsp)       # imm = 0x1DF
callq 0x156d0
jmp 0x98b6d
movq -0x28(%rbp), %rdi
callq 0x9a4c0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9b4f0
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x98ac1
jmp 0x98b76
movq -0x28(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x98ae5
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x20(%rax)
jmp 0x98b6b
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x98b08
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x20(%rax)
jmp 0x98b69
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
callq 0x9b550
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x156d3(%rip), %rdx     # 0xae217
leaq 0x155d5(%rip), %rax     # 0xae120
movq %rax, (%rsp)
movl $0x1f1, 0x8(%rsp)       # imm = 0x1F1
callq 0x156d0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x98b67
jmp 0x98b6d
jmp 0x98b69
jmp 0x98b6b
jmp 0x98b6d
movq -0x28(%rbp), %rdi
callq 0x9a4c0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)