// File: 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
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2360
movsbl (%rax), %eax
cmpl $0x52, %eax
jne 0x437f
movq -0x10(%rbp), %rdi
callq 0x3d30
jmp 0x4388
movb $0x0, -0x1(%rbp)
jmp 0x4701
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x3e10
leaq -0x30(%rbp), %rdi
callq 0x2130
cmpq $0x0, %rax
jne 0x43b4
movb $0x0, -0x1(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x46eb
leaq -0x30(%rbp), %rdi
callq 0x22c0
movq %rax, %rdi
callq 0x54c0
movsd %xmm0, -0xb8(%rbp)
jmp 0x43cf
movl $0x2, %edi
callq 0x5500
movsd %xmm0, -0xc0(%rbp)
jmp 0x43e3
movsd -0xc0(%rbp), %xmm1
movsd -0xb8(%rbp), %xmm0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
cvttss2si -0x38(%rbp), %eax
cvtsi2ss %eax, %xmm1
ucomiss %xmm1, %xmm0
jne 0x4417
jp 0x4417
jmp 0x4438
movb $0x0, -0x1(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x46eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x46f6
movq -0x10(%rbp), %rdi
callq 0x4050
movq %rax, -0xc8(%rbp)
jmp 0x444a
movq -0xc8(%rbp), %rax
movq %rax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jl 0x4461
cmpl $0x0, -0x48(%rbp)
jge 0x4471
movb $0x0, -0x1(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x46eb
leaq 0x9d68(%rip), %rsi      # 0xe1e0
leaq -0x78(%rbp), %rdi
callq 0x5520
jmp 0x4483
movslq -0x4c(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpq %rcx, %rax
ja 0x46c5
movq $0x0, -0x88(%rbp)
movss -0x38(%rbp), %xmm0
movss 0x5344(%rip), %xmm1     # 0x97f8
divss %xmm1, %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x8c(%rbp)
cvtsi2ssl -0x8c(%rbp), %xmm1
movss -0x38(%rbp), %xmm0
movss 0x5314(%rip), %xmm2     # 0x97f8
divss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jb 0x461d
movq -0x80(%rbp), %rax
addl -0x8c(%rbp), %eax
movl %eax, -0x90(%rbp)
cmpl $0x0, -0x90(%rbp)
jge 0x4528
leaq 0x9ccf(%rip), %rdi      # 0xe1e0
callq 0x51a0
movslq -0x90(%rbp), %rcx
addq %rcx, %rax
movl %eax, -0x90(%rbp)
jmp 0x4580
movslq -0x90(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq 0x9ca3(%rip), %rdi      # 0xe1e0
callq 0x51a0
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jb 0x457e
movslq -0x90(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq 0x9c7a(%rip), %rdi      # 0xe1e0
callq 0x51a0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
subq %rcx, %rax
movl %eax, -0x90(%rbp)
jmp 0x4580
movq -0x88(%rbp), %rax
addq %rax, %rax
movq %rax, -0x88(%rbp)
movslq -0x90(%rbp), %rsi
leaq 0x9c41(%rip), %rdi      # 0xe1e0
callq 0x52f0
movq %rdx, -0xe8(%rbp)
movq %rax, -0xe0(%rbp)
jmp 0x45b4
movq -0xe8(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x56b0
andb $0x1, %al
movzbl %al, %eax
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x44cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5080
jmp 0x46f6
leaq -0x30(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x2130
movq -0xf8(%rbp), %rdi
movq -0x88(%rbp), %rsi
notq %rsi
addq %rax, %rsi
callq 0x2360
movq %rax, -0xf0(%rbp)
jmp 0x464f
movq -0xf0(%rbp), %rax
movb (%rax), %al
subb $0x30, %al
setne %al
movb %al, -0x109(%rbp)
movq -0x80(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x52f0
movq %rdx, -0x108(%rbp)
movq %rax, -0x100(%rbp)
jmp 0x4680
movb -0x109(%rbp), %al
movq -0x108(%rbp), %rcx
movq -0x100(%rbp), %rdx
movq %rdx, -0xb0(%rbp)
movq %rcx, -0xa8(%rbp)
movzbl %al, %esi
andl $0x1, %esi
leaq -0xb0(%rbp), %rdi
callq 0x5350
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x448b
leaq 0x9b14(%rip), %rdi      # 0xe1e0
leaq -0x78(%rbp), %rsi
callq 0x56e0
jmp 0x46d7
movb $0x1, -0x1(%rbp)
movl $0x1, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5080
leaq -0x30(%rbp), %rdi
callq 0x2100
jmp 0x4701
leaq -0x30(%rbp), %rdi
callq 0x2100
jmp 0x470f
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2300
nopl (%rax,%rax)