; LLVM IR from MinhasKamal/AlgorithmImplementations :: numericalMethods/equationSolving (LinearEquationSolvingProcess)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 3, ptr %2, align 4, !tbaa !5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = zext i32 %9 to i64
  %11 = call ptr @llvm.stacksave.p0()
  store ptr %11, ptr %3, align 8
  %12 = alloca double, i64 %10, align 16
  store i64 %10, ptr %4, align 8
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = zext i32 %13 to i64
  %15 = alloca double, i64 %14, align 16
  store i64 %14, ptr %5, align 8
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = mul nuw i64 %17, %19
  %21 = alloca double, i64 %20, align 16
  store i64 %17, ptr %6, align 8
  store i64 %19, ptr %7, align 8
  %22 = mul nsw i64 0, %19
  %23 = getelementptr inbounds double, ptr %21, i64 %22
  %24 = getelementptr inbounds double, ptr %23, i64 0
  store double 8.000000e+00, ptr %24, align 8, !tbaa !9
  %25 = mul nsw i64 0, %19
  %26 = getelementptr inbounds double, ptr %21, i64 %25
  %27 = getelementptr inbounds double, ptr %26, i64 1
  store double 2.000000e+00, ptr %27, align 8, !tbaa !9
  %28 = mul nsw i64 0, %19
  %29 = getelementptr inbounds double, ptr %21, i64 %28
  %30 = getelementptr inbounds double, ptr %29, i64 2
  store double -2.000000e+00, ptr %30, align 8, !tbaa !9
  %31 = getelementptr inbounds double, ptr %15, i64 0
  store double 8.000000e+00, ptr %31, align 16, !tbaa !9
  %32 = mul nsw i64 1, %19
  %33 = getelementptr inbounds double, ptr %21, i64 %32
  %34 = getelementptr inbounds double, ptr %33, i64 0
  store double 1.000000e+00, ptr %34, align 8, !tbaa !9
  %35 = mul nsw i64 1, %19
  %36 = getelementptr inbounds double, ptr %21, i64 %35
  %37 = getelementptr inbounds double, ptr %36, i64 1
  store double -8.000000e+00, ptr %37, align 8, !tbaa !9
  %38 = mul nsw i64 1, %19
  %39 = getelementptr inbounds double, ptr %21, i64 %38
  %40 = getelementptr inbounds double, ptr %39, i64 2
  store double 3.000000e+00, ptr %40, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %15, i64 1
  store double -4.000000e+00, ptr %41, align 8, !tbaa !9
  %42 = mul nsw i64 2, %19
  %43 = getelementptr inbounds double, ptr %21, i64 %42
  %44 = getelementptr inbounds double, ptr %43, i64 0
  store double 2.000000e+00, ptr %44, align 8, !tbaa !9
  %45 = mul nsw i64 2, %19
  %46 = getelementptr inbounds double, ptr %21, i64 %45
  %47 = getelementptr inbounds double, ptr %46, i64 1
  store double 1.000000e+00, ptr %47, align 8, !tbaa !9
  %48 = mul nsw i64 2, %19
  %49 = getelementptr inbounds double, ptr %21, i64 %48
  %50 = getelementptr inbounds double, ptr %49, i64 2
  store double 9.000000e+00, ptr %50, align 8, !tbaa !9
  %51 = getelementptr inbounds double, ptr %15, i64 2
  store double 1.200000e+01, ptr %51, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %60, %0
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %56, label %63

56:                                               ; preds = %52
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %12, i64 %58
  store double 0.000000e+00, ptr %59, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %56
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %8, align 4, !tbaa !5
  br label %52, !llvm.loop !11

63:                                               ; preds = %52
  %64 = load i32, ptr %2, align 4, !tbaa !5
  call void @JacobisMethod(i32 noundef %64, ptr noundef %12, ptr noundef %15, ptr noundef %21)
  %65 = load i32, ptr %2, align 4, !tbaa !5
  call void @print(i32 noundef %65, ptr noundef %12)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %74, %63
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %70, label %77

70:                                               ; preds = %66
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds double, ptr %12, i64 %72
  store double 0.000000e+00, ptr %73, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %70
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %8, align 4, !tbaa !5
  br label %66, !llvm.loop !13

77:                                               ; preds = %66
  %78 = load i32, ptr %2, align 4, !tbaa !5
  call void @GaussSeidalMethod(i32 noundef %78, ptr noundef %12, ptr noundef %15, ptr noundef %21)
  %79 = load i32, ptr %2, align 4, !tbaa !5
  call void @print(i32 noundef %79, ptr noundef %12)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %80 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %80)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %81 = load i32, ptr %1, align 4
  ret i32 %81
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nounwind uwtable
declare dso_local void @JacobisMethod(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @print(i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @GaussSeidalMethod(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [3 x double], align 16
  %2 = alloca [3 x double], align 16
  %3 = alloca [9 x double], align 16
  store <2 x double> <double 8.000000e+00, double 2.000000e+00>, ptr %3, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  store <2 x double> <double -2.000000e+00, double 1.000000e+00>, ptr %4, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 32
  store <2 x double> <double -8.000000e+00, double 3.000000e+00>, ptr %5, align 16, !tbaa !5
  store <2 x double> <double 8.000000e+00, double -4.000000e+00>, ptr %2, align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 48
  store <2 x double> <double 2.000000e+00, double 1.000000e+00>, ptr %6, align 16, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %3, i64 64
  store double 9.000000e+00, ptr %7, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 16
  store double 1.200000e+01, ptr %8, align 16, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %1, i8 0, i64 24, i1 false), !tbaa !5
  call void @JacobisMethod(i32 noundef 3, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  call void @print(i32 noundef 3, ptr noundef nonnull %1)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %1, i8 0, i64 24, i1 false), !tbaa !5
  call void @GaussSeidalMethod(i32 noundef 3, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  call void @print(i32 noundef 3, ptr noundef nonnull %1)
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local void @JacobisMethod(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @print(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @GaussSeidalMethod(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass