// File: /workspace/github_cpp_makefile_star2_O2/sgielen[P]clife/multi_indep.cpp
// Function: main
int main(int argc, char *argv[]) {
	int microsleeptime = 100000;
	if(argc == 2) {
		std::stringstream ss;
		ss << argv[1];
		ss >> microsleeptime;
		if(!ss) {
			std::cerr << "Usage: " << argv[0] << " [microsleeptime]" << std::endl;
		}
	} else if(argc > 2) {
		std::cerr << "Usage: " << argv[0] << " [microsleeptime]" << std::endl;
	}

	init_random();

	std::vector<uint64_t> earlier_hashes;
	GameOfLifeField<SimpleValue<char(0x80), 0>> red(8, 80);
	GameOfLifeField<SimpleValue<char(0x80), 0>> green(8, 80);
	GameOfLifeField<SimpleValue<char(0x80), 0>> blue(8, 80);

	red.generateRandom(35);
	green.generateRandom(35);
	blue.generateRandom(35);

	bool red_done = false;
	bool green_done = false;
	bool blue_done = false;
	int repeats_to_do = 0;
	print_rgb(red, green, blue);
	while(!red_done || !green_done || !blue_done || repeats_to_do > 0) {
		if(repeats_to_do > 0) {
			--repeats_to_do;
		}
		red.nextState();
		green.nextState();
		blue.nextState();
		print_rgb(red, green, blue);
		if(!red_done || !green_done || !blue_done) {
			check_stop_condition(red, earlier_hashes, red_done, repeats_to_do);
			check_stop_condition(green, earlier_hashes, green_done, repeats_to_do);
			check_stop_condition(blue, earlier_hashes, blue_done, repeats_to_do);
		}
		usleep(microsleeptime);
		continue;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rsi, %rbx
movl $0x186a0, 0xc(%rsp)     # imm = 0x186A0
cmpl $0x2, %edi
jne 0x3fc1
leaq 0x190(%rsp), %rdi
callq 0x20d0
leaq 0x1a0(%rsp), %rdi
movq 0x8(%rbx), %rsi
callq 0x2140
leaq 0x190(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x20b0
movq 0x190(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x1b0(%rsp,%rax)
je 0x3fb2
movq 0x5064(%rip), %rdi      # 0x8fe8
leaq 0x21f5(%rip), %rsi      # 0x6180
callq 0x2140
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x2140
leaq 0x21e6(%rip), %rsi      # 0x6188
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
callq 0x2080
leaq 0x190(%rsp), %rdi
callq 0x20f0
jmp 0x3ff8
jle 0x3ff8
movq 0x501e(%rip), %rdi      # 0x8fe8
leaq 0x21af(%rip), %rsi      # 0x6180
callq 0x2140
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x2140
leaq 0x21a0(%rip), %rsi      # 0x6188
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
callq 0x2080
callq 0x3ef3
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x190(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x50
popq %rdx
callq 0x474c
leaq 0x50(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x50
popq %rdx
callq 0x474c
leaq 0x30(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x50
popq %rdx
callq 0x474c
leaq 0x190(%rsp), %rdi
pushq $0x23
popq %rsi
callq 0x4786
leaq 0x50(%rsp), %rdi
pushq $0x23
popq %rsi
callq 0x4786
leaq 0x30(%rsp), %rdi
pushq $0x23
popq %rsi
callq 0x4786
xorl %eax, %eax
movb %al, 0x7(%rsp)
movb %al, 0x6(%rsp)
movb %al, 0x5(%rsp)
andl $0x0, 0x8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x48d4
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x48d4
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x48d4
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x4825
leaq 0x70(%rsp), %rdi
callq 0x4b0c
leaq 0x90(%rsp), %rdi
callq 0x4b0c
leaq 0xb0(%rsp), %rdi
callq 0x4b0c
leaq 0x50(%rsp), %r14
leaq 0x30(%rsp), %r15
leaq 0x170(%rsp), %r12
leaq 0x150(%rsp), %r13
leaq 0x130(%rsp), %rbp
cmpb $0x1, 0x7(%rsp)
jne 0x4133
cmpb $0x1, 0x6(%rsp)
jne 0x4133
movl 0x8(%rsp), %eax
testl %eax, %eax
setle %cl
testb %cl, 0x5(%rsp)
je 0x4137
jmp 0x427b
movl 0x8(%rsp), %eax
testl %eax, %eax
jle 0x4141
decl %eax
movl %eax, 0x8(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x48f4
movq %r14, %rdi
callq 0x48f4
movq %r15, %rdi
callq 0x48f4
movq %r12, %rdi
leaq 0x190(%rsp), %rsi
callq 0x48d4
movq %r13, %rdi
movq %r14, %rsi
callq 0x48d4
movq %rbp, %rdi
movq %r15, %rsi
callq 0x48d4
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x4825
movq %rbp, %rdi
callq 0x4b0c
movq %r13, %rdi
callq 0x4b0c
movq %r12, %rdi
callq 0x4b0c
cmpb $0x1, 0x7(%rsp)
jne 0x41c3
cmpb $0x1, 0x6(%rsp)
jne 0x41c3
cmpb $0x0, 0x5(%rsp)
jne 0x426d
leaq 0x110(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x48d4
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x7(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x4a61
movq %rbx, %rdi
callq 0x4b0c
leaq 0xf0(%rsp), %rdi
movq %r14, %rsi
callq 0x48d4
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x6(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x4a61
movq %rbx, %rdi
callq 0x4b0c
leaq 0xd0(%rsp), %rdi
movq %r15, %rsi
callq 0x48d4
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x5(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x4a61
movq %rbx, %rdi
callq 0x4b0c
movl 0xc(%rsp), %edi
callq 0x21a0
jmp 0x4111
leaq 0x30(%rsp), %rdi
callq 0x4b0c
leaq 0x50(%rsp), %rdi
callq 0x4b0c
leaq 0x190(%rsp), %rdi
callq 0x4b0c
leaq 0x10(%rsp), %rdi
callq 0x4b90
xorl %eax, %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4b0c
jmp 0x42cc
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4b0c
jmp 0x42de
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x4375
jmp 0x437c
movq %rax, %rbx
jmp 0x4389
movq %rax, %rbx
jmp 0x4393
movq %rax, %rbx
jmp 0x43a0
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x20f0
jmp 0x43aa
jmp 0x437c
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
jmp 0x4375
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
jmp 0x4375
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x4375
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x4b0c
jmp 0x435b
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x4b0c
jmp 0x436d
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
callq 0x4b0c
jmp 0x437f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4b0c
leaq 0x50(%rsp), %rdi
callq 0x4b0c
leaq 0x190(%rsp), %rdi
callq 0x4b0c
leaq 0x10(%rsp), %rdi
callq 0x4b90
movq %rbx, %rdi
callq 0x21f0