// File: sgielen[P]clife/single.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>> field(8, 80);

	field.generateRandom(35);

	bool field_done = false;
	int repeats_to_do = 0;
	field.print(std::cout);
	while(!field_done || repeats_to_do > 0) {
		if(repeats_to_do > 0) {
			--repeats_to_do;
		}
		field.nextState();
		field.print(std::cout);
		if(!field_done) {
			check_stop_condition(field, earlier_hashes, field_done, repeats_to_do);
		}
		usleep(microsleeptime);
		continue;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x186a0, -0x14(%rbp)   # imm = 0x186A0
cmpl $0x2, -0x8(%rbp)
jne 0x56f9
leaq -0x1a0(%rbp), %rdi
callq 0x20d0
leaq -0x190(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2140
jmp 0x561c
leaq -0x1a0(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x20c0
jmp 0x562e
movq -0x1a0(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x1a0(%rbp,%rax), %rdi
callq 0x2080
movb %al, -0x211(%rbp)
jmp 0x564e
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0x565d
jmp 0x56eb
movq 0xa984(%rip), %rdi      # 0xffe8
leaq 0x5b15(%rip), %rsi      # 0xb180
callq 0x2140
movq %rax, -0x220(%rbp)
jmp 0x5679
movq -0x220(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2140
movq %rax, -0x228(%rbp)
jmp 0x5695
movq -0x228(%rbp), %rdi
leaq 0x5ae5(%rip), %rsi      # 0xb188
callq 0x2140
movq %rax, -0x230(%rbp)
jmp 0x56b1
movq -0x230(%rbp), %rdi
movq 0xa8f1(%rip), %rsi      # 0xffb0
callq 0x2170
jmp 0x56c6
jmp 0x56eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20f0
jmp 0x58fa
leaq -0x1a0(%rbp), %rdi
callq 0x20f0
jmp 0x5741
cmpl $0x2, -0x8(%rbp)
jle 0x573f
movq 0xa8e2(%rip), %rdi      # 0xffe8
leaq 0x5a73(%rip), %rsi      # 0xb180
callq 0x2140
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x5a5d(%rip), %rsi      # 0xb188
callq 0x2140
movq %rax, %rdi
movq 0xa876(%rip), %rsi      # 0xffb0
callq 0x2170
jmp 0x5741
callq 0x55a0
leaq -0x1c8(%rbp), %rdi
callq 0x72e0
leaq -0x1e8(%rbp), %rdi
movl $0x8, %esi
movl $0x50, %edx
callq 0x7300
jmp 0x576a
leaq -0x1e8(%rbp), %rdi
movl $0x23, %esi
callq 0x73a0
jmp 0x577d
movb $0x0, -0x1e9(%rbp)
movl $0x0, -0x1f0(%rbp)
movq 0xa833(%rip), %rsi      # 0xffc8
leaq -0x1e8(%rbp), %rdi
callq 0x74c0
jmp 0x57a3
jmp 0x57a5
movb $0x1, %al
testb $0x1, -0x1e9(%rbp)
movb %al, -0x231(%rbp)
je 0x57c6
cmpl $0x0, -0x1f0(%rbp)
setg %al
movb %al, -0x231(%rbp)
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0x57d5
jmp 0x58be
cmpl $0x0, -0x1f0(%rbp)
jle 0x581d
movl -0x1f0(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1f0(%rbp)
jmp 0x581d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x58ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x58e2
leaq -0x1e8(%rbp), %rdi
callq 0x7650
jmp 0x582b
movq 0xa796(%rip), %rsi      # 0xffc8
leaq -0x1e8(%rbp), %rdi
callq 0x74c0
jmp 0x5840
testb $0x1, -0x1e9(%rbp)
jne 0x58af
leaq -0x210(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x79a0
jmp 0x585e
leaq -0x210(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
leaq -0x1e9(%rbp), %rdx
leaq -0x1f0(%rbp), %rcx
callq 0x7900
jmp 0x5881
leaq -0x210(%rbp), %rdi
callq 0x79e0
jmp 0x58af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x79e0
jmp 0x58e2
movl -0x14(%rbp), %edi
callq 0x21b0
jmp 0x58b9
jmp 0x57a5
leaq -0x1e8(%rbp), %rdi
callq 0x79e0
leaq -0x1c8(%rbp), %rdi
callq 0x7a00
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0x1e8(%rbp), %rdi
callq 0x79e0
leaq -0x1c8(%rbp), %rdi
callq 0x7a00
movq -0x1a8(%rbp), %rdi
callq 0x2220
nopw %cs:(%rax,%rax)