#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(float *, float *, int, int);
int /*<<< orphan*/ memset(float **, int /*<<< orphan*/, int);
void f2(void) {
  float array_of_mat[(100)][(100)][(100)];
  float mat_sum[(100)][(100)];
  memset(mat_sum, 0, sizeof(mat_sum));
  int i;
#pragma omp parallel for reduction(add_mat : mat_sum)
  for (i = 0; i < (100); i++) {
    add_mat(&mat_sum[0][0], &array_of_mat[i][0][0], (100), (100));
  }
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3da550,%rsp
lea    -0x3da540(%rbp),%rdi
xor    %esi,%esi
mov    $0x9c40,%edx
call   1030 <memset@plt>
movl   $0x0,-0x3da544(%rbp)
cmpl   $0x64,-0x3da544(%rbp)
jge    1194 <f2+0x74>
lea    -0x3da540(%rbp),%rdi
movslq -0x3da544(%rbp),%rax
lea    -0x3d0900(%rbp),%rsi
imul   $0x9c40,%rax,%rax
add    %rax,%rsi
mov    $0x64,%ecx
mov    %ecx,%edx
call   1040 <add_mat@plt>
mov    -0x3da544(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3da544(%rbp)
jmp    1148 <f2+0x28>
add    $0x3da550,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
push   %r14
push   %rbx
sub    $0x3da548,%rsp
mov    %rsp,%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x9c40,%edx
call   1030 <memset@plt>
xchg   %ax,%ax
lea    (%rsp,%rbx,1),%rsi
add    $0x9c40,%rsi
mov    %r14,%rdi
mov    $0x64,%edx
mov    $0x64,%ecx
call   1040 <add_mat@plt>
add    $0x9c40,%rbx
cmp    $0x3d0900,%rbx
jne    1140 <f2+0x20>
add    $0x3da548,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @f2() {
%1 = alloca [100 x [100 x [100 x float]]]
%2 = alloca [100 x [100 x float]]
%3 = alloca i32
%4 = getelementptr inbounds [100 x [100 x float]], [100 x [100 x float]]* %2, i64 0, i64 0
%5 = bitcast [100 x float]* %4 to float**
%6 = call i32 @memset(float** %5, i32 0, i32 40000)
store i32 0, i32* %3
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = getelementptr inbounds [100 x [100 x float]], [100 x [100 x float]]* %2, i64 0, i64 0
%12 = getelementptr inbounds [100 x float], [100 x float]* %11, i64 0, i64 0
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x [100 x [100 x float]]], [100 x [100 x [100 x float]]]* %1, i64 0, i64 %14
%16 = getelementptr inbounds [100 x [100 x float]], [100 x [100 x float]]* %15, i64 0, i64 0
%17 = getelementptr inbounds [100 x float], [100 x float]* %16, i64 0, i64 0
%18 = call i32 @add_mat(float* %12, float* %17, i32 100, i32 100)
br label %19
19: ; preds = %10
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %7
22: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @f2() {
%1 = alloca [100 x [100 x [100 x float]]]
%2 = alloca [100 x [100 x float]]
%3 = bitcast [100 x [100 x [100 x float]]]* %1 to i8*
%4 = bitcast [100 x [100 x float]]* %2 to i8*
%5 = bitcast [100 x [100 x float]]* %2 to float**
%6 = call i32 @memset(float** %5, i32 0, i32 40000)
%7 = getelementptr inbounds [100 x [100 x float]], [100 x [100 x float]]* %2, i64 0, i64 0, i64 0
br label %8
8: ; preds = %0, %8
%9 = phi i64 [ 0, %0 ], [ %12, %8 ]
%10 = getelementptr inbounds [100 x [100 x [100 x float]]], [100 x [100 x [100 x float]]]* %1, i64 0, i64 %9, i64 0, i64 0
%11 = call i32 @add_mat(float* %7, float* %10, i32 100, i32 100)
%12 = add nuw nsw i64 %9, 1
%13 = icmp eq i64 %12, 100
br i1 %13, label %14, label %8
14: ; preds = %8
ret void
}