#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();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void initializeField(int *cells) {
  srand(time(0));
  for (int row = 0; row < 25; row++) {
    for (int col = 0; col < 80; col++) {
      cells[row * 80 + col] = (rand() % 8 == 0) ? 1 : 0;
    }
  }
}


x86 assembly (clang, -O0):
<initializeField>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x19,-0xc(%rbp)
jge    11bc <initializeField+0x8c>
movl   $0x0,-0x10(%rbp)
cmpl   $0x50,-0x10(%rbp)
jge    11a9 <initializeField+0x79>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmove  %eax,%edx
mov    -0x8(%rbp),%rax
imul   $0x50,-0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <initializeField+0x32>
jmp    11ae <initializeField+0x7e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <initializeField+0x21>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initializeField>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %r14d,%r14d
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
xor    %ecx,%ecx
test   $0x7,%al
sete   %cl
mov    %ecx,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    $0x50,%rbx
jne    1160 <initializeField+0x30>
add    $0x1,%r14
add    $0x140,%r15
cmp    $0x19,%r14
jne    1150 <initializeField+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @initializeField(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = call i32 @time(i32 0)
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %31, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 25
br i1 %9, label %10, label %34
10: ; preds = %7
store i32 0, i32* %4
br label %11
11: ; preds = %27, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 80
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 8
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 1, i32 0
%20 = load i32*, i32** %2
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, 80
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %20, i64 %25
store i32 %19, i32* %26
br label %27
27: ; preds = %14
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %11
30: ; preds = %11
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %7
34: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @initializeField(i32* nocapture writeonly %0) {
%2 = tail call i32 @time(i32 0)
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %1, %8
%5 = phi i64 [ 0, %1 ], [ %9, %8 ]
%6 = mul nuw nsw i64 %5, 80
br label %11
7: ; preds = %8
ret void
8: ; preds = %11
%9 = add nuw nsw i64 %5, 1
%10 = icmp eq i64 %9, 25
br i1 %10, label %7, label %4
11: ; preds = %4, %11
%12 = phi i64 [ 0, %4 ], [ %19, %11 ]
%13 = tail call i32 (...) @rand()
%14 = and i32 %13, 7
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = add nuw nsw i64 %12, %6
%18 = getelementptr inbounds i32, i32* %0, i64 %17
store i32 %16, i32* %18
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, 80
br i1 %20, label %8, label %11
}