// File: /workspace/github_c_makefile_star2_O1/hughbarney[P]zepl/zepl.c
// Function: copy_cut
void copy_cut(int cut, int verbose)
{
	char_t *p;
	if (scrap != NULL) {
		free(scrap);
		scrap = NULL;
		nscrap = 0;
	}
	/* if no mark or point == marker, nothing doing */
	if (curbp->b_mark == NOMARK || curbp->b_point == curbp->b_mark) return;

	if (curbp->b_point < curbp->b_mark) {
		/* point above marker: move gap under point, region = marker - point */
		(void)movegap(curbp, curbp->b_point);
		p = ptr(curbp, curbp->b_point);
		nscrap = curbp->b_mark - curbp->b_point;
	} else {
		/* if point below marker: move gap under marker, region = point - marker */
		(void)movegap(curbp, curbp->b_mark);
		p = ptr(curbp, curbp->b_mark);
		nscrap = curbp->b_point - curbp->b_mark;
	}
	assert(nscrap > 0);
	if ((scrap = (char_t*) malloc(nscrap + 1)) == NULL) {
		msg("No more memory available.");
	} else {
		(void)memcpy(scrap, p, nscrap * sizeof (char_t));
		*(scrap + nscrap) = '\0';  /* null terminate for insert_string */
		if (cut) {
			curbp->b_egap += nscrap; /* if cut expand gap down */
			curbp->b_point = pos(curbp, curbp->b_egap); /* set point to after region */
			curbp->b_flags |= B_MODIFIED;
			if (verbose) msg("%ld bytes cut.", nscrap);
		} else {
			if (verbose) msg("%ld bytes copied.", nscrap);
		}
		curbp->b_mark = NOMARK;  /* unmark */
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movl %edi, %ebp
movq 0xa468(%rip), %rdi      # 0xd8e8
testq %rdi, %rdi
je 0x349a
callq 0x2050
xorl %eax, %eax
movq %rax, 0xa455(%rip)      # 0xd8e8
movq %rax, 0xa446(%rip)      # 0xd8e0
movq 0xa657(%rip), %rdi      # 0xdaf8
movq (%rdi), %rsi
cmpq $-0x1, %rsi
je 0x35cb
movq 0x8(%rdi), %rax
cmpq %rsi, %rax
je 0x35cb
jge 0x34e9
movq %rax, %rsi
callq 0x2692
movq 0xa62c(%rip), %rax      # 0xdaf8
movq 0x8(%rax), %rcx
movq 0x20(%rax), %r14
testq %rcx, %rcx
js 0x352b
addq %rcx, %r14
movq 0x30(%rax), %rsi
cmpq %rsi, %r14
jae 0x3511
xorl %edx, %edx
jmp 0x3518
callq 0x2692
movq 0xa603(%rip), %rax      # 0xdaf8
movq (%rax), %rcx
movq 0x20(%rax), %r14
testq %rcx, %rcx
js 0x3527
addq %rcx, %r14
movq 0x30(%rax), %rsi
cmpq %rsi, %r14
jae 0x351d
xorl %edx, %edx
jmp 0x3524
movq 0x38(%rax), %rdx
subq %rsi, %rdx
addq %rdx, %r14
jmp 0x352b
movq 0x38(%rax), %rdx
subq %rsi, %rdx
addq %rdx, %r14
addq $0x8, %rax
movq (%rax), %r15
subq %rcx, %r15
movq %r15, 0xa3a8(%rip)      # 0xd8e0
leaq 0x1(%r15), %rdi
callq 0x21f0
movq %rax, 0xa3a0(%rip)      # 0xd8e8
testq %rax, %rax
je 0x3592
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21e0
movb $0x0, (%r12,%r15)
testl %ebp, %ebp
je 0x35a8
movq 0xa58a(%rip), %rax      # 0xdaf8
addq %r15, 0x38(%rax)
movq 0x30(%rax), %rcx
subq 0x20(%rax), %rcx
movq %rcx, 0x8(%rax)
orb $0x1, 0x14d(%rax)
testl %ebx, %ebx
je 0x35bd
leaq 0x4bb2(%rip), %rdi      # 0x8142
jmp 0x35b3
leaq 0x4b8f(%rip), %rdi      # 0x8128
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x24cb
testl %ebx, %ebx
je 0x35bd
leaq 0x4b9e(%rip), %rdi      # 0x8151
movq %r15, %rsi
xorl %eax, %eax
callq 0x24cb
movq 0xa534(%rip), %rax      # 0xdaf8
movq $-0x1, (%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq