// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/arch/arm32/arm_encode.c
// Function: prv_encode_directive
static void prv_encode_directive(void *user_data, subtilis_arm_op_t *op,
				 subtilis_error_t *err)
{
	uint32_t *dbl_ptr;
	size_t len;
	size_t i;
	subtilis_arm_encode_ud_t *ud = user_data;

	switch (op->type) {
	case SUBTILIS_ARM_OP_ALIGN:
		len = ud->bytes_written & (op->op.alignment - 1);
		if (len == 0)
			return;
		len = op->op.alignment - len;
		prv_ensure_code_size(ud, len, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		for (i = 0; i < len; i++)
			ud->code[ud->bytes_written++] = 0;
		break;
	case SUBTILIS_ARM_OP_BYTE:
		prv_ensure_code_size(ud, 1, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		ud->code[ud->bytes_written++] = op->op.byte;
		break;
	case SUBTILIS_ARM_OP_TWO_BYTE:
		prv_ensure_code_size(ud, 2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		*((uint16_t *)&ud->code[ud->bytes_written]) = op->op.two_bytes;
		ud->bytes_written += 2;
		break;
	case SUBTILIS_ARM_OP_FOUR_BYTE:
		prv_ensure_code_size(ud, 4, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		*((uint32_t *)&ud->code[ud->bytes_written]) = op->op.four_bytes;
		ud->bytes_written += 4;
		break;
	case SUBTILIS_ARM_OP_DOUBLE:
		prv_ensure_code_size(ud, 8, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		*((double *)&ud->code[ud->bytes_written]) = op->op.dbl;
		ud->bytes_written += 8;
		break;
	case SUBTILIS_ARM_OP_DOUBLER:
		prv_ensure_code_size(ud, 8, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		dbl_ptr = (uint32_t *)&op->op.dbl;
		*((uint32_t *)&ud->code[ud->bytes_written]) = dbl_ptr[1];
		*((uint32_t *)&ud->code[ud->bytes_written + 4]) = dbl_ptr[0];
		ud->bytes_written += 8;
		break;
	case SUBTILIS_ARM_OP_FLOAT:
		prv_ensure_code_size(ud, 4, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		dbl_ptr = (uint32_t *)&op->op.flt;
		*((uint32_t *)&ud->code[ud->bytes_written]) = *dbl_ptr;
		ud->bytes_written += 4;
		break;
	case SUBTILIS_ARM_OP_STRING:
		len = strlen(op->op.str) + 1;
		prv_ensure_code_size(ud, len, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		strcpy((char *)&ud->code[ud->bytes_written], op->op.str);
		ud->bytes_written += len;
		break;
	default:
		subtilis_error_set_assertion_failed(err);
		return;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r15
movl (%rsi), %eax
addl $-0x2, %eax
cmpl $0x7, %eax
ja 0x57756
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1e692(%rip), %rcx     # 0x75c40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x57496
cmpl $0x0, (%r15)
jne 0x5774d
movl 0x8(%r14), %eax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
movl %eax, (%rcx,%rdx)
addq $0x4, %rdx
jmp 0x5770f
movl $0x8, %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x57496
cmpl $0x0, (%r15)
jne 0x5774d
movsd 0x8(%r14), %xmm0
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
movsd %xmm0, (%rax,%rcx)
addq $0x8, %rcx
movq %rcx, 0x30(%rbx)
jmp 0x5774d
movl $0x1, %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x57496
cmpl $0x0, (%r15)
jne 0x5774d
movb 0x8(%r14), %al
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x30(%rbx)
movb %al, (%rcx,%rdx)
jmp 0x5774d
movl $0x2, %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x57496
cmpl $0x0, (%r15)
jne 0x5774d
movzwl 0x8(%r14), %eax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
movw %ax, (%rcx,%rdx)
addq $0x2, %rdx
jmp 0x5770f
movl 0x8(%r14), %r14d
leal -0x1(%r14), %eax
andl 0x30(%rbx), %eax
je 0x5774d
subq %rax, %r14
sete %bpl
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x57496
cmpl $0x0, (%r15)
setne %al
orb %bpl, %al
jne 0x5774d
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rbx)
movb $0x0, (%rax,%rcx)
decq %r14
jne 0x576c3
jmp 0x5774d
movl $0x8, %esi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x57496
cmpl $0x0, (%r15)
jne 0x5774d
movl 0xc(%r14), %eax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
movl %eax, (%rcx,%rdx)
movl 0x8(%r14), %eax
movl %eax, 0x4(%rcx,%rdx)
addq $0x8, %rdx
movq %rdx, 0x30(%rbx)
jmp 0x5774d
movq 0x8(%r14), %rdi
callq 0x120f0
movq %rax, %r12
incq %r12
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x57496
cmpl $0x0, (%r15)
jne 0x5774d
movq 0x28(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq 0x8(%r14), %rsi
callq 0x12070
addq %r12, 0x30(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e6e3(%rip), %rdx     # 0x75e40
movq %r15, %rdi
movl $0xf, %esi
movl $0x9a1, %ecx            # imm = 0x9A1
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x145f4