// File: /workspace/github_c_makefile_star2_O3/bobrippling[P]tim/yank.c
// Function: yank_put_in_list
void yank_put_in_list(
		const yank *ynk,
		list_t **const phead,
		const bool prepend,
		int *py, int *px)
{
	switch(ynk->as){
		case REGION_CHAR:
			charwise_put(ynk, list_seek(*phead, *py, true), px, prepend);
			break;

		case REGION_LINE:
		{
			list_t *copy = list_copy_deep(ynk->list, NULL);
			list_t *copy_tail = list_tail(copy);

			if(prepend){
				if(*py == 0){
					list_t *head = *phead;

					copy->prev = NULL;
					*phead = copy;

					copy_tail->next = head;
					if(head)
						head->prev = copy_tail;
				}else{
					list_t *before = list_seek(*phead, *py - 1, true);
					list_t *after = before->next;

					copy->prev = before;
					before->next = copy;

					copy_tail->next = after;
					if(after)
						after->prev = copy_tail;
				}
			}else{
				list_t *const head = *list_seekp(phead, *py, true);
				list_t *const after = head->next;

				/* top link */
				head->next = copy;
				copy->prev = head;

				/* bottom link */
				copy_tail->next = after;
				if(after)
					after->prev = copy_tail;

				++*py;
			}
			break;
		}
		case REGION_COL:
		{
			list_t *head = *list_seekp(phead, *py, true);
			assert(head);
			int y = 0;
			for(const list_t *l = ynk->list;
			    l; l = l->next, y++)
			{
				for(unsigned i = 0; i < l->len_line; i++)
					list_inschar(head,
							&(int){ *px + !prepend + i },
							&(int){ y },
							l->line[i], /* force spaces to fill in for now */' ');
			}

			if(!prepend)
				++*px;
			break;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r14
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %r12
movl 0x8(%rdi), %eax
cmpl $0x2, %eax
je 0xc902
movq %r8, %rbp
cmpl $0x1, %eax
movq %r8, 0x8(%rsp)
je 0xc849
testl %eax, %eax
jne 0xc97f
movq (%r15), %rdi
movl (%r14), %esi
movl $0x1, %ebx
movl $0x1, %edx
callq 0x9d35
movq %rax, %r14
xorb $0x1, %r13b
movzbl %r13b, %r13d
addl (%rbp), %r13d
movq (%r12), %r12
movl %r13d, (%rbp)
cmpq $0x0, 0x8(%r12)
je 0xc784
xorl %eax, %eax
leaq 0x1c(%rsp), %r15
movl $0x0, 0x1c(%rsp)
movq (%r12), %rcx
movsbl (%rcx,%rax), %ecx
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x9efa
movl %ebx, %eax
incl %ebx
cmpq %rax, 0x8(%r12)
ja 0xc754
movl (%rbp), %r13d
movq 0x18(%r12), %r15
testq %r15, %r15
je 0xc83d
movl %r13d, %eax
movq 0x8(%r14), %rbp
xorl %r12d, %r12d
movl $0x0, %ebx
cmpq %rax, %rbp
jbe 0xc7c9
movslq %r13d, %rdi
subl %r13d, %ebp
addq (%r14), %rdi
movq %rbp, %rsi
callq 0x5889
movq %rax, %rbx
movq 0x8(%rsp), %rax
movslq (%rax), %rax
movq %rax, 0x8(%r14)
movq %rbp, %r12
movq %r15, %rdi
xorl %esi, %esi
callq 0x9818
movq %rax, %rbp
movq %rax, %rdi
callq 0xa0ab
movq 0x18(%r14), %rcx
movq %rbp, 0x18(%r14)
movq %r14, 0x20(%rbp)
movq %rcx, 0x18(%rax)
testq %rcx, %rcx
je 0xc7f7
movq %rax, 0x20(%rcx)
testq %rbx, %rbx
movq 0x8(%rsp), %rbp
je 0xc83d
movq 0x18(%r14), %r14
movq 0x18(%r15), %r15
testq %r15, %r15
jne 0xc801
movl 0x8(%r14), %eax
leal (%r12,%rax), %esi
incl %esi
movq %rsi, 0x10(%r14)
movq (%r14), %rdi
callq 0x584a
movq %rax, (%r14)
addq 0x8(%r14), %rax
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4360
addq %r12, 0x8(%r14)
decl %r13d
movl %r13d, (%rbp)
jmp 0xc97f
movl %r13d, 0x4(%rsp)
movl (%r14), %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x9cb6
movq (%rax), %rbp
testq %rbp, %rbp
je 0xc9a9
movq (%r12), %r12
testq %r12, %r12
je 0xc8ee
movl 0x4(%rsp), %eax
xorb $0x1, %al
movzbl %al, %ebx
xorl %esi, %esi
leaq 0x18(%rsp), %r14
leaq 0x14(%rsp), %r13
cmpq $0x0, 0x8(%r12)
je 0xc8e2
movl $0x1, %r15d
xorl %eax, %eax
movq %rsi, 0x20(%rsp)
movq 0x8(%rsp), %rcx
movl (%rcx), %ecx
leal (%rbx,%r15), %edi
addl %edi, %ecx
decl %ecx
movl %ecx, 0x18(%rsp)
movl %esi, 0x14(%rsp)
movq (%r12), %rcx
movsbl (%rcx,%rax), %ecx
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl $0x20, %r8d
callq 0x9efa
movq 0x20(%rsp), %rsi
movl %r15d, %eax
incl %r15d
cmpq %rax, 0x8(%r12)
ja 0xc89d
incl %esi
movq 0x18(%r12), %r12
testq %r12, %r12
jne 0xc888
cmpb $0x0, 0x4(%rsp)
movq 0x8(%rsp), %rax
jne 0xc97f
incl (%rax)
jmp 0xc97f
movq (%r12), %rdi
xorl %esi, %esi
callq 0x9818
movq %rax, %r12
movq %rax, %rdi
callq 0xa0ab
movq %rax, %rbx
movl (%r14), %esi
testb %r13b, %r13b
je 0xc952
movq (%r15), %rdi
testl %esi, %esi
je 0xc98e
decl %esi
movl $0x1, %edx
callq 0x9d35
movq 0x18(%rax), %rcx
movq %rax, 0x20(%r12)
movq %r12, 0x18(%rax)
movq %rcx, 0x18(%rbx)
testq %rcx, %rcx
je 0xc97f
movq %rbx, 0x20(%rcx)
jmp 0xc97f
movq %r15, %rdi
movl $0x1, %edx
callq 0x9cb6
movq (%rax), %rcx
movq 0x18(%rcx), %rax
movq %r12, 0x18(%rcx)
movq %rcx, 0x20(%r12)
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0xc97c
movq %rbx, 0x20(%rax)
incl (%r14)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x0, 0x20(%r12)
movq %r12, (%r15)
movq %rdi, 0x18(%rbx)
testq %rdi, %rdi
je 0xc97f
movq %rbx, 0x20(%rdi)
jmp 0xc97f
leaq 0x1f71(%rip), %rdi      # 0xe921
leaq 0x1f38(%rip), %rsi      # 0xe8ef
leaq 0x1f68(%rip), %rcx      # 0xe926
movl $0xb4, %edx
callq 0x4210