// File: /workspace/github_c_makefile_star2_O3/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 0x59dcc
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 0x59ab9
cmpl $0x1, %eax
je 0x59a5e
cmpl $0x2, %eax
jne 0x59cad
movq 0x78(%r12), %rax
testq %rax, %rax
je 0x59b5c
movq 0x70(%r12), %rcx
movq (%rbp), %rdx
addq $0x8, %rcx
xorl %ebp, %ebp
cmpq %rdx, (%rcx)
je 0x59b5e
incq %rbp
addq $0x10, %rcx
cmpq %rbp, %rax
jne 0x59a44
jmp 0x59d85
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5758f
cmpl $0x0, (%r14)
jne 0x59def
movq 0x30(%rbx), %rdx
movq 0x80(%rbx), %rdi
movq 0x8(%rbp), %rcx
movq 0x10(%rbp), %rsi
movq %r14, %r8
callq 0x5a3a7
cmpl $0x0, (%r14)
jne 0x59def
movq 0x30(%rbx), %rax
testb $0x3, %al
jne 0x59c76
movq 0x28(%rbx), %rcx
movl $0x0, (%rcx,%rax)
jmp 0x59c9b
movq 0x60(%r12), %rax
testq %rax, %rax
je 0x59ae9
movq 0x58(%r12), %rcx
movq (%rbp), %rdx
addq $0x8, %rcx
xorl %r15d, %r15d
cmpq %rdx, (%rcx)
je 0x59aec
incq %r15
addq $0x18, %rcx
cmpq %r15, %rax
jne 0x59ad3
jmp 0x59d6f
xorl %r15d, %r15d
cmpq %rax, %r15
je 0x59d6f
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5758f
cmpl $0x0, (%r14)
jne 0x59def
movq 0x58(%r12), %rax
leaq (%r15,%r15,2), %rcx
leaq (%rax,%rcx,8), %rax
cmpb $0x1, 0x10(%rax)
jne 0x59bb3
movslq (%rax), %rcx
movq 0x30(%rbx), %rdx
movq 0x80(%rbx), %rdi
movq 0x10(%rbp), %rsi
movq %r14, %r8
callq 0x5a2dc
movq 0x30(%rbx), %rax
testb $0x3, %al
jne 0x59c76
movq 0x28(%rbx), %rcx
movl $0xffff, (%rcx,%rax)    # imm = 0xFFFF
jmp 0x59c9b
xorl %ebp, %ebp
cmpq %rax, %rbp
je 0x59d85
shlq $0x4, %rbp
addq 0x70(%r12), %rbp
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5758f
cmpl $0x0, (%r14)
jne 0x59def
movq 0x30(%rbx), %rax
cmpb $0x1, 0x8(%rbx)
jne 0x59bd6
testb $0x3, %al
je 0x59bf5
movq %r14, %rdi
movl $0x5d, %esi
leaq 0x1c2d9(%rip), %rdx     # 0x75e80
movl $0xfb, %ecx
callq 0x145a4
jmp 0x59c07
movq 0x30(%rbx), %rcx
testb $0x3, %cl
jne 0x59c76
movl (%rax), %eax
movq 0x28(%rbx), %rdx
movl %eax, (%rdx,%rcx)
addq $0x4, %rcx
movq %rcx, 0x30(%rbx)
jmp 0x59ca3
testb $0x3, %al
je 0x59c38
movq %r14, %rdi
movl $0x5d, %esi
leaq 0x1c297(%rip), %rdx     # 0x75e80
movl $0xfb, %ecx
callq 0x145a4
jmp 0x59c4a
movl 0x4(%rbp), %ecx
movq 0x28(%rbx), %rdx
movl %ecx, (%rdx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%rbx)
cmpl $0x0, (%r14)
jne 0x59def
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5758f
cmpl $0x0, (%r14)
jne 0x59def
movq 0x30(%rbx), %rax
testb $0x3, %al
jne 0x59c76
movl (%rbp), %ecx
jmp 0x59c94
movl (%rbp), %ecx
movq 0x28(%rbx), %rdx
movl %ecx, (%rdx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%rbx)
cmpl $0x0, (%r14)
jne 0x59def
movl $0x4, %esi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5758f
cmpl $0x0, (%r14)
jne 0x59def
movq 0x30(%rbx), %rax
testb $0x3, %al
je 0x59c91
movq %r14, %rdi
movl $0x5d, %esi
leaq 0x1c1fb(%rip), %rdx     # 0x75e80
movl $0xfb, %ecx
callq 0x145a4
jmp 0x59ca3
movl 0x4(%rbp), %ecx
movq 0x28(%rbx), %rdx
movl %ecx, (%rdx,%rax)
addq $0x4, %rax
movq %rax, 0x30(%rbx)
cmpl $0x0, (%r14)
jne 0x59def
incq %r13
movq 0x48(%rbx), %rax
cmpq %rax, %r13
jb 0x599ee
testq %rax, %rax
je 0x59dcc
movl $0x18, %r12d
xorl %r13d, %r13d
leaq 0x1c1aa(%rip), %r15     # 0x75e80
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 0x59d10
movl $0x8, %edx
subl %ecx, %edx
testl %ebp, %ebp
cmovsl %edx, %ebp
cmpl $0x1000, %ebp           # imm = 0x1000
jle 0x59d2f
jmp 0x59dac
jne 0x59d2f
movl $0x8, %edx
subl %ecx, %edx
testl %ebp, %ebp
cmovnsl %ebp, %edx
cmpl $0x400, %edx            # imm = 0x400
jg 0x59db3
shrl $0x2, %edx
movl %edx, %ebp
testb $0x3, %al
je 0x59d4c
movq %r14, %rdi
movl $0x5d, %esi
movq %r15, %rdx
movl $0xee, %ecx
callq 0x145a4
xorl %eax, %eax
jmp 0x59d50
addq 0x28(%rbx), %rax
cmpl $0x0, (%r14)
jne 0x59def
orl %ebp, (%rax)
incq %r13
addq $0x20, %r12
cmpq 0x48(%rbx), %r13
jb 0x59cd6
jmp 0x59dcc
leaq 0x1c10a(%rip), %rdx     # 0x75e80
movq %r14, %rdi
movl $0xf, %esi
movl $0x13e, %ecx            # imm = 0x13E
jmp 0x59d99
leaq 0x1c0f4(%rip), %rdx     # 0x75e80
movq %r14, %rdi
movl $0xf, %esi
movl $0x166, %ecx            # imm = 0x166
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x145a4
movl $0x115, %ecx            # imm = 0x115
jmp 0x59db8
movl $0x11d, %ecx            # imm = 0x11D
leaq 0x1c0c1(%rip), %rdx     # 0x75e80
movq %r14, %rdi
movl $0xf, %esi
callq 0x145a4
cmpl $0x0, (%r14)
jne 0x59def
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