// File: /workspace/github_cpp_makefile_star2_O2/arnoldrobbins[P]mcilroy-regex/sed1.cpp
// Function: sc(Text*, Text*)
void
sc(Text *script, Text *t)
{
	int c, flags, re;
	int *q;
	int n = -1;
	int nsub;
	int delim = *t->w++;
	switch(delim) {
	case '\n':
	case '\\':
		syntax("improper delimiter");
	}
	re = recomp(&rebuf, t, delim);
	putint(script, re);
	nsub = readdr(re)->re_nsub;
	flags = script->w - script->s;
	putint(script, 0);		/* space for flags */
	while((c=*t->w++) != delim) {
		assure(script, 3+sizeof(int*));
		if(c == '\n')
			syntax("unterminated command");
		else if(c == '\\') {
			int d = *t->w;
			if(d==delim)
				;
			else if(d=='&' || d=='\\')
				*script->w++ = c;
			else if(d>='0' && d<='9') {
				if(d > '0'+nsub)
					syntax("improper backreference");
				*script->w++ = c;
			}
			c = *t->w++;
		}
		*script->w++ = c;
	}
	*script->w++ = 0;
	script->w = (uchar*)intp(script->w);
	q = (int*)(script->s + flags);
	*q = 0;
	for(;;) {
		switch(*t->w) {
		case '0': case '1': case '2': case '3': case '4':
		case '5': case '6': case '7': case '8': case '9':
			if(n != -1)
				syntax("extra flags");
			n = number(t);
			if(n == 0 || (n&(PFLAG|WFLAG)) != 0)
				syntax("count out of range");
			continue;
		case 'p':
			if(*q & PFLAG)
				syntax("extra flags");
			t->w++;
			*q |= PFLAG;
			continue;
		case 'g':
			t->w++;
			if(n != -1)
				syntax("extra flags");
			n = 0;
			continue;
		case 'w':
			t->w++;
			*q |= WFLAG;	 
			wc(script, t);
		}
		break;
	}
	*q |= n==-1? 1: n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsi)
movzbl (%rax), %ebp
cmpl $0x5c, %ebp
je 0x6618
cmpl $0xa, %ebp
jne 0x6624
leaq 0x5cd1(%rip), %rdi      # 0xc2f0
callq 0x5d41
leaq 0xc115(%rip), %rdi      # 0x12740
movq %rbx, %rsi
movl %ebp, %edx
callq 0x73e4
movl %eax, %r15d
movq %r14, %rdi
movl %eax, %esi
callq 0x5f36
movq 0xc107(%rip), %rax      # 0x12750
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl (%rax,%r15), %r15d
movq (%r14), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%r14), %rax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x5f36
addl $0x30, %r15d
movl %r15d, 0x4(%rsp)
pushq $0xb
popq %r15
leaq 0x5c80(%rip), %r13      # 0xc303
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb (%rax), %r12b
cmpb %bpl, %r12b
je 0x6730
cmpq $0x0, 0x10(%r14)
je 0x66ad
movq 0x8(%r14), %rax
addq $0x4, %rax
cmpq %rax, (%r14)
jb 0x66b8
movq %r14, %rdi
movl %r15d, %esi
callq 0x5880
movzbl %r12b, %eax
cmpl $0x5c, %eax
je 0x66d3
cmpl $0xa, %eax
jne 0x6702
movq %r13, %rdi
callq 0x5d41
movb $0xa, %r12b
jmp 0x6702
movq (%rbx), %rax
movzbl (%rax), %eax
cmpb %bpl, %al
je 0x66f5
cmpl $0x26, %eax
je 0x66e8
cmpl $0x5c, %eax
jne 0x6714
movq (%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
movb $0x5c, (%rax)
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb (%rax), %r12b
movq (%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
movb %r12b, (%rax)
jmp 0x6683
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x66f5
cmpl %eax, 0x4(%rsp)
jge 0x66e8
leaq 0x5bef(%rip), %rdi      # 0xc318
callq 0x5d41
jmp 0x66e8
movq 0x10(%rsp), %rdx
subl 0x8(%rsp), %edx
movq (%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
movb $0x0, (%rax)
movq (%r14), %rax
movq 0x10(%r14), %r12
addq $0x3, %rax
andq $-0x4, %rax
movq %rax, (%r14)
movslq %edx, %r13
andl $0x0, (%r12,%r13)
pushq $-0x1
popq %rbp
leaq 0x5bc5(%rip), %r15      # 0xc32f
movq (%rbx), %rax
movzbl (%rax), %ecx
cmpl $0x70, %ecx
jne 0x679e
movl (%r12,%r13), %ecx
testl %ecx, %ecx
jns 0x678c
movq %r15, %rdi
callq 0x5d41
movq (%rbx), %rax
movl (%r12,%r13), %ecx
incq %rax
movq %rax, (%rbx)
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, (%r12,%r13)
jmp 0x676d
leal -0x30(%rcx), %edx
cmpl $0xa, %edx
jae 0x67d4
cmpl $-0x1, %ebp
je 0x67b3
movq %r15, %rdi
callq 0x5d41
movq %rbx, %rdi
callq 0x5f73
movl %eax, %ebp
decl %eax
leaq 0x5b75(%rip), %rdi      # 0xc33b
cmpl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jb 0x676a
callq 0x5d41
jmp 0x676a
cmpl $0x67, %ecx
jne 0x67f1
incq %rax
movq %rax, (%rbx)
movq %r15, %rdi
cmpl $-0x1, %ebp
movl $0x0, %ebp
jne 0x67cd
jmp 0x676a
cmpl $0x77, %ecx
jne 0x680d
incq %rax
movq %rax, (%rbx)
orb $0x40, 0x3(%r12,%r13)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6229
cmpl $-0x1, %ebp
pushq $0x1
popq %rax
cmovnel %ebp, %eax
orl %eax, (%r12,%r13)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq