#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ init_board(char **, char **, unsigned int *, unsigned int *,
                              char *);
int /*<<< orphan*/ live(char *, char *, unsigned int, unsigned int);
int /*<<< orphan*/ print(char *, unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  char *current, *next;
  unsigned width, height;
  srand(time(NULL));
  if (argc < 2) {
    fputs("Please provide input file as argument.\n", stderr);
    return 1;
  }
  init_board(&current, &next, &width, &height, argv[1]);
  live(current, next, width, height);
  print(next, width, height);
  while (true) {
    char *tmp = next;
    next = current;
    current = tmp;
    usleep(100 * 1000);
    live(current, next, width, height);
    printf("\033[2J\033[1;1H");
    print(next, width, height);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11d0 <main+0x50>
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
lea    0xe40(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1040 <init_board@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1090 <live@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1060 <print@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x186a0,%edi
call   10a0 <usleep@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1090 <live@plt>
lea    0xddd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1060 <print@plt>
jmp    120f <main+0x8f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
cmp    $0x1,%ebp
jg     11bf <main+0x3f>
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
lea    0xe52(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x8(%rbx),%r8
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
call   1040 <init_board@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
call   1090 <live@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
call   1060 <print@plt>
lea    0xe20(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %rcx,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x186a0,%edi
call   10a0 <usleep@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
call   1090 <live@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
call   1060 <print@plt>
jmp    1210 <main+0x90>

LLVM IR (-O0):
@.str = [40 x i8] c"Please provide input file as argument.\0A\00"
@stderr = global i32 0
@.str.1 = [11 x i8] c"\1B[2J\1B[1;1H\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fputs(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 1
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @init_board(i8** %6, i8** %7, i32* %8, i32* %9, i8* %21)
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = call i32 @live(i8* %23, i8* %24, i32 %25, i32 %26)
%28 = load i8*, i8** %7
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = call i32 @print(i8* %28, i32 %29, i32 %30)
br label %32
32: ; preds = %18, %32
%33 = load i8*, i8** %7
store i8* %33, i8** %10
%34 = load i8*, i8** %6
store i8* %34, i8** %7
%35 = load i8*, i8** %10
store i8* %35, i8** %6
%36 = call i32 @usleep(i32 100000)
%37 = load i8*, i8** %6
%38 = load i8*, i8** %7
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = call i32 @live(i8* %37, i8* %38, i32 %39, i32 %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%43 = load i8*, i8** %7
%44 = load i32, i32* %8
%45 = load i32, i32* %9
%46 = call i32 @print(i8* %43, i32 %44, i32 %45)
br label %32
}

LLVM IR (-O2):
@.str = [40 x i8] c"Please provide input file as argument.\0A\00"
@stderr = global i32 0
@.str.1 = [11 x i8] c"\1B[2J\1B[1;1H\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i8** %3 to i8*
%8 = bitcast i8** %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = tail call i32 @time(i32* null)
%12 = tail call i32 @srand(i32 %11)
%13 = icmp slt i32 %0, 2
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 @fputs(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 1
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @init_board(i8** %3, i8** %4, i32* %5, i32* %6, i8* %19)
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @live(i8* %21, i8* %22, i32 %23, i32 %24)
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 @print(i8* %26, i32 %27, i32 %28)
br label %30
30: ; preds = %30, %17
%31 = load i8*, i8** %4
%32 = load i8*, i8** %3
store i8* %32, i8** %4
store i8* %31, i8** %3
%33 = call i32 @usleep(i32 100000)
%34 = load i8*, i8** %3
%35 = load i8*, i8** %4
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = call i32 @live(i8* %34, i8* %35, i32 %36, i32 %37)
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%40 = load i8*, i8** %4
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = call i32 @print(i8* %40, i32 %41, i32 %42)
br label %30
}