// File: /workspace/github_cpp_makefile_star2_O1/JD557[P]Wolf/grammar.cpp
// Function: r(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool r(string& in) {
	if (in[0]=='R') {consume(in);}
	else {return false;}

	string rule=binaryString(in);
	if (rule.size()==0) {return false;}

	float range=log(rule.length())/log(2);
	if (range!=(int) range) {return false;}

	Interval interv=inter(in);
	if (interv.start<0 || interv.end<0) {return false;}

	vector <bool> newTape=systape;
	for (size_t i=interv.start;i<=interv.end;++i) {
		unsigned long long val=0;
		for (int j=-(range/2);j<=range/2;++j) {
			int pos=(int) i+j;
			if (pos<0) {pos=systape.size()+pos;}
			else if (pos>=systape.size()) {pos=(pos-systape.size());}
			val=val<<1;			
			val+=systape[pos];
		}
		newTape[i]=rule[rule.size()-1-val]-'0';
	}
	systape=newTape;
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq (%rdi), %rax
cmpb $0x52, (%rax)
jne 0x3813
movq %rdi, %rbx
callq 0x3314
leaq -0xb8(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x33b4
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x37ef
movq %rax, %xmm1
punpckldq 0x2047(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x204f(%rip), %xmm1     # 0x5810
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
callq 0x20f0
divsd 0x2066(%rip), %xmm0     # 0x5840
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
cvttps2dq %xmm1, %xmm0
cvtdq2ps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x37ef
jnp 0x382b
xorl %r14d, %r14d
leaq -0xa8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3816
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2150
jmp 0x3816
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movaps %xmm1, -0x70(%rbp)
movq %rbx, %rdi
callq 0x3525
movq %rax, %rbx
movabsq $-0x7fffffff80000000, %rax # imm = 0x8000000080000000
testq %rax, %rbx
sete %r14b
jne 0x37f2
leaq 0x48ec(%rip), %rsi      # 0x8140
leaq -0x58(%rbp), %rdi
callq 0x443e
movq %rbx, %rdx
shrq $0x20, %rdx
movl %ebx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
ja 0x39fe
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movaps -0x70(%rbp), %xmm1
mulss 0x1fbd(%rip), %xmm1     # 0x5848
movaps 0x1f8e(%rip), %xmm0     # 0x5820
movaps %xmm1, %xmm2
xorps %xmm1, %xmm0
cvttss2si %xmm0, %esi
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
movq 0x4896(%rip), %rdi      # 0x8140
movq -0xb8(%rbp), %r9
movq -0x58(%rbp), %r10
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
addl %esi, %ebx
movq %rsi, -0x88(%rbp)
incl %esi
movl %esi, -0x2c(%rbp)
leaq 0x3f(%rax), %r14
movq %rdx, -0x90(%rbp)
movq %r9, -0x80(%rbp)
movq %r10, -0x78(%rbp)
movabsq $-0x8000000000000000, %r13 # imm = 0x8000000000000000
movq $-0x1, %r15
ucomiss %xmm0, %xmm2
jb 0x39bb
movq 0x4853(%rip), %r12      # 0x8150
movl 0x4855(%rip), %eax      # 0x8158
subq 0x4836(%rip), %r12      # 0x8140
movq %rax, -0x70(%rbp)
leaq (%rax,%r12,8), %r10
shll $0x3, %r12d
movl -0x2c(%rbp), %esi
movq %rbx, -0x98(%rbp)
movl %ebx, %r9d
movq -0x88(%rbp), %rax
xorl %r15d, %r15d
testl %r9d, %r9d
js 0x394c
movl %r9d, %r8d
cmpq %r8, %r10
movl %r10d, %r11d
movl $0x0, %edx
cmoval %edx, %r11d
movl %r9d, %r8d
subl %r11d, %r8d
jmp 0x3957
leal (%rax,%rcx), %r8d
addl -0x70(%rbp), %r8d
addl %r12d, %r8d
movslq %r8d, %rbx
leaq 0x3f(%rbx), %r11
testq %rbx, %rbx
cmovnsq %rbx, %r11
sarq $0x6, %r11
leaq (%rdi,%r11,8), %r11
movq %rbx, %r8
andq %r14, %r8
xorl %edx, %edx
cmpq %r13, %r8
setbe %dl
movq -0x8(%r11,%rdx,8), %rdx
xorl %r8d, %r8d
btq %rbx, %rdx
setb %r8b
leaq (%r8,%r15,2), %r15
incl %eax
xorps %xmm1, %xmm1
cvtsi2ss %esi, %xmm1
incl %r9d
incl %esi
ucomiss %xmm1, %xmm2
jae 0x392d
notq %r15
movq -0x98(%rbp), %rbx
movq -0x90(%rbp), %rdx
movq -0x80(%rbp), %r9
movq -0x78(%rbp), %r10
movq -0xb0(%rbp), %r8
addq %r9, %r8
movl $0x1, %eax
shlq %cl, %rax
movq %rcx, %rsi
shrq $0x6, %rsi
cmpb $0x30, (%r15,%r8)
jne 0x39e4
notq %rax
andq (%r10,%rsi,8), %rax
jmp 0x39e8
orq (%r10,%rsi,8), %rax
movq %rax, (%r10,%rsi,8)
leaq 0x1(%rcx), %rax
incl %ebx
cmpq %rdx, %rcx
movq %rax, %rcx
jne 0x38e6
leaq 0x473b(%rip), %rdi      # 0x8140
leaq -0x58(%rbp), %rsi
callq 0x44dc
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x3a37
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x2150
xorl %eax, %eax
movq %rax, -0x58(%rbp)
movl %eax, -0x50(%rbp)
movq %rax, -0x48(%rbp)
movl %eax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movb $0x1, %r14b
jmp 0x37f2
movq %rax, %rbx
movq -0x58(%rbp), %rsi
testq %rsi, %rsi
je 0x3a5b
leaq -0x58(%rbp), %rdi
callq 0x2254
jmp 0x3a5b
jmp 0x3a58
movq %rax, %rbx
leaq -0xa8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3a7a
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x21f0