#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 *vec3_add(float a[3], float b[3]) {
  float *r;
  r = (float *)malloc(3 * sizeof(float));
  r[0] = a[0] + b[0];
  r[1] = a[1] + b[1];
  r[2] = a[2] + b[2];
  return r;
}


x86 assembly (clang, -O0):
<vec3_add>:
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,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
addss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
addss  0x4(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
addss  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec3_add>:
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  %xmm0,(%rax)
movss  0x4(%rbx),%xmm0
addss  0x4(%r14),%xmm0
movss  %xmm0,0x4(%rax)
movss  0x8(%rbx),%xmm0
addss  0x8(%r14),%xmm0
movss  %xmm0,0x8(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float* @vec3_add(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float*
store float* %0, float** %3
store float* %1, float** %4
%6 = call i64 @malloc(i32 12)
%7 = inttoptr i64 %6 to float*
store float* %7, float** %5
%8 = load float*, float** %3
%9 = getelementptr inbounds float, float* %8, i64 0
%10 = load float, float* %9
%11 = load float*, float** %4
%12 = getelementptr inbounds float, float* %11, i64 0
%13 = load float, float* %12
%14 = fadd float %10, %13
%15 = load float*, float** %5
%16 = getelementptr inbounds float, float* %15, i64 0
store float %14, float* %16
%17 = load float*, float** %3
%18 = getelementptr inbounds float, float* %17, i64 1
%19 = load float, float* %18
%20 = load float*, float** %4
%21 = getelementptr inbounds float, float* %20, i64 1
%22 = load float, float* %21
%23 = fadd float %19, %22
%24 = load float*, float** %5
%25 = getelementptr inbounds float, float* %24, i64 1
store float %23, float* %25
%26 = load float*, float** %3
%27 = getelementptr inbounds float, float* %26, i64 2
%28 = load float, float* %27
%29 = load float*, float** %4
%30 = getelementptr inbounds float, float* %29, i64 2
%31 = load float, float* %30
%32 = fadd float %28, %31
%33 = load float*, float** %5
%34 = getelementptr inbounds float, float* %33, i64 2
store float %32, float* %34
%35 = load float*, float** %5
ret float* %35
}

LLVM IR (-O2):
define float* @vec3_add(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
store float %7, float* %4
%8 = getelementptr inbounds float, float* %0, i64 1
%9 = load float, float* %8
%10 = getelementptr inbounds float, float* %1, i64 1
%11 = load float, float* %10
%12 = fadd float %9, %11
%13 = getelementptr inbounds float, float* %4, i64 1
store float %12, float* %13
%14 = getelementptr inbounds float, float* %0, i64 2
%15 = load float, float* %14
%16 = getelementptr inbounds float, float* %1, i64 2
%17 = load float, float* %16
%18 = fadd float %15, %17
%19 = getelementptr inbounds float, float* %4, i64 2
store float %18, float* %19
ret float* %4
}