// File: /workspace/github_c_makefile_star2_O2/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 $0x18, %rsp
movq %r8, (%rsp)
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpl $0x2, %eax
je 0xbf86
cmpl $0x1, %eax
je 0xbf05
testl %eax, %eax
jne 0xc0e0
movq (%r12), %rdi
movl (%r15), %esi
pushq $0x1
popq %rdx
callq 0x9737
movq (%r14), %rbx
xorb $0x1, %bpl
movzbl %bpl, %ecx
movq (%rsp), %rdx
addl %ecx, (%rdx)
movq %rax, %r14
xorl %eax, %eax
leaq 0x14(%rsp), %r15
movl %eax, %r12d
cmpq %r12, 0x8(%rbx)
jbe 0xbfe2
andl $0x0, 0x14(%rsp)
movq (%rbx), %rax
movsbl (%rax,%r12), %ecx
movq %r14, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
xorl %r8d, %r8d
callq 0x98d7
leal 0x1(%r12), %eax
jmp 0xbed2
movl (%r15), %esi
pushq $0x1
popq %rdx
movq %r12, %rdi
callq 0x96e1
movq (%rax), %r15
testq %r15, %r15
je 0xc107
movl %ebp, 0x8(%rsp)
movl %ebp, %eax
xorb $0x1, %al
movzbl %al, %ebx
xorl %r12d, %r12d
pushq $0x20
popq %rbp
movq (%r14), %r14
testq %r14, %r14
je 0xc06c
xorl %eax, %eax
movl %eax, %r13d
cmpq %r13, 0x8(%r14)
jbe 0xbf7d
leal (%rbx,%r13), %eax
movq (%rsp), %rcx
addl (%rcx), %eax
movl %eax, 0x10(%rsp)
movl %r12d, 0xc(%rsp)
movq (%r14), %rax
movsbl (%rax,%r13), %ecx
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
movl %ebp, %r8d
callq 0x98d7
leal 0x1(%r13), %eax
jmp 0xbf3e
addq $0x18, %r14
incl %r12d
jmp 0xbf30
movq (%r14), %rdi
xorl %esi, %esi
callq 0x9292
movq %rax, %r14
movq %rax, %rdi
callq 0x9a32
movq %rax, %rbx
movl (%r15), %esi
testb %bpl, %bpl
je 0xc07b
movq (%r12), %rdi
testl %esi, %esi
je 0xc0ef
decl %esi
pushq $0x1
popq %rdx
callq 0x9737
movq 0x18(%rax), %rcx
movq %rax, 0x20(%r14)
movq %r14, 0x18(%rax)
movq %rcx, 0x18(%rbx)
testq %rcx, %rcx
je 0xc0e0
movq %rbx, 0x20(%rcx)
jmp 0xc0e0
movq (%rsp), %rax
movl (%rax), %r13d
movq 0x18(%rbx), %r12
testq %r12, %r12
je 0xc0d6
movq 0x8(%r14), %rbp
xorl %r15d, %r15d
movl $0x0, %ebx
cmpq %r13, %rbp
jbe 0xc029
movslq %r13d, %rdi
subl %r13d, %ebp
addq (%r14), %rdi
movq %rbp, %rsi
callq 0x5690
movq %rax, %rbx
movq (%rsp), %rax
movslq (%rax), %rax
movq %rax, 0x8(%r14)
movq %rbp, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x9292
movq %rax, %rbp
movq %rax, %rdi
callq 0x9a32
movq 0x18(%r14), %rcx
movq %rbp, 0x18(%r14)
movq %r14, 0x20(%rbp)
movq %rcx, 0x18(%rax)
testq %rcx, %rcx
je 0xc057
movq %rax, 0x20(%rcx)
testq %rbx, %rbx
je 0xc0d6
testq %r12, %r12
je 0xc0a7
movq 0x18(%r14), %r14
movq 0x18(%r12), %r12
jmp 0xc05c
cmpb $0x0, 0x8(%rsp)
jne 0xc0e0
movq (%rsp), %rax
incl (%rax)
jmp 0xc0e0
pushq $0x1
popq %rdx
movq %r12, %rdi
callq 0x96e1
movq (%rax), %rcx
movq 0x18(%rcx), %rax
movq %r14, 0x18(%rcx)
movq %rcx, 0x20(%r14)
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0xc0a2
movq %rbx, 0x20(%rax)
incl (%r15)
jmp 0xc0e0
movl 0x8(%r14), %eax
leal (%r15,%rax), %esi
incl %esi
movq %rsi, 0x10(%r14)
movq (%r14), %rdi
callq 0x5660
movq %rax, (%r14)
addq 0x8(%r14), %rax
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4360
addq %r15, 0x8(%r14)
leal -0x1(%r13), %eax
movq (%rsp), %rcx
movl %eax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andq $0x0, 0x20(%r14)
movq %r14, (%r12)
movq %rdi, 0x18(%rbx)
testq %rdi, %rdi
je 0xc0e0
movq %rbx, 0x20(%rdi)
jmp 0xc0e0
leaq 0x2813(%rip), %rdi      # 0xe921
leaq 0x27da(%rip), %rsi      # 0xe8ef
leaq 0x280a(%rip), %rcx      # 0xe926
movl $0xb4, %edx
callq 0x4210
nop