#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 randomize(int *arr, int N) {
  srand(time(0));
  int i, j;
  for (i = 0; i <= N - 1; i++)
    for (j = 0; j <= N - 1; j++)
      arr[i * N + j] = rand() % 2;
}


x86 assembly (clang, -O0):
<randomize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11c1 <randomize+0x91>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11ae <randomize+0x7e>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <randomize+0x3c>
jmp    11b3 <randomize+0x83>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <randomize+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r12
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %ebp,%ebp
jle    119c <randomize+0x6c>
mov    %ebp,%ebp
lea    0x0(,%rbp,4),%r14
xor    %r15d,%r15d
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <randomize+0x40>
add    $0x1,%r15
add    %r14,%r12
cmp    %rbp,%r15
jne    1160 <randomize+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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