#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);
void fillMatrix(float **matrix, char rows, char cols, int seed) {
  srand(seed);
  char i = 0;
  char j = 0;
  for (i = 0; i < rows; i++) {
    for (j = 0; j < cols; j++) {
      matrix[i][j] = rand() % 10;
    }
  }
}


x86 assembly (clang, -O0):
<fillMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %rdi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <srand@plt>
movb   $0x0,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
movb   $0x0,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jge    11bb <fillMatrix+0x9b>
movb   $0x0,-0x12(%rbp)
movsbl -0x12(%rbp),%eax
movsbl -0xa(%rbp),%ecx
cmp    %ecx,%eax
jge    11a9 <fillMatrix+0x89>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
mov    -0x8(%rbp),%rax
movsbq -0x11(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbq -0x12(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x12(%rbp),%al
add    $0x1,%al
mov    %al,-0x12(%rbp)
jmp    1162 <fillMatrix+0x42>
jmp    11ae <fillMatrix+0x8e>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    114e <fillMatrix+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r12
mov    %ecx,%edi
call   1030 <srand@plt>
test   %r14b,%r14b
jle    119f <fillMatrix+0x7f>
movzbl %r14b,%r14d
movzbl %r15b,%r13d
xor    %ebx,%ebx
jmp    1159 <fillMatrix+0x39>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %r14,%rbx
je     119f <fillMatrix+0x7f>
test   %r15b,%r15b
jle    1150 <fillMatrix+0x30>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    (%r12,%rbx,8),%rax
movss  %xmm0,(%rax,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1160 <fillMatrix+0x40>
jmp    1150 <fillMatrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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