// File: /workspace/github_c_makefile_star2_O1/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 0xcc9b
movq %r8, %rbp
cmpl $0x1, %eax
movq %r8, 0x8(%rsp)
je 0xcbe2
testl %eax, %eax
jne 0xcd18
movq (%r15), %rdi
movl (%r14), %esi
movl $0x1, %ebx
movl $0x1, %edx
callq 0x9ede
movq (%r12), %r12
xorb $0x1, %r13b
movzbl %r13b, %ecx
addl %ecx, (%rbp)
movq %rax, %r14
cmpq $0x0, 0x8(%r12)
je 0xcb1b
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 0xa0a0
movl %ebx, %eax
incl %ebx
cmpq %rax, 0x8(%r12)
ja 0xcaef
movl (%rbp), %r13d
movq 0x18(%r12), %r12
testq %r12, %r12
je 0xcbd6
movq 0x8(%r14), %rbp
xorl %r15d, %r15d
movl $0x0, %ebx
cmpq %r13, %rbp
jbe 0xcb61
movslq %r13d, %rdi
subl %r13d, %ebp
addq (%r14), %rdi
movq %rbp, %rsi
callq 0x58a8
movq %rax, %rbx
movq 0x8(%rsp), %rax
movslq (%rax), %rax
movq %rax, 0x8(%r14)
movq %rbp, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x99b8
movq %rax, %rbp
movq %rax, %rdi
callq 0xa274
movq 0x18(%r14), %rcx
movq %rbp, 0x18(%r14)
movq %r14, 0x20(%rbp)
movq %rcx, 0x18(%rax)
testq %rcx, %rcx
je 0xcb8f
movq %rax, 0x20(%rcx)
testq %rbx, %rbx
movq 0x8(%rsp), %rbp
je 0xcbd6
movq 0x18(%r14), %r14
movq 0x18(%r12), %r12
testq %r12, %r12
jne 0xcb99
movl 0x8(%r14), %eax
leal (%r15,%rax), %esi
incl %esi
movq %rsi, 0x10(%r14)
movq (%r14), %rdi
callq 0x5851
movq %rax, (%r14)
addq 0x8(%r14), %rax
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4350
addq %r15, 0x8(%r14)
leal -0x1(%r13), %eax
movl %eax, (%rbp)
jmp 0xcd18
movl %r13d, 0x4(%rsp)
movl (%r14), %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x9e61
movq (%rax), %rbp
testq %rbp, %rbp
je 0xcd42
movq (%r12), %r12
testq %r12, %r12
je 0xcc87
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 0xcc7b
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 0xa0a0
movq 0x20(%rsp), %rsi
movl %r15d, %eax
incl %r15d
cmpq %rax, 0x8(%r12)
ja 0xcc36
incl %esi
movq 0x18(%r12), %r12
testq %r12, %r12
jne 0xcc21
cmpb $0x0, 0x4(%rsp)
movq 0x8(%rsp), %rax
jne 0xcd18
incl (%rax)
jmp 0xcd18
movq (%r12), %rdi
xorl %esi, %esi
callq 0x99b8
movq %rax, %r12
movq %rax, %rdi
callq 0xa274
movq %rax, %rbx
movl (%r14), %esi
testb %r13b, %r13b
je 0xcceb
movq (%r15), %rdi
testl %esi, %esi
je 0xcd27
decl %esi
movl $0x1, %edx
callq 0x9ede
movq 0x18(%rax), %rcx
movq %rax, 0x20(%r12)
movq %r12, 0x18(%rax)
movq %rcx, 0x18(%rbx)
testq %rcx, %rcx
je 0xcd18
movq %rbx, 0x20(%rcx)
jmp 0xcd18
movq %r15, %rdi
movl $0x1, %edx
callq 0x9e61
movq (%rax), %rcx
movq 0x18(%rcx), %rax
movq %r12, 0x18(%rcx)
movq %rcx, 0x20(%r12)
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0xcd15
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 0xcd18
movq %rbx, 0x20(%rdi)
jmp 0xcd18
leaq 0x2be8(%rip), %rdi      # 0xf931
leaq 0x2baf(%rip), %rsi      # 0xf8ff
leaq 0x2bdf(%rip), %rcx      # 0xf936
movl $0xb4, %edx
callq 0x4210
nopl (%rax)