// File: /workspace/github_c_makefile_star2_O3/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 0x69632
cmpl $0x0, (%r14)
jne 0x67c61
movq %rax, %rbx
movl (%rax), %eax
cmpl $0x1, %eax
je 0x67bdf
cmpl $0x6, %eax
je 0x67b8a
cmpl $0x7, %eax
jne 0x67c1c
cvttsd2si 0x8(%rbx), %ebp
jmp 0x67b8d
movl 0x8(%rbx), %ebp
leaq 0xc(%rsp), %rsi
movl %ebp, %edi
callq 0x4f87d
testb %al, %al
je 0x67bb3
movl $0x1, (%r12)
movl 0xc(%rsp), %eax
movl %eax, 0x8(%r12)
jmp 0x67c59
movq 0x8(%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0xf1aa(%rip), %rax      # 0x76d70
movq %r14, %rdi
movl $0x59, %esi
movl %ebp, %edx
xorl %ecx, %ecx
pushq $0x1a2                  # imm = 0x1A2
pushq %rax
callq 0x14486
jmp 0x67c55
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r12)
movq 0x10(%r15), %rdi
callq 0x12ad0
movq 0x10(%r15), %rdi
cmpl $0x2, (%rdi)
jne 0x67c12
movl $0x2, (%r12)
callq 0x12ad0
cmpb $0x2c, (%rax)
jne 0x67c12
cmpb $0x0, 0x1(%rax)
je 0x67c6e
movl $0x0, (%r12)
jmp 0x67c59
movq %rbx, %rdi
callq 0x6966d
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xf139(%rip), %r10      # 0x76d70
leaq 0xf1dd(%rip), %rdx      # 0x76e1b
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x1ad                  # imm = 0x1AD
pushq %r10
callq 0x143da
addq $0x10, %rsp
movq %rbx, %rdi
callq 0x68d41
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 0x12edc
cmpl $0x0, (%r14)
jne 0x67c59
movq 0x10(%r15), %rdi
callq 0x12ad0
movq 0x10(%r15), %rcx
cmpl $0x1, (%rcx)
jne 0x67cf1
movl 0x8(%rcx), %ecx
addl $-0x27, %ecx
cmpl $0x5, %ecx
jae 0x67d20
movl %ecx, %eax
leaq 0xf092(%rip), %rcx      # 0x76d3c
movl (%rcx,%rax,4), %eax
movl %eax, 0x10(%r12)
movq %rbx, %rdi
callq 0x68d41
movq %r15, %rdi
movq %r14, %rsi
callq 0x69632
cmpl $0x0, (%r14)
jne 0x67c61
movq %rax, %rbx
movl (%rax), %eax
cmpl $0x1, %eax
je 0x67d4f
cmpl $0x6, %eax
jne 0x67d63
movl 0x8(%rbx), %eax
movl %eax, 0x18(%r12)
movb $0x0, 0x20(%r12)
jmp 0x67c59
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xf06c(%rip), %r10      # 0x76d70
leaq 0xc10a(%rip), %rcx      # 0x73e15
movq %r14, %rdi
movl $0x10, %esi
movq %rax, %rdx
pushq $0x1c8                  # imm = 0x1C8
jmp 0x67c4e
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xf03d(%rip), %r10      # 0x76d70
leaq 0xf108(%rip), %rdx      # 0x76e42
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x1df                  # imm = 0x1DF
jmp 0x67c4e
movq 0x8(%rbx), %rax
movq %rax, 0x18(%r12)
movb $0x1, 0x20(%r12)
jmp 0x67c59
movq %rbx, %rdi
callq 0x6966d
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xeff2(%rip), %r10      # 0x76d70
leaq 0xf0dd(%rip), %rdx      # 0x76e62
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x1f1                  # imm = 0x1F1
jmp 0x67c4e