// File: /workspace/github_cpp_makefile_star2_O3/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 0x6dea
cmpl $0xa, %ebp
jne 0x6e1c
movq 0xc967(%rip), %r15      # 0x13758
movq %r15, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r15, %rax
leaq 0x6546(%rip), %rdi      # 0xd34e
leaq 0x64e1(%rip), %rsi      # 0xd2f0
movq %rax, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x589a
leaq 0xc91d(%rip), %rdi      # 0x13740
movq %rbx, %rsi
movl %ebp, %edx
callq 0x7d18
movl %eax, %r15d
movq %r14, %rdi
movl %eax, %esi
callq 0x6296
movq 0xc90f(%rip), %rax      # 0x13750
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq (%rax,%r15), %rax
movq %rax, 0x8(%rsp)
movq (%r14), %r13
subq 0x10(%r14), %r13
movq %r14, %rdi
xorl %esi, %esi
callq 0x6296
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb (%rax), %r12b
cmpb %bpl, %r12b
jne 0x700c
movq (%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
movb $0x0, (%rax)
movq (%r14), %rax
movq 0x10(%r14), %r15
addq $0x3, %rax
andq $-0x4, %rax
movq %rax, (%r14)
movslq %r13d, %rbp
movl $0x0, (%r15,%rbp)
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
leaq 0x649d(%rip), %r12      # 0xd34e
movq (%rbx), %rax
movzbl (%rax), %ecx
cmpl $0x70, %ecx
jne 0x6f0b
movl (%r15,%rbp), %ecx
testl %ecx, %ecx
jns 0x6ef9
movq 0xc88d(%rip), %r13      # 0x13758
movq %r13, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r13, %rax
movq %r12, %rdi
leaq 0x644a(%rip), %rsi      # 0xd32f
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x589a
movq (%rbx), %rax
movl (%r15,%rbp), %ecx
incq %rax
movq %rax, (%rbx)
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, (%r15,%rbp)
jmp 0x6eb4
leal -0x30(%rcx), %edx
cmpl $0xa, %edx
jae 0x6fa8
cmpl $-0x1, 0x8(%rsp)
je 0x6f4c
movq 0xc833(%rip), %r13      # 0x13758
movq %r13, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r13, %rax
movq %r12, %rdi
leaq 0x63f0(%rip), %rsi      # 0xd32f
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x589a
movq %rbx, %rdi
callq 0x62d5
movl %eax, 0x8(%rsp)
decl %eax
leaq 0x63da(%rip), %rcx      # 0xd33b
cmpl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jb 0x6eb1
movq %rcx, 0x10(%rsp)
movq %r12, %r13
movq 0xc7dd(%rip), %r12      # 0x13758
movq %r12, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r12, %rax
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rdx
movq %r12, %rcx
movq %r13, %r12
xorl %eax, %eax
callq 0x589a
jmp 0x6eb1
cmpl $0x67, %ecx
jne 0x6fce
incq %rax
movq %rax, (%rbx)
leaq 0x6375(%rip), %rcx      # 0xd32f
cmpl $-0x1, 0x8(%rsp)
movl $0x0, 0x8(%rsp)
jne 0x6f6c
jmp 0x6eb1
cmpl $0x77, %ecx
jne 0x6fea
incq %rax
movq %rax, (%rbx)
orb $0x40, 0x3(%r15,%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x66d9
movl 0x8(%rsp), %ecx
cmpl $-0x1, %ecx
movl $0x1, %eax
cmovnel %ecx, %eax
orl %eax, (%r15,%rbp)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rax
addl $0x30, %eax
movq %rax, 0x8(%rsp)
leaq 0x632e(%rip), %r15      # 0xd34e
cmpq $0x0, 0x10(%r14)
je 0x7034
movq 0x8(%r14), %rax
addq $0x4, %rax
cmpq %rax, (%r14)
jb 0x7041
movq %r14, %rdi
movl $0xb, %esi
callq 0x5a81
cmpb $0x5c, %r12b
je 0x7083
movzbl %r12b, %eax
cmpl $0xa, %eax
jne 0x70b2
movq 0xc701(%rip), %r12      # 0x13758
movq %r12, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r12, %rax
movq %r15, %rdi
leaq 0x6292(%rip), %rsi      # 0xd303
movq %rax, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x589a
movb $0xa, %r12b
jmp 0x70b2
movq (%rbx), %rax
movzbl (%rax), %eax
cmpb %bpl, %al
je 0x70a5
cmpl $0x26, %eax
je 0x7098
cmpl $0x5c, %eax
jne 0x70da
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)
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb (%rax), %r12b
cmpb %bpl, %r12b
jne 0x7020
jmp 0x6e78
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x70a5
cmpl %eax, 0x8(%rsp)
jge 0x7098
movq 0xc669(%rip), %r12      # 0x13758
movq %r12, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r12, %rax
movq %r15, %rdi
leaq 0x620f(%rip), %rsi      # 0xd318
movq %rax, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x589a
jmp 0x7098