// File: /workspace/github_cpp_makefile_star2_O1/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 0x6cbb
cmpl $0xa, %ebp
jne 0x6ced
movq 0xca96(%rip), %r15      # 0x13758
movq %r15, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r15, %rax
leaq 0x6678(%rip), %rdi      # 0xd351
leaq 0x6613(%rip), %rsi      # 0xd2f3
movq %rax, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x5899
leaq 0xca4c(%rip), %rdi      # 0x13740
movq %rbx, %rsi
movl %ebp, %edx
callq 0x7bdc
movl %eax, %r15d
movq %r14, %rdi
movl %eax, %esi
callq 0x62a4
movq 0xca3e(%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 0x62a4
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb (%rax), %r15b
cmpb %bpl, %r15b
jne 0x6ece
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 0x65cf(%rip), %r12      # 0xd351
movq (%rbx), %rax
movzbl (%rax), %ecx
cmpl $0x70, %ecx
jne 0x6dcd
cmpl $0x0, (%r15,%rbp)
jns 0x6dc2
movq 0xc9bd(%rip), %r13      # 0x13758
movq %r13, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r13, %rax
movq %r12, %rdi
leaq 0x657d(%rip), %rsi      # 0xd332
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x5899
incq (%rbx)
orb $-0x80, 0x3(%r15,%rbp)
jmp 0x6d82
leal -0x30(%rcx), %edx
cmpl $0xa, %edx
jae 0x6e6a
cmpl $-0x1, 0x8(%rsp)
je 0x6e0e
movq 0xc971(%rip), %r13      # 0x13758
movq %r13, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r13, %rax
movq %r12, %rdi
leaq 0x6531(%rip), %rsi      # 0xd332
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x5899
movq %rbx, %rdi
callq 0x62e0
movl %eax, 0x8(%rsp)
decl %eax
leaq 0x651b(%rip), %rcx      # 0xd33e
cmpl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
jb 0x6d82
movq %rcx, 0x10(%rsp)
movq %r12, %r13
movq 0xc91b(%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 0x5899
jmp 0x6d82
cmpl $0x67, %ecx
jne 0x6e90
incq %rax
movq %rax, (%rbx)
leaq 0x64b6(%rip), %rcx      # 0xd332
cmpl $-0x1, 0x8(%rsp)
movl $0x0, 0x8(%rsp)
jne 0x6e2e
jmp 0x6d82
cmpl $0x77, %ecx
jne 0x6eac
incq %rax
movq %rax, (%rbx)
orb $0x40, 0x3(%r15,%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x66db
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)
cmpq $0x0, 0x10(%r14)
je 0x6eef
movq 0x8(%r14), %rax
addq $0x4, %rax
cmpq %rax, (%r14)
jb 0x6efc
movq %r14, %rdi
movl $0xb, %esi
callq 0x5a80
cmpb $0x5c, %r15b
je 0x6f42
movzbl %r15b, %eax
cmpl $0xa, %eax
jne 0x6f71
movq 0xc846(%rip), %r12      # 0x13758
movq %r12, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r12, %rax
leaq 0x6428(%rip), %rdi      # 0xd351
leaq 0x63d6(%rip), %rsi      # 0xd306
movq %rax, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x5899
movb $0xa, %r15b
jmp 0x6f71
movq (%rbx), %rax
movzbl (%rax), %eax
cmpb %bpl, %al
je 0x6f64
cmpl $0x26, %eax
je 0x6f57
cmpl $0x5c, %eax
jne 0x6f99
movq (%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
movb %r15b, (%rax)
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb (%rax), %r15b
movq (%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
movb %r15b, (%rax)
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb (%rax), %r15b
cmpb %bpl, %r15b
jne 0x6edb
jmp 0x6d49
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x6f64
cmpl %eax, 0x8(%rsp)
jge 0x6f57
movq 0xc7aa(%rip), %r12      # 0x13758
movq %r12, %rdi
movl $0xa, %esi
callq 0x50c0
subq %r12, %rax
leaq 0x638c(%rip), %rdi      # 0xd351
leaq 0x634f(%rip), %rsi      # 0xd31b
movq %rax, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x5899
jmp 0x6f57