#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 */
scalar_t__ malloc(int);
float *RBR_vector_ave(float *V1, float *V2) {
  int i;
  float *V3;
  V3 = (float *)malloc(3 * sizeof(float));
  for (i = 0; i < 3; ++i) {
    V3[i] = ((float)(V1[i] + V2[i]) / 2);
  }
  return V3;
}


x86 assembly (clang, -O0):
<RBR_vector_ave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1180 <RBR_vector_ave+0x70>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  0xe9f(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <RBR_vector_ave+0x25>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RBR_vector_ave>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xc,%edi
call   1030 <malloc@plt>
movss  (%rbx),%xmm0
addss  (%r14),%xmm0
movss  0xecb(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,(%rax)
movss  0x4(%rbx),%xmm0
addss  0x4(%r14),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%rax)
movss  0x8(%rbx),%xmm0
addss  0x8(%r14),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x8(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float* @RBR_vector_ave(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca i32
%6 = alloca float*
store float* %0, float** %3
store float* %1, float** %4
%7 = call i64 @malloc(i32 12)
%8 = inttoptr i64 %7 to float*
store float* %8, float** %6
store i32 0, i32* %5
br label %9
9: ; preds = %29, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load float*, float** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds float, float* %13, i64 %15
%17 = load float, float* %16
%18 = load float*, float** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = load float, float* %21
%23 = fadd float %17, %22
%24 = fdiv float %23, 2.000000e+00
%25 = load float*, float** %6
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
store float %24, float* %28
br label %29
29: ; preds = %12
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %9
32: ; preds = %9
%33 = load float*, float** %6
ret float* %33
}

LLVM IR (-O2):
define float* @RBR_vector_ave(float* nocapture %0, float* nocapture %1) {
%3 = tail call i64 @malloc(i32 12)
%4 = inttoptr i64 %3 to float*
%5 = load float, float* %0
%6 = load float, float* %1
%7 = fadd float %5, %6
%8 = fmul float %7, 5.000000e-01
store float %8, float* %4
%9 = getelementptr inbounds float, float* %0, i64 1
%10 = load float, float* %9
%11 = getelementptr inbounds float, float* %1, i64 1
%12 = load float, float* %11
%13 = fadd float %10, %12
%14 = fmul float %13, 5.000000e-01
%15 = getelementptr inbounds float, float* %4, i64 1
store float %14, float* %15
%16 = getelementptr inbounds float, float* %0, i64 2
%17 = load float, float* %16
%18 = getelementptr inbounds float, float* %1, i64 2
%19 = load float, float* %18
%20 = fadd float %17, %19
%21 = fmul float %20, 5.000000e-01
%22 = getelementptr inbounds float, float* %4, i64 2
store float %21, float* %22
ret float* %4
}