// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/arch/arm32/arm_encode.c
// Function: prv_encode_prog
static void prv_encode_prog(subtilis_arm_prog_t *arm_p,
			    subtilis_arm_encode_ud_t *ud, subtilis_error_t *err)
{
	subtilis_arm_section_t *arm_s;
	size_t i;
	size_t size_in_bytes;
	size_t size_in_words;
	size_t *const_locations = NULL;

	for (i = 0; i < arm_p->num_sections; i++) {
		arm_s = arm_p->sections[i];
		subtilis_arm_link_section(ud->link, i, ud->bytes_written);
		prv_reset_encode_ud(ud, arm_s);
		prv_arm_encode(arm_s, ud, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	/* Let's write the constants arrays and strings */

	if (arm_p->constant_pool->size > 0) {
		const_locations = malloc(arm_p->constant_pool->size *
					 sizeof(*const_locations));
		if (!const_locations) {
			subtilis_error_set_oom(err);
			return;
		}
		for (i = 0; i < arm_p->constant_pool->size; i++) {
			size_in_bytes = arm_p->constant_pool->data[i].data_size;
			size_in_words = size_in_bytes >> 2;
			if (size_in_bytes > size_in_words << 2)
				size_in_bytes = (size_in_words + 1) << 2;
			prv_ensure_code_size(ud, size_in_bytes, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
			const_locations[i] = ud->bytes_written;
			prv_copy_constant_to_buf(
			    arm_p, ud, &arm_p->constant_pool->data[i], err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			ud->bytes_written += size_in_bytes;
		}
	}

	subtilis_arm_link_link(ud->link, ud->code, ud->bytes_written,
			       const_locations, arm_p->constant_pool->size,
			       err);

cleanup:

	free(const_locations);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x58(%rsi), %rax
movq %rax, 0x20(%rsp)
leaq 0x88(%rsi), %rax
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
movq %rdi, 0x10(%rsp)
cmpq 0x8(%rdi), %r15
jae 0x538c6
movq (%rdi), %rax
movq (%rax,%r15,8), %r13
movq 0x30(%r14), %rdx
movq 0x80(%r14), %rdi
movq %r15, %rsi
callq 0x564cd
movq %r13, (%r14)
movq 0x10(%r13), %rax
movq %rax, 0x20(%r14)
andq $0x0, 0x70(%r14)
andq $0x0, 0x48(%r14)
movq 0x20(%rsp), %rax
pxor %xmm0, %xmm0
movdqu %xmm0, (%rax)
movq 0x18(%rsp), %rax
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rax)
movq %r14, 0x28(%rsp)
leaq 0x60b(%rip), %rax       # 0x53b68
movq %rax, 0x38(%rsp)
leaq 0x682(%rip), %rax       # 0x53beb
movq %rax, 0x30(%rsp)
leaq 0x855(%rip), %rax       # 0x53dca
movq %rax, 0x40(%rsp)
leaq 0xa04(%rip), %rax       # 0x53f85
movq %rax, 0x48(%rsp)
leaq 0xaf5(%rip), %rax       # 0x54082
movq %rax, 0x50(%rsp)
leaq 0xb2d(%rip), %rax       # 0x540c6
movq %rax, 0x58(%rsp)
leaq 0xb65(%rip), %rax       # 0x5410a
movq %rax, 0x60(%rsp)
leaq 0xd20(%rip), %rax       # 0x542d1
movq %rax, 0x68(%rsp)
leaq 0xe30(%rip), %rax       # 0x543ed
movq %rax, 0x70(%rsp)
leaq 0xef0(%rip), %rax       # 0x544b9
movq %rax, 0x78(%rsp)
leaq 0xf50(%rip), %rax       # 0x54525
movq %rax, 0x80(%rsp)
leaq 0xfda(%rip), %rax       # 0x545be
movq %rax, 0x88(%rsp)
leaq 0x1070(%rip), %rax      # 0x54663
movq %rax, 0x90(%rsp)
leaq 0x10c7(%rip), %rax      # 0x546c9
movq %rax, 0xa0(%rsp)
leaq 0x11b3(%rip), %rax      # 0x547c4
movq %rax, 0x98(%rsp)
leaq 0x1254(%rip), %rax      # 0x54874
movq %rax, 0xa8(%rsp)
leaq 0x128b(%rip), %rax      # 0x548ba
movq %rax, 0xb0(%rsp)
leaq 0x12c3(%rip), %rax      # 0x54901
movq %rax, 0xb8(%rsp)
leaq 0x13a7(%rip), %rax      # 0x549f4
movq %rax, 0xc0(%rsp)
leaq 0x14a1(%rip), %rax      # 0x54afd
movq %rax, 0xc8(%rsp)
leaq 0x156a(%rip), %rax      # 0x54bd5
movq %rax, 0xd0(%rsp)
leaq 0x15ea(%rip), %rax      # 0x54c64
movq %rax, 0xd8(%rsp)
leaq 0x1651(%rip), %rax      # 0x54cda
movq %rax, 0xe0(%rsp)
leaq 0x1758(%rip), %rax      # 0x54df0
movq %rax, 0xe8(%rsp)
leaq 0x184f(%rip), %rax      # 0x54ef6
movq %rax, 0xf0(%rsp)
leaq 0x18c5(%rip), %rax      # 0x54f7b
movq %rax, 0xf8(%rsp)
leaq 0x1a83(%rip), %rax      # 0x55148
movq %rax, 0x100(%rsp)
leaq 0x1c12(%rip), %rax      # 0x552e6
movq %rax, 0x108(%rsp)
leaq 0x1cbc(%rip), %rax      # 0x5539f
movq %rax, 0x110(%rsp)
leaq 0x1e40(%rip), %rax      # 0x55532
movq %rax, 0x118(%rsp)
leaq 0x1f55(%rip), %rax      # 0x55656
movq %rax, 0x120(%rsp)
leaq 0x2000(%rip), %rax      # 0x55710
movq %rax, 0x128(%rsp)
leaq 0x2086(%rip), %rax      # 0x557a5
movq %rax, 0x130(%rsp)
leaq 0x2138(%rip), %rax      # 0x55866
movq %rax, 0x138(%rsp)
leaq 0x2284(%rip), %rax      # 0x559c1
movq %rax, 0x140(%rsp)
leaq 0x2349(%rip), %rax      # 0x55a95
movq %rax, 0x148(%rsp)
movq %r13, %rdi
leaq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x4f404
cmpl $0x0, (%rbx)
jne 0x53a43
movq %r14, %rdi
movq %rbx, %rsi
callq 0x55b7c
cmpl $0x0, (%rbx)
jne 0x53a43
movq %r15, (%rsp)
pushq $0x10
popq %rbp
xorl %r15d, %r15d
cmpq 0x70(%r14), %r15
jae 0x53883
movq 0x68(%r14), %r12
movq (%r12,%rbp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x5624d
cmpl $0x0, (%rbx)
jne 0x53883
movq %rax, %r13
movl -0x10(%r12,%rbp), %eax
cmpl $0x1, %eax
je 0x537ff
testl %eax, %eax
jne 0x53860
movq 0x10(%r14), %rax
movq -0x8(%r12,%rbp), %rcx
movq (%r12,%rbp), %rsi
movq (%rax,%rcx,8), %rdi
movl $0x800000, %edx         # imm = 0x800000
movq %rbx, %rcx
callq 0x5627b
cmpl $0x0, (%rbx)
jne 0x53883
cltd
pushq $0x4
popq %rcx
idivl %ecx
addl $0xfffffe, %eax         # imm = 0xFFFFFE
andl $0xffffff, %eax         # imm = 0xFFFFFF
jmp 0x5385c
movq 0x10(%r14), %rax
movq -0x8(%r12,%rbp), %rcx
movq (%r12,%rbp), %rsi
movq (%rax,%rcx,8), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rbx, %rcx
callq 0x5627b
cmpl $0x0, (%rbx)
jne 0x53883
cmpl $0x7, %eax
jg 0x53845
movl (%r13), %ecx
movl $0xff3fffff, %edx       # imm = 0xFF3FFFFF
andl %edx, %ecx
orl $0x400000, %ecx         # imm = 0x400000
movl %ecx, (%r13)
pushq $0x8
popq %rcx
subl %eax, %ecx
movl %ecx, %eax
jmp 0x53848
addl $-0x8, %eax
movl %eax, %edi
leaq 0xc(%rsp), %rsi
callq 0x4caab
testb %al, %al
je 0x5386c
movl 0xc(%rsp), %eax
orl %eax, (%r13)
incq %r15
addq $0x18, %rbp
jmp 0x5378b
movq %rbx, %rdi
pushq $0x61
popq %rsi
leaq 0x1c577(%rip), %rdx     # 0x6fdf0
movl $0x94e, %ecx            # imm = 0x94E
callq 0x1429e
movl $0x9, 0x150(%rsp)
movl $0x4, 0x158(%rsp)
movq %r14, %rdi
leaq 0x150(%rsp), %rsi
movq %rbx, %rdx
callq 0x53beb
movq (%rsp), %r15
incq %r15
cmpl $0x0, (%rbx)
movq 0x10(%rsp), %rdi
je 0x534fe
jmp 0x53a43
movq 0x20(%rdi), %rbp
movq (%rbp), %r13
testq %r13, %r13
je 0x539f9
leaq (,%r13,8), %rdi
callq 0x121d0
testq %rax, %rax
je 0x53a01
movq %rax, (%rsp)
xorl %r15d, %r15d
cmpq %r13, %r15
jae 0x53a1a
movq 0x10(%rbp), %rax
imulq $0x18, %r15, %r12
movq (%rax,%r12), %r13
addq $0x3, %r13
andq $-0x4, %r13
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x53aff
cmpl $0x0, (%rbx)
jne 0x53a55
movq 0x30(%r14), %rax
movq (%rsp), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x10(%rsp), %rdx
movq 0x20(%rdx), %rcx
movq 0x10(%rcx), %rcx
leaq (%rcx,%r12), %rbp
cmpb $0x1, 0x10(%rcx,%r12)
movq %rdx, %r12
jne 0x5399d
movq 0x40(%r12), %rcx
testq %rcx, %rcx
je 0x5399d
cmpb $0x1, 0xc(%rcx)
jne 0x5399d
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x5624d
cmpl $0x0, (%rbx)
jne 0x53a43
movq (%rbp), %rcx
shrq $0x3, %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x539df
movq 0x8(%rbp), %rsi
movl 0x4(%rsi,%rdx,8), %edi
movl %edi, (%rax,%rdx,8)
movl (%rsi,%rdx,8), %esi
movl %esi, 0x4(%rax,%rdx,8)
incq %rdx
jmp 0x53981
addq 0x28(%r14), %rax
movq (%rbp), %rdx
movq 0x8(%rbp), %rsi
movq %rax, %rdi
callq 0x121b0
movq (%rbp), %rdx
movq %rdx, %rcx
andq $0x3, %rcx
je 0x539df
pushq $0x4
popq %rax
subq %rcx, %rax
movq 0x28(%r14), %rcx
addq 0x30(%r14), %rcx
addq %rdx, %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x539df
movb $0x0, (%rcx,%rdx)
incq %rdx
jmp 0x539d1
cmpl $0x0, (%rbx)
jne 0x53a43
addq %r13, 0x30(%r14)
incq %r15
movq 0x20(%r12), %rbp
movq (%rbp), %r13
jmp 0x538f4
xorl %r13d, %r13d
xorl %r15d, %r15d
jmp 0x53a1e
leaq 0x1c3e8(%rip), %rdx     # 0x6fdf0
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl $0xa1d, %ecx            # imm = 0xA1D
callq 0x1429e
jmp 0x53a43
movq (%rsp), %r15
movq 0x80(%r14), %rdi
movq 0x28(%r14), %rsi
movq 0x30(%r14), %rdx
movq %r15, %rcx
movq %r13, %r8
movq %rbx, %r9
callq 0x564d6
movq %r15, %rdi
callq 0x122c0
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %r15
jmp 0x53a3b