// File: /workspace/github_c_makefile_star2_O1/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, %rcx
movq %rdi, %r15
cmpq $0x0, 0x8(%rdi)
movq %rdx, (%rsp)
movq %rdi, 0x18(%rsp)
movq %rsi, 0x8(%rsp)
je 0x57227
leaq 0x58(%rcx), %r12
leaq 0x88(%rcx), %rax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
movq %r12, 0x20(%rsp)
movq (%r15), %rax
movq (%rax,%r13,8), %rbp
movq 0x30(%rcx), %rdx
movq 0x80(%rcx), %rdi
movq %r13, %rsi
movq %rcx, %r14
callq 0x5a350
movq %rbp, (%r14)
movq 0x10(%rbp), %rax
movq %rax, 0x20(%r14)
xorl %eax, %eax
movq %rax, 0x70(%r14)
movq %rax, 0x48(%r14)
pxor %xmm0, %xmm0
movdqu %xmm0, (%r12)
movq 0x10(%rsp), %rax
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rax)
movq %r14, 0x28(%rsp)
leaq 0x721(%rip), %rax       # 0x57501
movq %rax, 0x38(%rsp)
leaq 0x79c(%rip), %rax       # 0x57588
movq %rax, 0x30(%rsp)
leaq 0x97f(%rip), %rax       # 0x57777
movq %rax, 0x40(%rsp)
leaq 0xb69(%rip), %rax       # 0x5796d
movq %rax, 0x48(%rsp)
leaq 0xc63(%rip), %rax       # 0x57a73
movq %rax, 0x50(%rsp)
leaq 0xc9d(%rip), %rax       # 0x57ab9
movq %rax, 0x58(%rsp)
leaq 0xcd7(%rip), %rax       # 0x57aff
movq %rax, 0x60(%rsp)
leaq 0xea8(%rip), %rax       # 0x57cdc
movq %rax, 0x68(%rsp)
leaq 0xfe3(%rip), %rax       # 0x57e23
movq %rax, 0x70(%rsp)
leaq 0x10c9(%rip), %rax      # 0x57f15
movq %rax, 0x78(%rsp)
leaq 0x1159(%rip), %rax      # 0x57fb1
movq %rax, 0x80(%rsp)
leaq 0x11ea(%rip), %rax      # 0x58051
movq %rax, 0x88(%rsp)
leaq 0x1290(%rip), %rax      # 0x58106
movq %rax, 0x90(%rsp)
leaq 0x12ee(%rip), %rax      # 0x58173
movq %rax, 0xa0(%rsp)
leaq 0x13fb(%rip), %rax      # 0x5828f
movq %rax, 0x98(%rsp)
leaq 0x14c6(%rip), %rax      # 0x58369
movq %rax, 0xa8(%rsp)
leaq 0x14ff(%rip), %rax      # 0x583b1
movq %rax, 0xb0(%rsp)
leaq 0x153b(%rip), %rax      # 0x583fc
movq %rax, 0xb8(%rsp)
leaq 0x164a(%rip), %rax      # 0x5851a
movq %rax, 0xc0(%rsp)
leaq 0x177e(%rip), %rax      # 0x5865d
movq %rax, 0xc8(%rsp)
leaq 0x1865(%rip), %rax      # 0x58753
movq %rax, 0xd0(%rsp)
leaq 0x18ef(%rip), %rax      # 0x587ec
movq %rax, 0xd8(%rsp)
leaq 0x1982(%rip), %rax      # 0x5888e
movq %rax, 0xe0(%rsp)
leaq 0x1aba(%rip), %rax      # 0x589d5
movq %rax, 0xe8(%rsp)
leaq 0x1bf3(%rip), %rax      # 0x58b1d
movq %rax, 0xf0(%rsp)
leaq 0x1c73(%rip), %rax      # 0x58bac
movq %rax, 0xf8(%rsp)
leaq 0x1e0a(%rip), %rax      # 0x58d52
movq %rax, 0x100(%rsp)
leaq 0x1fb7(%rip), %rax      # 0x58f0e
movq %rax, 0x108(%rsp)
leaq 0x2092(%rip), %rax      # 0x58ff8
movq %rax, 0x110(%rsp)
leaq 0x2235(%rip), %rax      # 0x591aa
movq %rax, 0x118(%rsp)
leaq 0x2373(%rip), %rax      # 0x592f7
movq %rax, 0x120(%rsp)
leaq 0x243d(%rip), %rax      # 0x593d0
movq %rax, 0x128(%rsp)
leaq 0x24f2(%rip), %rax      # 0x59494
movq %rax, 0x130(%rsp)
leaq 0x25c3(%rip), %rax      # 0x59574
movq %rax, 0x138(%rsp)
leaq 0x2738(%rip), %rax      # 0x596f8
movq %rax, 0x140(%rsp)
leaq 0x2822(%rip), %rax      # 0x597f1
movq %rax, 0x148(%rsp)
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x528e8
cmpl $0x0, (%rbx)
jne 0x5720c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x598fe
cmpl $0x0, (%rbx)
jne 0x5720c
cmpq $0x0, 0x70(%r14)
movq %r14, %r8
je 0x571da
movl $0x10, %ebp
xorl %r12d, %r12d
movq 0x68(%r8), %rbx
movq (%rbx,%rbp), %r14
testb $0x3, %r14b
je 0x5704f
movq (%rsp), %r15
movq %r15, %rdi
movl $0x5d, %esi
leaq 0x1ee05(%rip), %rdx     # 0x75e40
movl $0xee, %ecx
callq 0x145f4
movq 0x8(%rsp), %r8
xorl %r14d, %r14d
jmp 0x57057
addq 0x28(%r8), %r14
movq (%rsp), %r15
cmpl $0x0, (%r15)
movq 0x18(%rsp), %r15
jne 0x571da
movl -0x10(%rbx,%rbp), %eax
cmpl $0x1, %eax
je 0x570cd
testl %eax, %eax
jne 0x571a9
movq 0x10(%r8), %rcx
movq -0x8(%rbx,%rbp), %rdx
movq (%rbx,%rbp), %rax
movq (%rcx,%rdx,8), %rcx
movq %rcx, %rsi
subq %rax, %rsi
negq %rsi
movq %rcx, %rdx
subq %rax, %rdx
cmovbeq %rsi, %rdx
cmpq $0x800001, %rdx         # imm = 0x800001
jb 0x57120
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0xf, %esi
leaq 0x1ed89(%rip), %rdx     # 0x75e40
movl $0x91b, %ecx            # imm = 0x91B
callq 0x145f4
movq 0x8(%rsp), %r8
movl $0xfffffe, %eax         # imm = 0xFFFFFE
jmp 0x57143
movq 0x10(%r8), %rcx
movq -0x8(%rbx,%rbp), %rdx
movq (%rbx,%rbp), %rax
movq (%rcx,%rdx,8), %rcx
movq %rcx, %rsi
subq %rax, %rsi
negq %rsi
movq %rcx, %rdx
subq %rax, %rdx
cmovbeq %rsi, %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
je 0x5714d
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0xf, %esi
leaq 0x1ed33(%rip), %rdx     # 0x75e40
movl $0x91b, %ecx            # imm = 0x91B
callq 0x145f4
movq 0x8(%rsp), %r8
xorl %edi, %edi
jmp 0x5715b
movl %edx, %esi
negl %esi
cmpq %rax, %rcx
cmovael %edx, %esi
leal 0x3(%rsi), %eax
testl %esi, %esi
cmovnsl %esi, %eax
shrl $0x2, %eax
addl $0xfffffe, %eax         # imm = 0xFFFFFE
andl $0xffffff, %eax         # imm = 0xFFFFFF
movq (%rsp), %rbx
cmpl $0x0, (%rbx)
je 0x571a6
jmp 0x571da
movl %edx, %edi
negl %edi
cmpq %rax, %rcx
cmovael %edx, %edi
movq (%rsp), %rbx
cmpl $0x0, (%rbx)
jne 0x571da
cmpl $0x7, %edi
jg 0x57182
movl (%r14), %eax
movl $0xff3fffff, %ecx       # imm = 0xFF3FFFFF
andl %ecx, %eax
orl $0x400000, %eax         # imm = 0x400000
movl %eax, (%r14)
movl $0x8, %eax
subl %edi, %eax
movl %eax, %edi
jmp 0x57185
addl $-0x8, %edi
movq (%rsp), %rbx
leaq 0x150(%rsp), %rsi
callq 0x4f8d1
testb %al, %al
je 0x571bc
movl 0x150(%rsp), %eax
movq 0x8(%rsp), %r8
orl %eax, (%r14)
incq %r12
addq $0x18, %rbp
cmpq 0x70(%r8), %r12
jb 0x5701a
jmp 0x571da
movq %rbx, %rdi
movl $0x61, %esi
leaq 0x1ec75(%rip), %rdx     # 0x75e40
movl $0x94e, %ecx            # imm = 0x94E
callq 0x145f4
movq 0x8(%rsp), %r8
movl $0x9, 0x150(%rsp)
movl $0x4, 0x158(%rsp)
movq %r8, %rdi
leaq 0x150(%rsp), %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x57588
movq 0x20(%rsp), %r12
cmpl $0x0, (%rbx)
jne 0x573dd
incq %r13
cmpq 0x8(%r15), %r13
movq 0x8(%rsp), %rcx
jb 0x56d8b
movq 0x20(%r15), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x57396
shlq $0x3, %rdi
callq 0x121d0
testq %rax, %rax
je 0x573c4
movq %rax, %r13
movq 0x20(%r15), %rax
cmpq $0x0, (%rax)
movq 0x8(%rsp), %rcx
je 0x57399
xorl %r14d, %r14d
movq %r13, 0x10(%rsp)
movq 0x10(%rax), %rax
movq %rbx, %r15
leaq (%r14,%r14,2), %rbx
movq (%rax,%rbx,8), %rbp
addq $0x3, %rbp
andq $-0x4, %rbp
movq %rcx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %rcx, %r12
callq 0x57496
cmpl $0x0, (%r15)
jne 0x573ba
movq 0x30(%r12), %rdi
movq %rdi, (%r13,%r14,8)
movq 0x18(%rsp), %r15
movq 0x20(%r15), %rax
movq 0x10(%rax), %rax
leaq (%rax,%rbx,8), %r13
cmpb $0x1, 0x10(%r13)
jne 0x572f5
movq 0x40(%r15), %rax
testq %rax, %rax
je 0x572f5
cmpb $0x1, 0xc(%rax)
jne 0x572f5
testb $0x3, %dil
movq (%rsp), %rbx
je 0x57360
movq %rbx, %rdi
movl $0x5d, %esi
leaq 0x1eb59(%rip), %rdx     # 0x75e40
movl $0xee, %ecx
callq 0x145f4
xorl %edi, %edi
jmp 0x57365
addq 0x28(%r12), %rdi
movq (%r13), %rdx
movq 0x8(%r13), %rsi
callq 0x121b0
movq (%r13), %rax
movq %rax, %rcx
andq $0x3, %rcx
movq (%rsp), %rbx
je 0x57337
movl $0x4, %edx
subq %rcx, %rdx
movq 0x8(%rsp), %rcx
movq 0x28(%rcx), %rdi
addq 0x30(%rcx), %rdi
addq %rax, %rdi
xorl %esi, %esi
callq 0x12140
cmpl $0x0, (%rbx)
jne 0x573dd
movq 0x8(%rsp), %rcx
addq %rbp, 0x30(%rcx)
incq %r14
movq 0x20(%r15), %rax
cmpq (%rax), %r14
movq 0x10(%rsp), %r13
jb 0x57267
jmp 0x57399
addq 0x28(%r12), %rdi
cmpl $0x0, (%rbx)
jne 0x57337
movq (%r13), %rax
cmpq $0x8, %rax
jb 0x57337
shrq $0x3, %rax
movq 0x8(%r13), %rcx
xorl %edx, %edx
movl 0x4(%rcx,%rdx,8), %esi
movl %esi, (%rdi,%rdx,8)
movl (%rcx,%rdx,8), %esi
movl %esi, 0x4(%rdi,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x5737e
jmp 0x57337
xorl %r13d, %r13d
movq 0x80(%rcx), %rdi
movq 0x28(%rcx), %rsi
movq 0x30(%rcx), %rdx
movq 0x20(%r15), %rax
movq (%rax), %r8
movq %r13, %rcx
movq %rbx, %r9
callq 0x5a359
movq %r13, %rdi
callq 0x122c0
jmp 0x573dd
leaq 0x1ea75(%rip), %rdx     # 0x75e40
movq %rbx, %rdi
movl $0x1, %esi
movl $0xa1d, %ecx            # imm = 0xA1D
callq 0x145f4
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq