// File: /workspace/github_c_makefile_star2_O1/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
cmpq $0x0, 0x48(%rdi)
je 0x59bf6
movq (%rbx), %r12
xorl %r13d, %r13d
movq 0x40(%rbx), %rax
movq %r13, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %rbp
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 0x599ee
cmpl $0x1, %eax
je 0x59993
cmpl $0x2, %eax
jne 0x59bde
movq 0x78(%r12), %rax
testq %rax, %rax
je 0x59ab0
movq 0x70(%r12), %rcx
movq (%rbp), %rdx
addq $0x8, %rcx
xorl %ebp, %ebp
cmpq %rdx, (%rcx)
je 0x59ab2
incq %rbp
addq $0x10, %rcx
cmpq %rbp, %rax
jne 0x59976
movq %rax, %rbp
jmp 0x59ab2
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x57496
cmpl $0x0, (%r14)
jne 0x59d22
movq 0x30(%rbx), %rdx
movq 0x80(%rbx), %rdi
movq 0x8(%rbp), %rcx
movq 0x10(%rbp), %rsi
movq %r14, %r8
callq 0x5a2f2
cmpl $0x0, (%r14)
jne 0x59d22
movq 0x30(%rbx), %rax
testb $0x3, %al
jne 0x59ba7
movq 0x28(%rbx), %rcx
movl $0x0, (%rcx,%rax)
jmp 0x59bcc
movq 0x60(%r12), %rax
testq %rax, %rax
je 0x59a1e
movq 0x58(%r12), %rcx
movq (%rbp), %rdx
addq $0x8, %rcx
xorl %r15d, %r15d
cmpq %rdx, (%rcx)
je 0x59a21
incq %r15
addq $0x18, %rcx
cmpq %r15, %rax
jne 0x59a08
movq %rax, %r15
jmp 0x59a21
xorl %r15d, %r15d
cmpq %rax, %r15
je 0x59cbf
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x57496
cmpl $0x0, (%r14)
jne 0x59d22
movq 0x58(%r12), %rax
leaq (%r15,%r15,2), %rcx
leaq (%rax,%rcx,8), %rax
cmpb $0x1, 0x10(%rax)
jne 0x59a8d
movslq (%rax), %rcx
movq 0x30(%rbx), %rdx
movq 0x80(%rbx), %rdi
movq 0x10(%rbp), %rsi
movq %r14, %r8
callq 0x5a227
movq 0x30(%rbx), %rax
testb $0x3, %al
jne 0x59ba7
movq 0x28(%rbx), %rcx
movl $0xffff, (%rcx,%rax)    # imm = 0xFFFF
jmp 0x59bcc
movq 0x30(%rbx), %rcx
testb $0x3, %cl
jne 0x59ba7
movl (%rax), %eax
movq 0x28(%rbx), %rdx
movl %eax, (%rdx,%rcx)
addq $0x4, %rcx
movq %rcx, 0x30(%rbx)
jmp 0x59bd4
xorl %ebp, %ebp
cmpq %rax, %rbp
je 0x59ca9
shlq $0x4, %rbp
addq 0x70(%r12), %rbp
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x57496
cmpl $0x0, (%r14)
jne 0x59d22
movq 0x30(%rbx), %rax
cmpb $0x1, 0x8(%rbx)
jne 0x59b07
testb $0x3, %al
je 0x59b26
movq %r14, %rdi
movl $0x5d, %esi
leaq 0x1c345(%rip), %rdx     # 0x75e40
movl $0xfb, %ecx
callq 0x145f4
jmp 0x59b38
testb $0x3, %al
je 0x59b69
movq %r14, %rdi
movl $0x5d, %esi
leaq 0x1c326(%rip), %rdx     # 0x75e40
movl $0xfb, %ecx
callq 0x145f4
jmp 0x59b7b
movl 0x4(%rbp), %ecx
movq 0x28(%rbx), %rdx
movl %ecx, (%rdx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%rbx)
cmpl $0x0, (%r14)
jne 0x59d22
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x57496
cmpl $0x0, (%r14)
jne 0x59d22
movq 0x30(%rbx), %rax
testb $0x3, %al
jne 0x59ba7
movl (%rbp), %ecx
jmp 0x59bc5
movl (%rbp), %ecx
movq 0x28(%rbx), %rdx
movl %ecx, (%rdx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%rbx)
cmpl $0x0, (%r14)
jne 0x59d22
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x57496
cmpl $0x0, (%r14)
jne 0x59d22
movq 0x30(%rbx), %rax
testb $0x3, %al
je 0x59bc2
movq %r14, %rdi
movl $0x5d, %esi
leaq 0x1c28a(%rip), %rdx     # 0x75e40
movl $0xfb, %ecx
callq 0x145f4
jmp 0x59bd4
movl 0x4(%rbp), %ecx
movq 0x28(%rbx), %rdx
movl %ecx, (%rdx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%rbx)
cmpl $0x0, (%r14)
jne 0x59d22
incq %r13
movq 0x48(%rbx), %rax
cmpq %rax, %r13
jb 0x59920
testq %rax, %rax
sete %al
jmp 0x59bf8
movb $0x1, %al
testb %al, %al
jne 0x59cff
movl $0x18, %r12d
xorl %r13d, %r13d
leaq 0x1c230(%rip), %r15     # 0x75e40
movq 0x10(%rbx), %rcx
movq 0x40(%rbx), %rdx
movq -0x18(%rdx,%r12), %rsi
movq -0x8(%rdx,%r12), %rax
movl (%rcx,%rsi,8), %ecx
subl %eax, %ecx
leal -0x8(%rcx), %ebp
cmpl $0x2, (%rdx,%r12)
jae 0x59c47
movl $0x8, %edx
subl %ecx, %edx
testl %ebp, %ebp
cmovsl %edx, %ebp
cmpl $0x1000, %ebp           # imm = 0x1000
jle 0x59c66
jmp 0x59ca2
jne 0x59c66
movl $0x8, %edx
subl %ecx, %edx
testl %ebp, %ebp
cmovnsl %ebp, %edx
cmpl $0x400, %edx            # imm = 0x400
jg 0x59ce6
shrl $0x2, %edx
movl %edx, %ebp
testb $0x3, %al
je 0x59c83
movq %r14, %rdi
movl $0x5d, %esi
movq %r15, %rdx
movl $0xee, %ecx
callq 0x145f4
xorl %eax, %eax
jmp 0x59c87
addq 0x28(%rbx), %rax
cmpl $0x0, (%r14)
jne 0x59cff
orl %ebp, (%rax)
incq %r13
addq $0x20, %r12
cmpq 0x48(%rbx), %r13
jb 0x59c10
jmp 0x59cff
movl $0x115, %ecx            # imm = 0x115
jmp 0x59ceb
leaq 0x1c190(%rip), %rdx     # 0x75e40
movq %r14, %rdi
movl $0xf, %esi
movl $0x166, %ecx            # imm = 0x166
jmp 0x59cd3
leaq 0x1c17a(%rip), %rdx     # 0x75e40
movq %r14, %rdi
movl $0xf, %esi
movl $0x13e, %ecx            # imm = 0x13E
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145f4
movl $0x11d, %ecx            # imm = 0x11D
leaq 0x1c14e(%rip), %rdx     # 0x75e40
movq %r14, %rdi
movl $0xf, %esi
callq 0x145f4
cmpl $0x0, (%r14)
jne 0x59d22
movq $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