#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();
void fillRand(int mat[4][4]) {
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      mat[i][j] = (rand() % 2 - 1) * (rand() % 1000);
}


x86 assembly (clang, -O0):
<fillRand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11a1 <fillRand+0x91>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    118e <fillRand+0x7e>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x1,%edx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x14(%rbp),%edx
imul   %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <fillRand+0x24>
jmp    1193 <fillRand+0x83>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <fillRand+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillRand>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
not    %ebp
or     $0x1,%ebp
add    %eax,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   %ebp,%eax
mov    %eax,(%r14,%rbx,1)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
not    %ebp
or     $0x1,%ebp
add    %eax,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   %ebp,%eax
mov    %eax,0x4(%r14,%rbx,1)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
not    %ebp
or     $0x1,%ebp
add    %eax,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   %ebp,%eax
mov    %eax,0x8(%r14,%rbx,1)
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
not    %ebp
or     $0x1,%ebp
add    %eax,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   %ebp,%eax
mov    %eax,0xc(%r14,%rbx,1)
add    $0x10,%rbx
cmp    $0x40,%rbx
jne    1120 <fillRand+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @fillRand([4 x i32]* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %32, %2 ]
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 2
%6 = add nsw i32 %5, -1
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 1000
%9 = mul nsw i32 %6, %8
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %3, i64 0
store i32 %9, i32* %10
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 2
%13 = add nsw i32 %12, -1
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 1000
%16 = mul nsw i32 %13, %15
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %3, i64 1
store i32 %16, i32* %17
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 2
%20 = add nsw i32 %19, -1
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 1000
%23 = mul nsw i32 %20, %22
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %3, i64 2
store i32 %23, i32* %24
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 2
%27 = add nsw i32 %26, -1
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 1000
%30 = mul nsw i32 %27, %29
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 %3, i64 3
store i32 %30, i32* %31
%32 = add nuw nsw i64 %3, 1
%33 = icmp eq i64 %32, 4
br i1 %33, label %34, label %2
34: ; preds = %2
ret void
}