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


x86 assembly (clang, -O0):
<vec3_scale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  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_scale>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  %xmm0,0xc(%rsp)
mov    $0xc,%edi
call   1030 <malloc@plt>
movss  (%rbx),%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,(%rax)
movss  0x4(%rbx),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%rax)
mulss  0x8(%rbx),%xmm1
movss  %xmm1,0x8(%rax)
add    $0x10,%rsp
pop    %rbx
ret

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

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