#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 */
int /*<<< orphan*/ printVector(double *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ vectorAddition(double *, double *, int);
double vectorLength(double *, int);
void testVectorAlgebra() {
  double v[] = {4, 11, 8, 10};
  double vLength = 0;
  double v1[] = {3, 2, 1, -2};
  double v2[] = {2, -1, 4, 1};
  printf("\nMatrix\n");
  vLength = vectorLength(v, 4);
  printf("vector length: %f\n", vLength);
  printf("vector addition\n");
  vectorAddition(v1, v2, 4);
  printVector(v1, 4);
}


x86 assembly (clang, -O0):
<testVectorAlgebra>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe8e(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe8b(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe88(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1060 <vectorLength@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x4,%edx
call   1050 <vectorAddition@plt>
lea    -0x50(%rbp),%rdi
mov    $0x4,%esi
call   1040 <printVector@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testVectorAlgebra>:
push   %rbx
sub    $0x60,%rsp
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0x40(%rsp),%rdi
mov    $0x4,%esi
call   1070 <vectorLength@plt>
lea    0xea2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1060 <vectorAddition@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <printVector@plt>
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.testVectorAlgebra.v = [4 x double] [double 4.000000e+00, double 1.100000e+01, double 8.000000e+00, double 1.000000e+01]
@__const.testVectorAlgebra.v1 = [4 x double] [double 3.000000e+00, double 2.000000e+00, double 1.000000e+00, double -2.000000e+00]
@__const.testVectorAlgebra.v2 = [4 x double] [double 2.000000e+00, double -1.000000e+00, double 4.000000e+00, double 1.000000e+00]
@.str = [9 x i8] c"\0AMatrix\0A\00"
@.str.1 = [19 x i8] c"vector length: %f\0A\00"
@.str.2 = [17 x i8] c"vector addition\0A\00"
define void @testVectorAlgebra() {
%1 = alloca [4 x double]
%2 = alloca double
%3 = alloca [4 x double]
%4 = alloca [4 x double]
%5 = bitcast [4 x double]* %1 to i8*
store double 0.000000e+00, double* %2
%6 = bitcast [4 x double]* %3 to i8*
%7 = bitcast [4 x double]* %4 to i8*
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%10 = call double @vectorLength(double* %9, i32 4)
store double %10, double* %2
%11 = load double, double* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 0
%15 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 0
%16 = call i32 @vectorAddition(double* %14, double* %15, i32 4)
%17 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 0
%18 = call i32 @printVector(double* %17, i32 4)
ret void
}

LLVM IR (-O2):
@__const.testVectorAlgebra.v = [4 x double] [double 4.000000e+00, double 1.100000e+01, double 8.000000e+00, double 1.000000e+01]
@__const.testVectorAlgebra.v1 = [4 x double] [double 3.000000e+00, double 2.000000e+00, double 1.000000e+00, double -2.000000e+00]
@__const.testVectorAlgebra.v2 = [4 x double] [double 2.000000e+00, double -1.000000e+00, double 4.000000e+00, double 1.000000e+00]
@.str.1 = [19 x i8] c"vector length: %f\0A\00"
@str = [8 x i8] c"\0AMatrix\00"
@str.3 = [16 x i8] c"vector addition\00"
define void @testVectorAlgebra() {
%1 = alloca [4 x double]
%2 = alloca [4 x double]
%3 = alloca [4 x double]
%4 = bitcast [4 x double]* %1 to i8*
%5 = bitcast [4 x double]* %2 to i8*
%6 = bitcast [4 x double]* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%9 = call double @vectorLength(double* %8, i32 4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.3, i64 0, i64 0))
%12 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 0
%13 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 0
%14 = call i32 @vectorAddition(double* %12, double* %13, i32 4)
%15 = call i32 @printVector(double* %12, i32 4)
ret void
}