#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 norm2(double *, int);
int /*<<< orphan*/ print_vector(double *, int);
int /*<<< orphan*/ printf(char *);
double proj_coeff(double *, double *, int);
void gram_schmidt() {
  double v1[3] = {4.0, 1.0, -1.0};
  double v2[3] = {0.0, 5.0, 2.0};
  double v3[3] = {-1.0, 4.0, 3.0};
  double u1[3] = {0.0};
  double u2[3] = {0.0};
  double u3[3] = {0.0};
  double e1[3] = {0.0};
  double e2[3] = {0.0};
  double e3[3] = {0.0};
  int n = 3;
  int i;
  double temp_coeff;
  double temp_coeff2;
  double temp_norm;
  for (i = 0; i < n; i++) {
    u1[i] = v1[i];
  }
  temp_norm = norm2(u1, n);
  for (i = 0; i < n; i++) {
    u1[i] = u1[i] / temp_norm;
  }
  temp_coeff = proj_coeff(v2, u1, n);
  for (i = 0; i < n; i++) {
    u2[i] = v2[i] - (temp_coeff * u1[i]);
  }
  temp_norm = norm2(u2, n);
  for (i = 0; i < n; i++) {
    u2[i] = u2[i] / temp_norm;
  }
  temp_coeff = proj_coeff(v3, u1, n);
  temp_coeff2 = proj_coeff(v3, u2, n);
  for (i = 0; i < n; i++) {
    u3[i] = v3[i] - (temp_coeff * u1[i]) - (temp_coeff2 * u2[i]);
  }
  temp_norm = norm2(u3, n);
  for (i = 0; i < n; i++) {
    u3[i] = u3[i] / temp_norm;
  }
  printf("\n----------PART 2 : Gram_Schmidt----------\n");
  printf("Normalized vectors : \n");
  printf("\nVector e1: \n");
  print_vector(u1, n);
  printf("\nVector e2: \n");
  print_vector(u2, n);
  printf("\nVector e3: \n");
  print_vector(u3, n);
  printf("\n----------EndOfGram_Schmidt---------\n\n");
}


x86 assembly (clang, -O0):
<gram_schmidt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    0xe9e(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe9c(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe96(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
movl   $0x3,-0x124(%rbp)
movl   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jge    1281 <gram_schmidt+0x131>
movslq -0x128(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
movslq -0x128(%rbp),%rax
movsd  %xmm0,-0x80(%rbp,%rax,8)
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    1241 <gram_schmidt+0xf1>
lea    -0x80(%rbp),%rdi
mov    -0x124(%rbp),%esi
call   1030 <norm2@plt>
movsd  %xmm0,-0x140(%rbp)
ff
movl   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jge    12ea <gram_schmidt+0x19a>
movslq -0x128(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
divsd  -0x140(%rbp),%xmm0
ff
movslq -0x128(%rbp),%rax
movsd  %xmm0,-0x80(%rbp,%rax,8)
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    12a2 <gram_schmidt+0x152>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1070 <proj_coeff@plt>
movsd  %xmm0,-0x130(%rbp)
ff
movl   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jge    1386 <gram_schmidt+0x236>
movslq -0x128(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm1
movsd  -0x130(%rbp),%xmm0
ff
movslq -0x128(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x128(%rbp),%rax
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    130f <gram_schmidt+0x1bf>
lea    -0xa0(%rbp),%rdi
mov    -0x124(%rbp),%esi
call   1030 <norm2@plt>
movsd  %xmm0,-0x140(%rbp)
ff
movl   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jge    13f8 <gram_schmidt+0x2a8>
movslq -0x128(%rbp),%rax
movsd  -0xa0(%rbp,%rax,8),%xmm0
ff ff
divsd  -0x140(%rbp),%xmm0
ff
movslq -0x128(%rbp),%rax
movsd  %xmm0,-0xa0(%rbp,%rax,8)
ff ff
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    13aa <gram_schmidt+0x25a>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1070 <proj_coeff@plt>
movsd  %xmm0,-0x130(%rbp)
ff
lea    -0x60(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1070 <proj_coeff@plt>
movsd  %xmm0,-0x138(%rbp)
ff
movl   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jge    14e9 <gram_schmidt+0x399>
movslq -0x128(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
movsd  -0x130(%rbp),%xmm1
ff
movslq -0x128(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x138(%rbp),%xmm0
ff
movslq -0x128(%rbp),%rax
movsd  -0xa0(%rbp,%rax,8),%xmm2
ff ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x128(%rbp),%rax
movsd  %xmm0,-0xc0(%rbp,%rax,8)
ff ff
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    143b <gram_schmidt+0x2eb>
lea    -0xc0(%rbp),%rdi
mov    -0x124(%rbp),%esi
call   1030 <norm2@plt>
movsd  %xmm0,-0x140(%rbp)
ff
movl   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%eax
cmp    -0x124(%rbp),%eax
jge    155b <gram_schmidt+0x40b>
movslq -0x128(%rbp),%rax
movsd  -0xc0(%rbp,%rax,8),%xmm0
ff ff
divsd  -0x140(%rbp),%xmm0
ff
movslq -0x128(%rbp),%rax
movsd  %xmm0,-0xc0(%rbp,%rax,8)
ff ff
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    150d <gram_schmidt+0x3bd>
lea    0xaf6(%rip),%rdi
call   1040 <printf@plt>
lea    0xb16(%rip),%rdi
call   1040 <printf@plt>
lea    0xb21(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x124(%rbp),%esi
call   1060 <print_vector@plt>
lea    0xb14(%rip),%rdi
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x124(%rbp),%esi
call   1060 <print_vector@plt>
lea    0xb04(%rip),%rdi
call   1040 <printf@plt>
lea    -0xc0(%rbp),%rdi
mov    -0x124(%rbp),%esi
call   1060 <print_vector@plt>
lea    0xaf4(%rip),%rdi
call   1040 <printf@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gram_schmidt>:
push   %r15
push   %r14
push   %rbx
sub    $0xb0,%rsp
mov    0xedd(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
mov    0xedf(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movapd 0xe76(%rip),%xmm0
movapd %xmm0,(%rsp)
mov    0xe7a(%rip),%rax
mov    %rax,0x10(%rsp)
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x3,%esi
call   1040 <norm2@plt>
movapd (%rsp),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0x80(%rsp),%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1060 <proj_coeff@plt>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
mulpd  (%rsp),%xmm1
movapd 0x80(%rsp),%xmm2
subpd  %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
movsd  0x90(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x3,%esi
call   1040 <norm2@plt>
movapd 0x20(%rsp),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  0x30(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1060 <proj_coeff@plt>
movapd %xmm0,0xa0(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1060 <proj_coeff@plt>
movapd 0x60(%rsp),%xmm1
movapd 0xa0(%rsp),%xmm3
movapd %xmm3,%xmm2
unpcklpd %xmm3,%xmm2
mulpd  (%rsp),%xmm2
subpd  %xmm2,%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
mulpd  0x20(%rsp),%xmm2
subpd  %xmm2,%xmm1
movapd %xmm1,0x40(%rsp)
movsd  0x70(%rsp),%xmm1
movapd %xmm3,%xmm2
mulsd  0x10(%rsp),%xmm2
subsd  %xmm2,%xmm1
mulsd  0x30(%rsp),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rsp)
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <norm2@plt>
movapd 0x40(%rsp),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,0x40(%rsp)
movsd  0x50(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rsp)
lea    0xd34(%rip),%rdi
call   1030 <puts@plt>
lea    0xd53(%rip),%rdi
call   1030 <puts@plt>
lea    0xd5d(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x3,%esi
call   1050 <print_vector@plt>
lea    0xd51(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1050 <print_vector@plt>
lea    0xd45(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <print_vector@plt>
lea    0xd39(%rip),%rdi
call   1030 <puts@plt>
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.gram_schmidt.v1 = [3 x double] [double 4.000000e+00, double 1.000000e+00, double -1.000000e+00]
@__const.gram_schmidt.v2 = [3 x double] [double 0.000000e+00, double 5.000000e+00, double 2.000000e+00]
@__const.gram_schmidt.v3 = [3 x double] [double -1.000000e+00, double 4.000000e+00, double 3.000000e+00]
@.str = [44 x i8] c"\0A----------PART 2 : Gram_Schmidt----------\0A\00"
@.str.1 = [23 x i8] c"Normalized vectors : \0A\00"
@.str.2 = [14 x i8] c"\0AVector e1: \0A\00"
@.str.3 = [14 x i8] c"\0AVector e2: \0A\00"
@.str.4 = [14 x i8] c"\0AVector e3: \0A\00"
@.str.5 = [40 x i8] c"\0A----------EndOfGram_Schmidt---------\0A\0A\00"
define void @gram_schmidt() {
%1 = alloca [3 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = bitcast [3 x double]* %1 to i8*
%16 = bitcast [3 x double]* %2 to i8*
%17 = bitcast [3 x double]* %3 to i8*
%18 = bitcast [3 x double]* %4 to i8*
%19 = bitcast [3 x double]* %5 to i8*
%20 = bitcast [3 x double]* %6 to i8*
%21 = bitcast [3 x double]* %7 to i8*
%22 = bitcast [3 x double]* %8 to i8*
%23 = bitcast [3 x double]* %9 to i8*
store i32 3, i32* %10
store i32 0, i32* %11
br label %24
24: ; preds = %36, %0
%25 = load i32, i32* %11
%26 = load i32, i32* %10
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %39
28: ; preds = %24
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 %30
%32 = load double, double* %31
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %34
store double %32, double* %35
br label %36
36: ; preds = %28
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %24
39: ; preds = %24
%40 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%41 = load i32, i32* %10
%42 = call double @norm2(double* %40, i32 %41)
store double %42, double* %14
store i32 0, i32* %11
br label %43
43: ; preds = %57, %39
%44 = load i32, i32* %11
%45 = load i32, i32* %10
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %60
47: ; preds = %43
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %49
%51 = load double, double* %50
%52 = load double, double* %14
%53 = fdiv double %51, %52
%54 = load i32, i32* %11
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %55
store double %53, double* %56
br label %57
57: ; preds = %47
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 1
store i32 %59, i32* %11
br label %43
60: ; preds = %43
%61 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%62 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%63 = load i32, i32* %10
%64 = call double @proj_coeff(double* %61, double* %62, i32 %63)
store double %64, double* %12
store i32 0, i32* %11
br label %65
65: ; preds = %84, %60
%66 = load i32, i32* %11
%67 = load i32, i32* %10
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %87
69: ; preds = %65
%70 = load i32, i32* %11
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 %71
%73 = load double, double* %72
%74 = load double, double* %12
%75 = load i32, i32* %11
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %76
%78 = load double, double* %77
%79 = fneg double %74
%80 = call double @llvm.fmuladd.f64(double %79, double %78, double %73)
%81 = load i32, i32* %11
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %82
store double %80, double* %83
br label %84
84: ; preds = %69
%85 = load i32, i32* %11
%86 = add nsw i32 %85, 1
store i32 %86, i32* %11
br label %65
87: ; preds = %65
%88 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%89 = load i32, i32* %10
%90 = call double @norm2(double* %88, i32 %89)
store double %90, double* %14
store i32 0, i32* %11
br label %91
91: ; preds = %105, %87
%92 = load i32, i32* %11
%93 = load i32, i32* %10
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %108
95: ; preds = %91
%96 = load i32, i32* %11
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %97
%99 = load double, double* %98
%100 = load double, double* %14
%101 = fdiv double %99, %100
%102 = load i32, i32* %11
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %103
store double %101, double* %104
br label %105
105: ; preds = %95
%106 = load i32, i32* %11
%107 = add nsw i32 %106, 1
store i32 %107, i32* %11
br label %91
108: ; preds = %91
%109 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%110 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%111 = load i32, i32* %10
%112 = call double @proj_coeff(double* %109, double* %110, i32 %111)
store double %112, double* %12
%113 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%114 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%115 = load i32, i32* %10
%116 = call double @proj_coeff(double* %113, double* %114, i32 %115)
store double %116, double* %13
store i32 0, i32* %11
br label %117
117: ; preds = %143, %108
%118 = load i32, i32* %11
%119 = load i32, i32* %10
%120 = icmp slt i32 %118, %119
br i1 %120, label %121, label %146
121: ; preds = %117
%122 = load i32, i32* %11
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %123
%125 = load double, double* %124
%126 = load double, double* %12
%127 = load i32, i32* %11
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 %128
%130 = load double, double* %129
%131 = fneg double %126
%132 = call double @llvm.fmuladd.f64(double %131, double %130, double %125)
%133 = load double, double* %13
%134 = load i32, i32* %11
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %135
%137 = load double, double* %136
%138 = fneg double %133
%139 = call double @llvm.fmuladd.f64(double %138, double %137, double %132)
%140 = load i32, i32* %11
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 %141
store double %139, double* %142
br label %143
143: ; preds = %121
%144 = load i32, i32* %11
%145 = add nsw i32 %144, 1
store i32 %145, i32* %11
br label %117
146: ; preds = %117
%147 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%148 = load i32, i32* %10
%149 = call double @norm2(double* %147, i32 %148)
store double %149, double* %14
store i32 0, i32* %11
br label %150
150: ; preds = %164, %146
%151 = load i32, i32* %11
%152 = load i32, i32* %10
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %167
154: ; preds = %150
%155 = load i32, i32* %11
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 %156
%158 = load double, double* %157
%159 = load double, double* %14
%160 = fdiv double %158, %159
%161 = load i32, i32* %11
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 %162
store double %160, double* %163
br label %164
164: ; preds = %154
%165 = load i32, i32* %11
%166 = add nsw i32 %165, 1
store i32 %166, i32* %11
br label %150
167: ; preds = %150
%168 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%169 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%170 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%171 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%172 = load i32, i32* %10
%173 = call i32 @print_vector(double* %171, i32 %172)
%174 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%175 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%176 = load i32, i32* %10
%177 = call i32 @print_vector(double* %175, i32 %176)
%178 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%179 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%180 = load i32, i32* %10
%181 = call i32 @print_vector(double* %179, i32 %180)
%182 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.gram_schmidt.v1 = [3 x double] [double 4.000000e+00, double 1.000000e+00, double -1.000000e+00]
@__const.gram_schmidt.v2 = [3 x double] [double 0.000000e+00, double 5.000000e+00, double 2.000000e+00]
@__const.gram_schmidt.v3 = [3 x double] [double -1.000000e+00, double 4.000000e+00, double 3.000000e+00]
@str = [43 x i8] c"\0A----------PART 2 : Gram_Schmidt----------\00"
@str.6 = [22 x i8] c"Normalized vectors : \00"
@str.7 = [13 x i8] c"\0AVector e1: \00"
@str.8 = [13 x i8] c"\0AVector e2: \00"
@str.9 = [13 x i8] c"\0AVector e3: \00"
@str.10 = [39 x i8] c"\0A----------EndOfGram_Schmidt---------\0A\00"
define void @gram_schmidt() {
%1 = alloca [3 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = bitcast [3 x double]* %3 to i8*
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %1 to i8*
%8 = bitcast [3 x double]* %2 to i8*
%9 = bitcast [3 x double]* %5 to i8*
%10 = bitcast [3 x double]* %6 to i8*
%11 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%12 = call double @norm2(double* %11, i32 3)
%13 = bitcast [3 x double]* %3 to <2 x double>*
%14 = load <2 x double>, <2 x double>* %13
%15 = insertelement <2 x double> poison, double %12, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = fdiv <2 x double> %14, %16
%18 = bitcast [3 x double]* %3 to <2 x double>*
store <2 x double> %17, <2 x double>* %18
%19 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%20 = load double, double* %19
%21 = fdiv double %20, %12
store double %21, double* %19
%22 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%23 = call double @proj_coeff(double* %22, double* %11, i32 3)
%24 = fneg double %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%26 = bitcast [3 x double]* %1 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = bitcast [3 x double]* %3 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = insertelement <2 x double> poison, double %24, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %29, <2 x double> %27)
%33 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %32, <2 x double>* %33
%34 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%35 = load double, double* %34
%36 = load double, double* %19
%37 = call double @llvm.fmuladd.f64(double %24, double %36, double %35)
%38 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %37, double* %38
%39 = call double @norm2(double* %25, i32 3)
%40 = bitcast [3 x double]* %5 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = insertelement <2 x double> poison, double %39, i64 0
%43 = shufflevector <2 x double> %42, <2 x double> poison, <2 x i32> zeroinitializer
%44 = fdiv <2 x double> %41, %43
%45 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %44, <2 x double>* %45
%46 = load double, double* %38
%47 = fdiv double %46, %39
store double %47, double* %38
%48 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%49 = call double @proj_coeff(double* %48, double* %11, i32 3)
%50 = call double @proj_coeff(double* %48, double* %25, i32 3)
%51 = fneg double %49
%52 = fneg double %50
%53 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%54 = bitcast [3 x double]* %2 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = bitcast [3 x double]* %3 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = insertelement <2 x double> poison, double %51, i64 0
%59 = shufflevector <2 x double> %58, <2 x double> poison, <2 x i32> zeroinitializer
%60 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %59, <2 x double> %57, <2 x double> %55)
%61 = bitcast [3 x double]* %5 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = insertelement <2 x double> poison, double %52, i64 0
%64 = shufflevector <2 x double> %63, <2 x double> poison, <2 x i32> zeroinitializer
%65 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %64, <2 x double> %62, <2 x double> %60)
%66 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %65, <2 x double>* %66
%67 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
%68 = load double, double* %67
%69 = load double, double* %19
%70 = call double @llvm.fmuladd.f64(double %51, double %69, double %68)
%71 = load double, double* %38
%72 = call double @llvm.fmuladd.f64(double %52, double %71, double %70)
%73 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %72, double* %73
%74 = call double @norm2(double* %53, i32 3)
%75 = bitcast [3 x double]* %6 to <2 x double>*
%76 = load <2 x double>, <2 x double>* %75
%77 = insertelement <2 x double> poison, double %74, i64 0
%78 = shufflevector <2 x double> %77, <2 x double> poison, <2 x i32> zeroinitializer
%79 = fdiv <2 x double> %76, %78
%80 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %79, <2 x double>* %80
%81 = load double, double* %73
%82 = fdiv double %81, %74
store double %82, double* %73
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%86 = call i32 @print_vector(double* %11, i32 3)
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.8, i64 0, i64 0))
%88 = call i32 @print_vector(double* %25, i32 3)
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%90 = call i32 @print_vector(double* %53, i32 3)
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0))
ret void
}