#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 */
typedef int /*<<< orphan*/ mat_sum;

/* Variables and functions */
int /*<<< orphan*/ add_mat(int, int, float *, float *);
int /*<<< orphan*/ memset(float **, int /*<<< orphan*/, int);
void f2(int num_mats, int vector_size) {
  float array_of_mat[num_mats][vector_size][vector_size];
  float mat_sum[vector_size][vector_size];
  memset(mat_sum, 0, sizeof(mat_sum));
  int i;
#pragma omp parallel for reduction(add_mat : mat_sum)
  for (i = 0; i < num_mats; i++) {
    add_mat(vector_size, vector_size, &mat_sum[0][0], &array_of_mat[i][0][0]);
  }
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
mov    %rax,-0x68(%rbp)
mov    %rax,%rdx
mov    %rdx,-0x60(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rdx
imul   %rax,%rdx
imul   %rax,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x58(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
imul   %rcx,%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1224 <f2+0x104>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    -0x68(%rbp),%r9
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%r8
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
imul   $0x0,%r8,%r8
shl    $0x2,%r8
add    %r8,%rdx
movslq -0x3c(%rbp),%r8
imul   %rax,%r9
imul   %r9,%r8
shl    $0x2,%r8
add    %r8,%rcx
imul   $0x0,%rax,%rax
shl    $0x2,%rax
add    %rax,%rcx
call   1040 <add_mat@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11c2 <f2+0xa2>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,-0x2c(%rbp)
mov    %edi,%r13d
mov    %esi,%r12d
imul   %r12,%r12
mov    %r12,%rax
imul   %r13,%rax
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r15
lea    0xf(,%r12,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0x0(,%r12,4),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11aa <f2+0x8a>
shl    $0x2,%r12
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %r14d,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1040 <add_mat@plt>
add    %r12,%rbx
add    $0xffffffffffffffff,%r13
jne    1190 <f2+0x70>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @f2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = load i32, i32* %4
%15 = zext i32 %14 to i64
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %5
%19 = mul nuw i64 %13, %15
%20 = mul nuw i64 %19, %17
%21 = alloca float, i64 %20
store i64 %13, i64* %6
store i64 %15, i64* %7
store i64 %17, i64* %8
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = load i32, i32* %4
%25 = zext i32 %24 to i64
%26 = mul nuw i64 %23, %25
%27 = alloca float, i64 %26
store i64 %23, i64* %9
store i64 %25, i64* %10
%28 = bitcast float* %27 to float**
%29 = mul nuw i64 %23, %25
%30 = mul nuw i64 4, %29
%31 = trunc i64 %30 to i32
%32 = call i32 @memset(float** %28, i32 0, i32 %31)
store i32 0, i32* %11
br label %33
33: ; preds = %52, %2
%34 = load i32, i32* %11
%35 = load i32, i32* %3
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %55
37: ; preds = %33
%38 = load i32, i32* %4
%39 = load i32, i32* %4
%40 = mul nsw i64 0, %25
%41 = getelementptr inbounds float, float* %27, i64 %40
%42 = getelementptr inbounds float, float* %41, i64 0
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = mul nuw i64 %15, %17
%46 = mul nsw i64 %44, %45
%47 = getelementptr inbounds float, float* %21, i64 %46
%48 = mul nsw i64 0, %17
%49 = getelementptr inbounds float, float* %47, i64 %48
%50 = getelementptr inbounds float, float* %49, i64 0
%51 = call i32 @add_mat(i32 %38, i32 %39, float* %42, float* %50)
br label %52
52: ; preds = %37
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %33
55: ; preds = %33
%56 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
define void @f2(i32 %0, i32 %1) {
%3 = zext i32 %0 to i64
%4 = zext i32 %1 to i64
%5 = mul nuw i64 %4, %4
%6 = mul i64 %5, %3
%7 = alloca float, i64 %6
%8 = alloca float, i64 %5
%9 = bitcast float* %8 to float**
%10 = trunc i64 %5 to i32
%11 = shl i32 %10, 2
%12 = call i32 @memset(float** %9, i32 0, i32 %11)
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %21
14: ; preds = %2, %14
%15 = phi i64 [ %19, %14 ], [ 0, %2 ]
%16 = mul nsw i64 %5, %15
%17 = getelementptr inbounds float, float* %7, i64 %16
%18 = call i32 @add_mat(i32 %1, i32 %1, float* %8, float* %17)
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %3
br i1 %20, label %21, label %14
21: ; preds = %14, %2
ret void
}