// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movq %rdx, %rsi
callq 0x647a2
cmpl $0x0, (%r14)
jne 0x63851
movq %rax, %rbx
movl (%rax), %eax
cmpl $0x1, %eax
je 0x637d6
cmpl $0x6, %eax
je 0x63783
cmpl $0x7, %eax
jne 0x63810
cvttsd2si 0x8(%rbx), %ebp
jmp 0x63786
movl 0x8(%rbx), %ebp
leaq 0xc(%rsp), %rsi
movl %ebp, %edi
callq 0x4caab
testb %al, %al
je 0x637ac
movl $0x1, (%r12)
movl 0xc(%rsp), %eax
movl %eax, 0x8(%r12)
jmp 0x63849
movq 0x8(%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0xd521(%rip), %rax      # 0x70ce0
pushq $0x59
popq %rsi
movq %r14, %rdi
movl %ebp, %edx
xorl %ecx, %ecx
pushq $0x1a2                  # imm = 0x1A2
pushq %rax
callq 0x14179
jmp 0x63847
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r12)
movq 0x10(%r15), %rdi
callq 0x12a25
movq 0x10(%r15), %rdi
cmpl $0x2, (%rdi)
jne 0x63809
movl $0x2, (%r12)
callq 0x12a25
cmpb $0x2c, (%rax)
jne 0x63809
cmpb $0x0, 0x1(%rax)
je 0x6385e
andl $0x0, (%r12)
jmp 0x63849
movq %rbx, %rdi
callq 0x647dd
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xd4b5(%rip), %r10      # 0x70ce0
leaq 0xd559(%rip), %rdx      # 0x70d8b
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %rax, %rcx
pushq $0x1ad                  # imm = 0x1AD
pushq %r10
callq 0x140cd
popq %rax
popq %rcx
movq %rbx, %rdi
callq 0x63ee7
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r15), %rdi
movq 0x10(%r15), %rsi
movq %r14, %rdx
callq 0x12e0e
cmpl $0x0, (%r14)
jne 0x63849
movq 0x10(%r15), %rdi
callq 0x12a25
movq 0x10(%r15), %rcx
cmpl $0x1, (%rcx)
jne 0x638e1
movl 0x8(%rcx), %ecx
addl $-0x27, %ecx
cmpl $0x5, %ecx
jae 0x6390e
movl %ecx, %eax
leaq 0xd412(%rip), %rcx      # 0x70cac
movl (%rcx,%rax,4), %eax
movl %eax, 0x10(%r12)
movq %rbx, %rdi
callq 0x63ee7
movq %r15, %rdi
movq %r14, %rsi
callq 0x647a2
cmpl $0x0, (%r14)
jne 0x63851
movq %rax, %rbx
movl (%rax), %eax
cmpl $0x1, %eax
je 0x6393b
cmpl $0x6, %eax
jne 0x6394f
movl 0x8(%rbx), %eax
movl %eax, 0x18(%r12)
movb $0x0, 0x20(%r12)
jmp 0x63849
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xd3ec(%rip), %r10      # 0x70ce0
leaq 0xa4ca(%rip), %rcx      # 0x6ddc5
pushq $0x10
popq %rsi
movq %r14, %rdi
movq %rax, %rdx
pushq $0x1c8                  # imm = 0x1C8
jmp 0x63840
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xd3bf(%rip), %r10      # 0x70ce0
leaq 0xd48a(%rip), %rdx      # 0x70db2
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %rax, %rcx
pushq $0x1df                  # imm = 0x1DF
jmp 0x63840
movq 0x8(%rbx), %rax
movq %rax, 0x18(%r12)
movb $0x1, 0x20(%r12)
jmp 0x63849
movq %rbx, %rdi
callq 0x647dd
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xd376(%rip), %r10      # 0x70ce0
leaq 0xd461(%rip), %rdx      # 0x70dd2
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %rax, %rcx
pushq $0x1f1                  # imm = 0x1F1
jmp 0x63840