#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 RAND_MAX;
int /*<<< orphan*/ evolve(unsigned int **, int, int);
int /*<<< orphan*/ printf(char *, int);
int rand();
int /*<<< orphan*/ show(unsigned int **, int, int);
int /*<<< orphan*/ usleep(int);
void game(int w, int h) {
  unsigned universe[h][w];
  printf("RAND_MAX:%ld\n", RAND_MAX);
  printf("RAND_MAX/10:%ld\n", RAND_MAX / 10);
  for (int x = 0; x < w; x++)
    for (int y = 0; y < h; y++)
      universe[y][x] = rand() < RAND_MAX / 10 ? 1 : 0;
  while (1) {
    show(universe, w, h);
    evolve(universe, w, h);
    usleep(200000);
  }
}


x86 assembly (clang, -O0):
<game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rdx
imul   %rax,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    125c <game+0x10c>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1249 <game+0xf9>
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edi
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%r8d
mov    -0x30(%rbp),%rax
xor    %edx,%edx
mov    $0x1,%ecx
cmp    %r8d,%edi
cmovl  %ecx,%edx
movslq -0x28(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e7 <game+0x97>
jmp    124e <game+0xfe>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d4 <game+0x84>
jmp    1261 <game+0x111>
jmp    1266 <game+0x116>
mov    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1040 <show@plt>
mov    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <evolve@plt>
mov    $0x30d40,%edi
call   1070 <usleep@plt>
jmp    1261 <game+0x111>

x86 assembly (clang, -O2):
<game>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
mov    %edi,%r15d
mov    %esi,%eax
mov    %edi,%edx
mov    %rax,-0x38(%rbp)
mov    %rdx,-0x30(%rbp)
imul   %rdx,%rax
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e55(%rip),%r12
mov    (%r12),%esi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
movslq (%r12),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x22,%rsi
add    %eax,%esi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
test   %r15d,%r15d
jle    1260 <game+0x110>
mov    -0x30(%rbp),%rax
lea    0x0(,%rax,4),%rcx
mov    %rbx,%r13
xor    %eax,%eax
mov    %rcx,-0x50(%rbp)
jmp    1206 <game+0xb6>
nopw   0x0(%rax,%rax,1)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    -0x48(%rbp),%r13
add    $0x4,%r13
cmp    -0x30(%rbp),%rax
je     1260 <game+0x110>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%r12
mov    %r13,-0x48(%rbp)
test   %r14d,%r14d
jle    11f0 <game+0xa0>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
mov    0x2dba(%rip),%rcx
movslq (%rcx),%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
xor    %edx,%edx
cmp    %ecx,%eax
mov    -0x50(%rbp),%rcx
setl   %dl
mov    %edx,0x0(%r13)
add    %rcx,%r13
add    $0xffffffffffffffff,%r12
jne    1220 <game+0xd0>
jmp    11f0 <game+0xa0>
nop
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1040 <show@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1050 <evolve@plt>
mov    $0x30d40,%edi
call   1070 <usleep@plt>
jmp    1260 <game+0x110>

LLVM IR (-O0):
@.str = [14 x i8] c"RAND_MAX:%ld\0A\00"
@RAND_MAX = global i32 0
@.str.1 = [17 x i8] c"RAND_MAX/10:%ld\0A\00"
define void @game(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %5
%15 = mul nuw i64 %11, %13
%16 = alloca i32, i64 %15
store i64 %11, i64* %6
store i64 %13, i64* %7
%17 = load i32, i32* @RAND_MAX
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @RAND_MAX
%20 = sdiv i32 %19, 10
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %20)
store i32 0, i32* %8
br label %22
22: ; preds = %49, %2
%23 = load i32, i32* %8
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %52
26: ; preds = %22
store i32 0, i32* %9
br label %27
27: ; preds = %45, %26
%28 = load i32, i32* %9
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %48
31: ; preds = %27
%32 = call i32 (...) @rand()
%33 = load i32, i32* @RAND_MAX
%34 = sdiv i32 %33, 10
%35 = icmp slt i32 %32, %34
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 1, i32 0
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = mul nsw i64 %39, %13
%41 = getelementptr inbounds i32, i32* %16, i64 %40
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %37, i32* %44
br label %45
45: ; preds = %31
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %27
48: ; preds = %27
br label %49
49: ; preds = %48
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %22
52: ; preds = %22
br label %53
53: ; preds = %54, %52
br label %54
54: ; preds = %53
%55 = bitcast i32* %16 to i32**
%56 = load i32, i32* %3
%57 = load i32, i32* %4
%58 = call i32 @show(i32** %55, i32 %56, i32 %57)
%59 = bitcast i32* %16 to i32**
%60 = load i32, i32* %3
%61 = load i32, i32* %4
%62 = call i32 @evolve(i32** %59, i32 %60, i32 %61)
%63 = call i32 @usleep(i32 200000)
br label %53
}

LLVM IR (-O2):
@.str = [14 x i8] c"RAND_MAX:%ld\0A\00"
@RAND_MAX = global i32 0
@.str.1 = [17 x i8] c"RAND_MAX/10:%ld\0A\00"
define void @game(i32 %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = zext i32 %0 to i64
%5 = mul nuw i64 %3, %4
%6 = alloca i32, i64 %5
%7 = load i32, i32* @RAND_MAX
%8 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @RAND_MAX
%10 = sdiv i32 %9, 10
%11 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = icmp sgt i32 %1, 0
br label %15
15: ; preds = %13, %21
%16 = phi i64 [ 0, %13 ], [ %22, %21 ]
br i1 %14, label %17, label %21
17: ; preds = %15
%18 = getelementptr inbounds i32, i32* %6, i64 %16
br label %24
19: ; preds = %21, %2
%20 = bitcast i32* %6 to i32**
br label %35
21: ; preds = %24, %15
%22 = add nuw nsw i64 %16, 1
%23 = icmp eq i64 %22, %4
br i1 %23, label %19, label %15
24: ; preds = %17, %24
%25 = phi i64 [ 0, %17 ], [ %33, %24 ]
%26 = tail call i32 (...) @rand()
%27 = load i32, i32* @RAND_MAX
%28 = sdiv i32 %27, 10
%29 = icmp slt i32 %26, %28
%30 = zext i1 %29 to i32
%31 = mul nuw nsw i64 %25, %4
%32 = getelementptr inbounds i32, i32* %18, i64 %31
store i32 %30, i32* %32
%33 = add nuw nsw i64 %25, 1
%34 = icmp eq i64 %33, %3
br i1 %34, label %21, label %24
35: ; preds = %19, %35
%36 = call i32 @show(i32** %20, i32 %0, i32 %1)
%37 = call i32 @evolve(i32** %20, i32 %0, i32 %1)
%38 = call i32 @usleep(i32 200000)
br label %35
}