// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
movq 0x95ff(%rip), %rdi      # 0xc8e8
testq %rdi, %rdi
je 0x3303
callq 0x2050
andq $0x0, 0x95ed(%rip)      # 0xc8e8
andq $0x0, 0x95dd(%rip)      # 0xc8e0
movq 0x97ee(%rip), %rdi      # 0xcaf8
movq (%rdi), %rsi
cmpq $-0x1, %rsi
je 0x3441
movq 0x8(%rdi), %rax
cmpq %rsi, %rax
je 0x3441
jge 0x3356
movq %rax, %rsi
callq 0x2688
movq 0x97c3(%rip), %rcx      # 0xcaf8
movq 0x8(%rcx), %rax
movq 0x20(%rcx), %r14
testq %rax, %rax
movq %r14, (%rsp)
js 0x338d
addq %rax, %r14
movq 0x30(%rcx), %rsi
cmpq %rsi, %r14
jae 0x3383
xorl %edx, %edx
jmp 0x338a
callq 0x2688
movq 0x9796(%rip), %r13      # 0xcaf8
movq (%r13), %rax
movq 0x20(%r13), %rsi
movq %rsi, %r14
testq %rax, %rax
js 0x339c
leaq (%rsi,%rax), %r14
movq 0x30(%r13), %rdx
cmpq %rdx, %r14
jae 0x3392
xorl %ecx, %ecx
jmp 0x3399
movq 0x38(%rcx), %rdx
subq %rsi, %rdx
addq %rdx, %r14
movq %rcx, %r13
jmp 0x33a4
movq 0x38(%r13), %rcx
subq %rdx, %rcx
addq %rcx, %r14
movq %rsi, (%rsp)
leaq 0x8(%r13), %rcx
movq (%rcx), %r15
subq %rax, %r15
movq %r15, 0x952f(%rip)      # 0xc8e0
leaq 0x1(%r15), %rdi
callq 0x21f0
movq %rax, 0x9527(%rip)      # 0xc8e8
testq %rax, %rax
je 0x3405
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21e0
movb $0x0, (%r12,%r15)
testl %ebp, %ebp
je 0x3421
addq %r15, 0x38(%r13)
movq 0x30(%r13), %rax
subq (%rsp), %rax
movq %rax, 0x8(%r13)
orb $0x1, 0x14d(%r13)
testl %ebx, %ebx
je 0x3436
leaq 0x3d3f(%rip), %rdi      # 0x7142
jmp 0x342c
leaq 0x3d1c(%rip), %rdi      # 0x7128
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x24c3
testl %ebx, %ebx
je 0x3436
leaq 0x3d25(%rip), %rdi      # 0x7151
movq %r15, %rsi
xorl %eax, %eax
callq 0x24c3
movq 0x96bb(%rip), %rax      # 0xcaf8
orq $-0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq