#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*/ vec_sum;

/* Variables and functions */
int /*<<< orphan*/ add_vec(int, float *, float *);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
void f1(int num_vectors, int vector_size) {
  float array_of_vec[num_vectors][vector_size];
  float vec_sum[vector_size];
  memset(vec_sum, 0, sizeof(vec_sum));
  int i;
#pragma omp parallel for reduction(add_vec : vec_sum)
  for (i = 0; i < num_vectors; i++) {
    add_vec(vector_size, &vec_sum[0], &array_of_vec[i][0]);
  }
}


x86 assembly (clang, -O0):
<f1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rdx
imul   %rax,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11da <f1+0xba>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x8(%rbp),%edi
movslq -0x2c(%rbp),%rax
imul   %rcx,%rax
shl    $0x2,%rax
add    %rax,%rdx
call   1040 <add_vec@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119d <f1+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f1>:
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
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(,%r14,4),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11a7 <f1+0x87>
shl    $0x2,%r12
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <add_vec@plt>
add    %r12,%rbx
add    $0xffffffffffffffff,%r13
jne    1190 <f1+0x70>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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