#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 */
double get_scale_factor(double const *, int);
void get_vec_covariant(const double *x, double *v, double *vc) {
  vc[0] = v[0] * get_scale_factor(x, 1);
  vc[1] = v[1] * get_scale_factor(x, 0);
  vc[2] = v[2] * get_scale_factor(x, 2);
}


x86 assembly (clang, -O0):
<get_vec_covariant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <get_scale_factor@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <get_scale_factor@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1030 <get_scale_factor@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_vec_covariant>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  (%rsi),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%esi
call   1030 <get_scale_factor@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <get_scale_factor@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    $0x2,%esi
call   1030 <get_scale_factor@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @get_vec_covariant(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%7 = load double*, double** %5
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = load double*, double** %4
%11 = call double @get_scale_factor(double* %10, i32 1)
%12 = fmul double %9, %11
%13 = load double*, double** %6
%14 = getelementptr inbounds double, double* %13, i64 0
store double %12, double* %14
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = call double @get_scale_factor(double* %18, i32 0)
%20 = fmul double %17, %19
%21 = load double*, double** %6
%22 = getelementptr inbounds double, double* %21, i64 1
store double %20, double* %22
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = load double*, double** %4
%27 = call double @get_scale_factor(double* %26, i32 2)
%28 = fmul double %25, %27
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i64 2
store double %28, double* %30
ret void
}

LLVM IR (-O2):
define void @get_vec_covariant(double* %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = load double, double* %1
%5 = tail call double @get_scale_factor(double* %0, i32 1)
%6 = fmul double %4, %5
store double %6, double* %2
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = tail call double @get_scale_factor(double* %0, i32 0)
%10 = fmul double %8, %9
%11 = getelementptr inbounds double, double* %2, i64 1
store double %10, double* %11
%12 = getelementptr inbounds double, double* %1, i64 2
%13 = load double, double* %12
%14 = tail call double @get_scale_factor(double* %0, i32 2)
%15 = fmul double %13, %14
%16 = getelementptr inbounds double, double* %2, i64 2
store double %15, double* %16
ret void
}