// File: /workspace/github_c_makefile_star2_O3/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 0xa489(%rip), %rdi      # 0xd8e8
testq %rdi, %rdi
je 0x3479
callq 0x2050
xorl %eax, %eax
movq %rax, 0xa476(%rip)      # 0xd8e8
movq %rax, 0xa467(%rip)      # 0xd8e0
movq 0xa678(%rip), %rdi      # 0xdaf8
movq (%rdi), %rsi
cmpq $-0x1, %rsi
je 0x35ba
movq 0x8(%rdi), %rax
cmpq %rsi, %rax
je 0x35ba
jge 0x34cc
movq %rax, %rsi
callq 0x2699
movq 0xa64d(%rip), %rcx      # 0xdaf8
movq 0x8(%rcx), %rax
movq 0x20(%rcx), %r14
testq %rax, %rax
movq %r14, (%rsp)
js 0x3503
addq %rax, %r14
movq 0x30(%rcx), %rsi
cmpq %rsi, %r14
jae 0x34f9
xorl %edx, %edx
jmp 0x3500
callq 0x2699
movq 0xa620(%rip), %r13      # 0xdaf8
movq (%r13), %rax
movq 0x20(%r13), %rsi
movq %rsi, %r14
testq %rax, %rax
js 0x3512
leaq (%rsi,%rax), %r14
movq 0x30(%r13), %rdx
cmpq %rdx, %r14
jae 0x3508
xorl %ecx, %ecx
jmp 0x350f
movq 0x38(%rcx), %rdx
subq %rsi, %rdx
addq %rdx, %r14
movq %rcx, %r13
jmp 0x351a
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, 0xa3b9(%rip)      # 0xd8e0
leaq 0x1(%r15), %rdi
callq 0x21f0
movq %rax, 0xa3b1(%rip)      # 0xd8e8
testq %rax, %rax
je 0x357b
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21e0
movb $0x0, (%r12,%r15)
testl %ebp, %ebp
je 0x3597
addq %r15, 0x38(%r13)
movq 0x30(%r13), %rax
subq (%rsp), %rax
movq %rax, 0x8(%r13)
orb $0x1, 0x14d(%r13)
testl %ebx, %ebx
je 0x35ac
leaq 0x4bc9(%rip), %rdi      # 0x8142
jmp 0x35a2
leaq 0x4ba6(%rip), %rdi      # 0x8128
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x24cb
testl %ebx, %ebx
je 0x35ac
leaq 0x4baf(%rip), %rdi      # 0x8151
movq %r15, %rsi
xorl %eax, %eax
callq 0x24cb
movq 0xa545(%rip), %rax      # 0xdaf8
movq $-0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq