// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movl (%rsi), %eax
addl $-0x2, %eax
cmpl $0x7, %eax
ja 0x53da8
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1bfdf(%rip), %rcx     # 0x6fbf0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x4
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x53aff
cmpl $0x0, (%r15)
jne 0x53d9c
movl 0x8(%r14), %eax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
movl %eax, (%rcx,%rdx)
addq $0x4, %rdx
jmp 0x53d5e
pushq $0x8
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x53aff
cmpl $0x0, (%r15)
jne 0x53d9c
movsd 0x8(%r14), %xmm0
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
movsd %xmm0, (%rax,%rcx)
addq $0x8, %rcx
movq %rcx, 0x30(%rbx)
jmp 0x53d9c
pushq $0x1
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x53aff
cmpl $0x0, (%r15)
jne 0x53d9c
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 0x53d9c
pushq $0x2
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x53aff
cmpl $0x0, (%r15)
jne 0x53d9c
movzwl 0x8(%r14), %eax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
movw %ax, (%rcx,%rdx)
addq $0x2, %rdx
jmp 0x53d5e
movl 0x8(%r14), %r14d
leal -0x1(%r14), %eax
andl 0x30(%rbx), %eax
je 0x53d9c
subq %rax, %r14
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x53aff
cmpl $0x0, (%r15)
jne 0x53d9c
jmp 0x53d27
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rbx)
movb $0x0, (%rax,%rcx)
subq $0x1, %r14
jae 0x53d13
jmp 0x53d9c
pushq $0x8
popq %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x53aff
cmpl $0x0, (%r15)
jne 0x53d9c
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 0x53d9c
movq 0x8(%r14), %rdi
callq 0x120f0
movq %rax, %r12
incq %r12
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x53aff
cmpl $0x0, (%r15)
jne 0x53d9c
movq 0x28(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq 0x8(%r14), %rsi
callq 0x12070
addq %r12, 0x30(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1c041(%rip), %rdx     # 0x6fdf0
pushq $0xf
popq %rsi
movq %r15, %rdi
movl $0x9a1, %ecx            # imm = 0x9A1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1429e