#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 init_cell_space();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_init_alive_cell();
int /*<<< orphan*/ show_cell_space();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ start_a_period();
int main(int argc, char *argv[]) {
  printf("Welcome to the GAME-OF-LIFE!\n");
  int ret = 0;
  ret = init_cell_space();
  if (ret < 0) {
    printf("初始化细胞空间失败！\n");
    return -1;
  }
  set_init_alive_cell();
  show_cell_space();
  sleep(3);
  while (1) {
    show_cell_space();
    start_a_period();
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <init_cell_space@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11b4 <main+0x54>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1070 <set_init_alive_cell@plt>
mov    $0x0,%al
call   1060 <show_cell_space@plt>
mov    $0x3,%edi
call   1080 <sleep@plt>
mov    $0x0,%al
call   1060 <show_cell_space@plt>
mov    $0x0,%al
call   1030 <start_a_period@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    11cc <main+0x6c>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <init_cell_space@plt>
test   %eax,%eax
js     11aa <main+0x4a>
xor    %eax,%eax
call   1070 <set_init_alive_cell@plt>
xor    %eax,%eax
call   1060 <show_cell_space@plt>
mov    $0x3,%edi
call   1080 <sleep@plt>
xor    %eax,%eax
call   1060 <show_cell_space@plt>
xor    %eax,%eax
call   1040 <start_a_period@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    1190 <main+0x30>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Welcome to the GAME-OF-LIFE!\0A\00"
@.str.1 = [32 x i8] c"\E5\88\9D\E5\A7\8B\E5\8C\96\E7\BB\86\E8\83\9E\E7\A9\BA\E9\97\B4\E5\A4\B1\E8\B4\A5\EF\BC\81\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
%8 = call i32 (...) @init_cell_space()
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
ret i32 -1
13: ; preds = %2
%14 = call i32 (...) @set_init_alive_cell()
%15 = call i32 (...) @show_cell_space()
%16 = call i32 @sleep(i32 3)
br label %17
17: ; preds = %13, %17
%18 = call i32 (...) @show_cell_space()
%19 = call i32 (...) @start_a_period()
%20 = call i32 @sleep(i32 1)
br label %17
}

LLVM IR (-O2):
@str = [29 x i8] c"Welcome to the GAME-OF-LIFE!\00"
@str.2 = [31 x i8] c"\E5\88\9D\E5\A7\8B\E5\8C\96\E7\BB\86\E8\83\9E\E7\A9\BA\E9\97\B4\E5\A4\B1\E8\B4\A5\EF\BC\81\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @init_cell_space()
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.2, i64 0, i64 0))
ret i32 -1
8: ; preds = %2
%9 = tail call i32 (...) @set_init_alive_cell()
%10 = tail call i32 (...) @show_cell_space()
%11 = tail call i32 @sleep(i32 3)
br label %12
12: ; preds = %12, %8
%13 = tail call i32 (...) @show_cell_space()
%14 = tail call i32 (...) @start_a_period()
%15 = tail call i32 @sleep(i32 1)
br label %12
}