// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/arch/arm32/arm_encode.c
// Function: prv_flush_constants
static void prv_flush_constants(subtilis_arm_encode_ud_t *ud,
				subtilis_error_t *err)
{
	size_t i;
	size_t j;
	subtilis_arm_encode_const_t *cnst;
	uint32_t *real_ptr;
	int32_t constant_index;
	subtilis_arm_section_t *arm_s = ud->arm_s;

	for (i = 0; i < ud->const_count; i++) {
		cnst = &ud->constants[i];
		ud->label_offsets[cnst->label] = ud->bytes_written;
		switch (cnst->type) {
		case SUBTILIS_ARM_ENCODE_BP_LDR:
			for (j = 0; j < arm_s->constants.ui32_count; j++)
				if (arm_s->constants.ui32[j].label ==
				    cnst->label)
					break;
			if (j == arm_s->constants.ui32_count) {
				subtilis_error_set_assertion_failed(err);
				return;
			}

			prv_ensure_code(ud, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			if (arm_s->constants.ui32[j].link_time) {
				constant_index =
				    arm_s->constants.ui32[j].integer;
				subtilis_arm_link_constant_add(
				    ud->link, cnst->code_index,
				    ud->bytes_written, constant_index, err);
				prv_add_word(ud, 0xffff, err);
			} else {
				prv_add_word(
				    ud, arm_s->constants.ui32[j].integer, err);
			}
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			break;
		case SUBTILIS_ARM_ENCODE_BP_LDRP:
			prv_ensure_code(ud, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			subtilis_arm_link_extref_add(ud->link, cnst->code_index,
						     ud->bytes_written,
						     cnst->section_label, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			prv_add_word(ud, 0, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			break;
		case SUBTILIS_ARM_ENCODE_BP_LDRF:
			for (j = 0; j < arm_s->constants.real_count; j++)
				if (arm_s->constants.real[j].label ==
				    cnst->label)
					break;
			if (j == arm_s->constants.real_count) {
				subtilis_error_set_assertion_failed(err);
				return;
			}
			real_ptr =
			    (uint32_t *)(void *)&arm_s->constants.real[j].real;
			prv_ensure_code(ud, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			if (ud->reverse_fpa_consts) {
				prv_add_word(ud, real_ptr[1], err);
				if (err->type != SUBTILIS_ERROR_OK)
					return;
				prv_ensure_code(ud, err);
				if (err->type != SUBTILIS_ERROR_OK)
					return;
				prv_add_word(ud, real_ptr[0], err);
				if (err->type != SUBTILIS_ERROR_OK)
					return;
			} else {
				prv_add_word(ud, real_ptr[0], err);
				if (err->type != SUBTILIS_ERROR_OK)
					return;
				prv_ensure_code(ud, err);
				if (err->type != SUBTILIS_ERROR_OK)
					return;
				prv_add_word(ud, real_ptr[1], err);
				if (err->type != SUBTILIS_ERROR_OK)
					return;
			}
			break;
		}
	}

	prv_apply_constants(ud, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	prv_reset_pool_state(ud);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r15
xorl %r12d, %r12d
movq 0x48(%rbx), %rax
cmpq %rax, %r12
jae 0x55db3
movq 0x40(%rbx), %rax
movq %r12, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %r13
movq 0x10(%rbx), %rdx
movq 0x30(%rbx), %rsi
movq (%rax,%rcx), %rdi
movq %rsi, (%rdx,%rdi,8)
movl 0x18(%rax,%rcx), %eax
testl %eax, %eax
je 0x55c4c
cmpl $0x1, %eax
je 0x55c08
cmpl $0x2, %eax
jne 0x55d72
movq 0x78(%r15), %rax
xorl %ebp, %ebp
movq %rax, %rcx
subq $0x1, %rcx
jb 0x55d8e
movq 0x70(%r15), %rdx
movq 0x8(%rdx,%rbp), %rdx
cmpq (%r13), %rdx
je 0x55ccb
addq $0x10, %rbp
movq %rcx, %rax
jmp 0x55be2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55e8e
cmpl $0x0, (%r14)
jne 0x55e78
movq 0x30(%rbx), %rdx
movq 0x80(%rbx), %rdi
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rsi
movq %r14, %r8
callq 0x5646f
cmpl $0x0, (%r14)
jne 0x55e78
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x55d60
movq 0x60(%r15), %rax
xorl %ebp, %ebp
movq %rax, %rcx
subq $0x1, %rcx
jb 0x55d7a
movq 0x58(%r15), %rdx
movq 0x8(%rdx,%rbp), %rdx
cmpq (%r13), %rdx
je 0x55c77
addq $0x18, %rbp
movq %rcx, %rax
jmp 0x55c55
testq %rax, %rax
je 0x55d7a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55e8e
cmpl $0x0, (%r14)
jne 0x55e78
movq 0x58(%r15), %rax
movl (%rax,%rbp), %esi
cmpb $0x1, 0x10(%rax,%rbp)
jne 0x55d5d
movslq %esi, %rcx
movq 0x30(%rbx), %rdx
movq 0x80(%rbx), %rdi
movq 0x10(%r13), %rsi
movq %r14, %r8
callq 0x563b0
movl $0xffff, %esi           # imm = 0xFFFF
jmp 0x55d5d
testq %rax, %rax
je 0x55d8e
movq 0x70(%r15), %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55e8e
cmpl $0x0, (%r14)
jne 0x55e78
cmpb $0x1, 0x8(%rbx)
jne 0x55d29
movl 0x4(%r13,%rbp), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x55e99
cmpl $0x0, (%r14)
jne 0x55e78
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55e8e
cmpl $0x0, (%r14)
jne 0x55e78
movl (%r13,%rbp), %esi
jmp 0x55d5d
movl (%r13,%rbp), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x55e99
cmpl $0x0, (%r14)
jne 0x55e78
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55e8e
cmpl $0x0, (%r14)
jne 0x55e78
movl 0x4(%r13,%rbp), %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x55e99
cmpl $0x0, (%r14)
jne 0x55e78
incq %r12
jmp 0x55b93
leaq 0x1a06f(%rip), %rdx     # 0x6fdf0
pushq $0xf
popq %rsi
movq %r14, %rdi
movl $0x13e, %ecx            # imm = 0x13E
jmp 0x55da0
leaq 0x1a05b(%rip), %rdx     # 0x6fdf0
pushq $0xf
popq %rsi
movq %r14, %rdi
movl $0x166, %ecx            # imm = 0x166
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1429e
pushq $0x18
popq %r15
xorl %r12d, %r12d
pushq $0x8
popq %rbp
cmpq %rax, %r12
jae 0x55e58
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq -0x18(%rcx,%r15), %rdx
movq -0x8(%rcx,%r15), %rsi
movl (%rax,%rdx,8), %eax
subl %esi, %eax
leal -0x8(%rax), %r13d
cmpl $0x2, (%rcx,%r15)
jae 0x55dfe
movl %ebp, %ecx
subl %eax, %ecx
testl %r13d, %r13d
cmovsl %ecx, %r13d
cmpl $0x1000, %r13d          # imm = 0x1000
jle 0x55e19
jmp 0x55e3a
jne 0x55e19
movl %ebp, %ecx
subl %eax, %ecx
testl %r13d, %r13d
cmovnsl %r13d, %ecx
cmpl $0x400, %ecx            # imm = 0x400
jg 0x55e41
shrl $0x2, %ecx
movl %ecx, %r13d
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5624d
cmpl $0x0, (%r14)
jne 0x55e78
orl %r13d, (%rax)
incq %r12
movq 0x48(%rbx), %rax
addq $0x20, %r15
jmp 0x55dbd
movl $0x115, %ecx            # imm = 0x115
jmp 0x55e46
movl $0x11d, %ecx            # imm = 0x11D
leaq 0x19fa3(%rip), %rdx     # 0x6fdf0
pushq $0xf
popq %rsi
movq %r14, %rdi
callq 0x1429e
cmpl $0x0, (%r14)
jne 0x55e78
andq $0x0, 0x48(%rbx)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x58(%rbx)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x88(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq