#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 stackDynMatrixMult() {
  srand(time(NULL));
  int d[100][100];
  int e[100][100];
  int f[100][100];
  int i = 0;
  int j = 0;
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      d[i][j] = (rand() % 100 + 1);
      e[i][j] = (rand() % 100 + 1);
    }
  }
  int k = 0;
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      for (k = 0; k < 100; k++) {
        f[i][j] += d[i][k] * e[k][j];
      }
    }
  }
}


x86 assembly (clang, -O0):
<stackDynMatrixMult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d4d0,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x1d4c4(%rbp)
movl   $0x0,-0x1d4c8(%rbp)
movl   $0x0,-0x1d4c4(%rbp)
cmpl   $0x64,-0x1d4c4(%rbp)
jge    1222 <stackDynMatrixMult+0xf2>
movl   $0x0,-0x1d4c8(%rbp)
cmpl   $0x64,-0x1d4c8(%rbp)
jge    1209 <stackDynMatrixMult+0xd9>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
movslq -0x1d4c4(%rbp),%rcx
lea    -0x9c40(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d4c8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
movslq -0x1d4c4(%rbp),%rcx
lea    -0x13880(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d4c8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1d4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4c8(%rbp)
jmp    1180 <stackDynMatrixMult+0x50>
jmp    120e <stackDynMatrixMult+0xde>
mov    -0x1d4c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4c4(%rbp)
jmp    1169 <stackDynMatrixMult+0x39>
movl   $0x0,-0x1d4cc(%rbp)
movl   $0x0,-0x1d4c4(%rbp)
cmpl   $0x64,-0x1d4c4(%rbp)
jge    1321 <stackDynMatrixMult+0x1f1>
movl   $0x0,-0x1d4c8(%rbp)
cmpl   $0x64,-0x1d4c8(%rbp)
jge    1308 <stackDynMatrixMult+0x1d8>
movl   $0x0,-0x1d4cc(%rbp)
cmpl   $0x64,-0x1d4cc(%rbp)
jge    12ef <stackDynMatrixMult+0x1bf>
movslq -0x1d4c4(%rbp),%rcx
lea    -0x9c40(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d4cc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
movslq -0x1d4cc(%rbp),%rcx
lea    -0x13880(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d4c8(%rbp),%rcx
imul   (%rax,%rcx,4),%edx
movslq -0x1d4c4(%rbp),%rcx
lea    -0x1d4c0(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x1d4c8(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x1d4cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4cc(%rbp)
jmp    1264 <stackDynMatrixMult+0x134>
jmp    12f4 <stackDynMatrixMult+0x1c4>
mov    -0x1d4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4c8(%rbp)
jmp    124d <stackDynMatrixMult+0x11d>
jmp    130d <stackDynMatrixMult+0x1dd>
mov    -0x1d4c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4c4(%rbp)
jmp    1236 <stackDynMatrixMult+0x106>
add    $0x1d4d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stackDynMatrixMult>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1d4c8,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
lea    0x9c40(%rsp),%r14
mov    %rsp,%r12
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%r14,%rbx,4)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1170 <stackDynMatrixMult+0x40>
add    $0x1,%r15
add    $0x190,%r14
add    $0x190,%r12
cmp    $0x64,%r15
jne    1160 <stackDynMatrixMult+0x30>
lea    0x9c40(%rsp),%rax
xor    %r9d,%r9d
mov    %rsp,%r8
nopw   0x0(%rax,%rax,1)
mov    %r8,%rdx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
imul   $0x190,%r9,%rcx
add    %rsp,%rcx
add    $0x13880,%rcx
lea    (%rcx,%rdi,4),%rbx
movd   (%rcx,%rdi,4),%xmm0
mov    %rdx,%rsi
xor    %ecx,%ecx
nop
movdqa (%rax,%rcx,4),%xmm1
movd   0x4b0(%rsi),%xmm2
movd   0x320(%rsi),%xmm3
punpckldq %xmm2,%xmm3
movd   0x190(%rsi),%xmm2
movd   (%rsi),%xmm4
punpckldq %xmm2,%xmm4
punpcklqdq %xmm3,%xmm4
pshufd $0xf5,%xmm4,%xmm2
pmuludq %xmm1,%xmm4
pshufd $0xe8,%xmm4,%xmm3
pshufd $0xf5,%xmm1,%xmm1
pmuludq %xmm2,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm3
paddd  %xmm3,%xmm0
add    $0x4,%rcx
add    $0x640,%rsi
cmp    $0x64,%rcx
jne    1230 <stackDynMatrixMult+0x100>
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,(%rbx)
add    $0x1,%rdi
add    $0x4,%rdx
cmp    $0x64,%rdi
jne    1210 <stackDynMatrixMult+0xe0>
add    $0x1,%r9
add    $0x190,%rax
cmp    $0x64,%r9
jne    1200 <stackDynMatrixMult+0xd0>
add    $0x1d4c8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @stackDynMatrixMult() {
%1 = alloca [100 x [100 x i32]]
%2 = alloca [100 x [100 x i32]]
%3 = alloca [100 x [100 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %4
br label %9
9: ; preds = %39, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %42
12: ; preds = %9
store i32 0, i32* %5
br label %13
13: ; preds = %35, %12
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %38
16: ; preds = %13
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 100
%19 = add nsw i32 %18, 1
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i32], [100 x i32]* %22, i64 0, i64 %24
store i32 %19, i32* %25
%26 = call i32 (...) @rand()
%27 = srem i32 %26, 100
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %30
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %31, i64 0, i64 %33
store i32 %28, i32* %34
br label %35
35: ; preds = %16
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %13
38: ; preds = %13
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %9
42: ; preds = %9
store i32 0, i32* %6
store i32 0, i32* %4
br label %43
43: ; preds = %86, %42
%44 = load i32, i32* %4
%45 = icmp slt i32 %44, 100
br i1 %45, label %46, label %89
46: ; preds = %43
store i32 0, i32* %5
br label %47
47: ; preds = %82, %46
%48 = load i32, i32* %5
%49 = icmp slt i32 %48, 100
br i1 %49, label %50, label %85
50: ; preds = %47
store i32 0, i32* %6
br label %51
51: ; preds = %78, %50
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 100
br i1 %53, label %54, label %81
54: ; preds = %51
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %56
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i32], [100 x i32]* %57, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %63
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100 x i32], [100 x i32]* %64, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = mul nsw i32 %61, %68
%70 = load i32, i32* %4
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 %71
%73 = load i32, i32* %5
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [100 x i32], [100 x i32]* %72, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = add nsw i32 %76, %69
store i32 %77, i32* %75
br label %78
78: ; preds = %54
%79 = load i32, i32* %6
%80 = add nsw i32 %79, 1
store i32 %80, i32* %6
br label %51
81: ; preds = %51
br label %82
82: ; preds = %81
%83 = load i32, i32* %5
%84 = add nsw i32 %83, 1
store i32 %84, i32* %5
br label %47
85: ; preds = %47
br label %86
86: ; preds = %85
%87 = load i32, i32* %4
%88 = add nsw i32 %87, 1
store i32 %88, i32* %4
br label %43
89: ; preds = %43
ret void
}

LLVM IR (-O2):
define void @stackDynMatrixMult() {
%1 = alloca [100 x [100 x i32]]
%2 = alloca [100 x [100 x i32]]
%3 = alloca [100 x [100 x i32]]
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = bitcast [100 x [100 x i32]]* %1 to i8*
%7 = bitcast [100 x [100 x i32]]* %2 to i8*
%8 = bitcast [100 x [100 x i32]]* %3 to i8*
br label %9
9: ; preds = %0, %23
%10 = phi i64 [ 0, %0 ], [ %24, %23 ]
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %21, %11 ]
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 100
%15 = add nsw i32 %14, 1
%16 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %10, i64 %12
store i32 %15, i32* %16
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 100
%19 = add nsw i32 %18, 1
%20 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %10, i64 %12
store i32 %19, i32* %20
%21 = add nuw nsw i64 %12, 1
%22 = icmp eq i64 %21, 100
br i1 %22, label %23, label %11
23: ; preds = %11
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, 100
br i1 %25, label %26, label %9
26: ; preds = %23, %62
%27 = phi i64 [ %63, %62 ], [ 0, %23 ]
br label %28
28: ; preds = %26, %58
%29 = phi i64 [ 0, %26 ], [ %60, %58 ]
%30 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 %27, i64 %29
%31 = load i32, i32* %30
%32 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %31, i64 0
br label %33
33: ; preds = %33, %28
%34 = phi i64 [ 0, %28 ], [ %56, %33 ]
%35 = phi <4 x i32> [ %32, %28 ], [ %55, %33 ]
%36 = or i64 %34, 1
%37 = or i64 %34, 2
%38 = or i64 %34, 3
%39 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %27, i64 %34
%40 = bitcast i32* %39 to <4 x i32>*
%41 = load <4 x i32>, <4 x i32>* %40
%42 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %34, i64 %29
%43 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %36, i64 %29
%44 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %37, i64 %29
%45 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %38, i64 %29
%46 = load i32, i32* %42
%47 = load i32, i32* %43
%48 = load i32, i32* %44
%49 = load i32, i32* %45
%50 = insertelement <4 x i32> poison, i32 %46, i64 0
%51 = insertelement <4 x i32> %50, i32 %47, i64 1
%52 = insertelement <4 x i32> %51, i32 %48, i64 2
%53 = insertelement <4 x i32> %52, i32 %49, i64 3
%54 = mul nsw <4 x i32> %53, %41
%55 = add <4 x i32> %35, %54
%56 = add nuw i64 %34, 4
%57 = icmp eq i64 %56, 100
br i1 %57, label %58, label %33
58: ; preds = %33
%59 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %55)
store i32 %59, i32* %30
%60 = add nuw nsw i64 %29, 1
%61 = icmp eq i64 %60, 100
br i1 %61, label %62, label %28
62: ; preds = %58
%63 = add nuw nsw i64 %27, 1
%64 = icmp eq i64 %63, 100
br i1 %64, label %65, label %26
65: ; preds = %62
ret void
}