#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 /*<<< orphan*/ getpid();
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
void insert(int (*p)[4], int row, int col) {
  int i, j;
  srand(getpid());
  for (i = 0; i < row; i++)
    for (j = 0; j < col; j++)
      p[i][j] = rand() % 50 + 1;
}


x86 assembly (clang, -O0):
<insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bf <insert+0x8f>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ac <insert+0x7c>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116a <insert+0x3a>
jmp    11b1 <insert+0x81>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <insert+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %r14d,%r14d
jle    11c5 <insert+0x95>
mov    %r14d,%r14d
mov    %r15d,%r13d
xor    %r12d,%r12d
jmp    117d <insert+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
add    $0x10,%rbx
cmp    %r14,%r12
je     11c5 <insert+0x95>
test   %r15d,%r15d
jle    1170 <insert+0x40>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1190 <insert+0x60>
jmp    1170 <insert+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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