#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 COLS;
int LINES;
int getpid();
int rand();
int /*<<< orphan*/ srandom(int);
int time(int /*<<< orphan*/);
void init_life(int grid[COLS][LINES]) {
  int i;
  int j;
  srandom(time(0) * getpid());
  for (i = 0; i < COLS; i++) {
    for (j = 0; j < LINES; j++) {
      if ((rand() % 3) == 0)
        grid[i][j] = 1;
      else
        grid[i][j] = 0;
    }
  }
}


x86 assembly (clang, -O0):
<init_life>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x20(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x14(%rbp),%edi
imul   %eax,%edi
call   1030 <srandom@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%eax
jge    122e <init_life+0xee>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%eax
jge    121b <init_life+0xdb>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e6 <init_life+0xa6>
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1208 <init_life+0xc8>
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    120d <init_life+0xcd>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1195 <init_life+0x55>
jmp    1220 <init_life+0xe0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <init_life+0x3c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_life>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e93(%rip),%r13
mov    0x0(%r13),%r15d
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <getpid@plt>
imul   %eax,%r14d
mov    %r14d,%edi
call   1030 <srandom@plt>
mov    0x2e63(%rip),%r14
mov    (%r14),%ecx
test   %ecx,%ecx
jle    11f1 <init_life+0xb1>
mov    0x0(%r13),%eax
shl    $0x2,%r15
xor    %r12d,%r12d
jmp    11af <init_life+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
movslq %ecx,%rdx
add    %r15,%rbx
cmp    %rdx,%r12
jge    11f1 <init_life+0xb1>
test   %eax,%eax
jle    11a0 <init_life+0x60>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <rand@plt>
imul   $0xaaaaaaab,%eax,%eax
add    $0x2aaaaaaa,%eax
xor    %ecx,%ecx
cmp    $0x55555555,%eax
setb   %cl
mov    %ecx,(%rbx,%rbp,4)
add    $0x1,%rbp
movslq 0x0(%r13),%rax
cmp    %rax,%rbp
jl     11c0 <init_life+0x80>
mov    (%r14),%ecx
jmp    11a0 <init_life+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@COLS = global i32 0
@LINES = global i32 0
define void @init_life(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32, i32* @COLS
%6 = zext i32 %5 to i64
%7 = load i32, i32* @LINES
%8 = zext i32 %7 to i64
%9 = call i32 @time(i32 0)
%10 = call i32 (...) @getpid()
%11 = mul nsw i32 %9, %10
%12 = call i32 @srandom(i32 %11)
store i32 0, i32* %3
br label %13
13: ; preds = %49, %1
%14 = load i32, i32* %3
%15 = load i32, i32* @COLS
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %52
17: ; preds = %13
store i32 0, i32* %4
br label %18
18: ; preds = %45, %17
%19 = load i32, i32* %4
%20 = load i32, i32* @LINES
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %48
22: ; preds = %18
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 3
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32*, i32** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = mul nsw i64 %29, %8
%31 = getelementptr inbounds i32, i32* %27, i64 %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 1, i32* %34
br label %44
35: ; preds = %22
%36 = load i32*, i32** %2
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = mul nsw i64 %38, %8
%40 = getelementptr inbounds i32, i32* %36, i64 %39
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
store i32 0, i32* %43
br label %44
44: ; preds = %35, %26
br label %45
45: ; preds = %44
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %18
48: ; preds = %18
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %13
52: ; preds = %13
ret void
}

LLVM IR (-O2):
@COLS = global i32 0
@LINES = global i32 0
define void @init_life(i32* nocapture writeonly %0) {
%2 = load i32, i32* @LINES
%3 = zext i32 %2 to i64
%4 = tail call i32 @time(i32 0)
%5 = tail call i32 (...) @getpid()
%6 = mul nsw i32 %5, %4
%7 = tail call i32 @srandom(i32 %6)
%8 = load i32, i32* @COLS
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %39
10: ; preds = %1
%11 = load i32, i32* @LINES
br label %12
12: ; preds = %10, %33
%13 = phi i32 [ %8, %10 ], [ %34, %33 ]
%14 = phi i32 [ %11, %10 ], [ %35, %33 ]
%15 = phi i64 [ 0, %10 ], [ %36, %33 ]
%16 = icmp sgt i32 %14, 0
br i1 %16, label %17, label %33
17: ; preds = %12
%18 = mul nuw nsw i64 %15, %3
%19 = getelementptr inbounds i32, i32* %0, i64 %18
br label %20
20: ; preds = %17, %20
%21 = phi i64 [ 0, %17 ], [ %27, %20 ]
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 3
%24 = icmp eq i32 %23, 0
%25 = getelementptr inbounds i32, i32* %19, i64 %21
%26 = zext i1 %24 to i32
store i32 %26, i32* %25
%27 = add nuw nsw i64 %21, 1
%28 = load i32, i32* @LINES
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %20, label %31
31: ; preds = %20
%32 = load i32, i32* @COLS
br label %33
33: ; preds = %31, %12
%34 = phi i32 [ %32, %31 ], [ %13, %12 ]
%35 = phi i32 [ %28, %31 ], [ %14, %12 ]
%36 = add nuw nsw i64 %15, 1
%37 = sext i32 %34 to i64
%38 = icmp slt i64 %36, %37
br i1 %38, label %12, label %39
39: ; preds = %33, %1
ret void
}