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


x86 assembly (clang, -O0):
<vec3_dot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define float* @vec3_dot(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 4)
%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 = load float*, float** %3
%15 = getelementptr inbounds float, float* %14, i64 1
%16 = load float, float* %15
%17 = load float*, float** %4
%18 = getelementptr inbounds float, float* %17, i64 1
%19 = load float, float* %18
%20 = fmul float %16, %19
%21 = call float @llvm.fmuladd.f32(float %10, float %13, float %20)
%22 = load float*, float** %3
%23 = getelementptr inbounds float, float* %22, i64 2
%24 = load float, float* %23
%25 = load float*, float** %4
%26 = getelementptr inbounds float, float* %25, i64 2
%27 = load float, float* %26
%28 = call float @llvm.fmuladd.f32(float %24, float %27, float %21)
%29 = load float*, float** %5
store float %28, float* %29
%30 = load float*, float** %5
ret float* %30
}

LLVM IR (-O2):
define float* @vec3_dot(float* nocapture %0, float* nocapture %1) {
%3 = tail call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to float*
%5 = load float, float* %0
%6 = load float, float* %1
%7 = getelementptr inbounds float, float* %0, i64 1
%8 = load float, float* %7
%9 = getelementptr inbounds float, float* %1, i64 1
%10 = load float, float* %9
%11 = fmul float %8, %10
%12 = tail call float @llvm.fmuladd.f32(float %5, float %6, float %11)
%13 = getelementptr inbounds float, float* %0, i64 2
%14 = load float, float* %13
%15 = getelementptr inbounds float, float* %1, i64 2
%16 = load float, float* %15
%17 = tail call float @llvm.fmuladd.f32(float %14, float %16, float %12)
store float %17, float* %4
ret float* %4
}