; LLVM IR from Dutta-SD/Numerical_Methods :: Linear_Algebra (Power_Method)

; 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"

@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

declare i32 @printf(ptr noundef, ...) #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @Max_Arr(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

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

; Function Attrs: nounwind uwtable
define dso_local void @Power_Method() #0 {
  %1 = alloca [3 x [3 x double]], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca [3 x [1 x double]], align 16
  %7 = alloca [3 x [1 x double]], align 16
  %8 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store double 1.000000e-04, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds [3 x [3 x double]], ptr %1, i64 0, i64 0
  call void @Matrix_Input(ptr noundef %9)
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %18, %0
  %11 = load i32, ptr %2, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 3
  br i1 %12, label %13, label %21

13:                                               ; preds = %10
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [3 x [1 x double]], ptr %6, i64 0, i64 %15
  %17 = getelementptr inbounds [1 x double], ptr %16, i64 0, i64 0
  store double 1.000000e+00, ptr %17, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %2, align 4, !tbaa !9
  br label %10, !llvm.loop !11

21:                                               ; preds = %10
  %22 = getelementptr inbounds [3 x [3 x double]], ptr %1, i64 0, i64 0
  %23 = getelementptr inbounds [3 x [1 x double]], ptr %6, i64 0, i64 0
  %24 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 0
  call void @MatMult(ptr noundef %22, ptr noundef %23, ptr noundef %24)
  store double 0.000000e+00, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 0
  %26 = call double @Max_Arr(ptr noundef %25)
  store double %26, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 0
  %28 = load double, ptr %4, align 8, !tbaa !5
  call void @Divide_by_Eigen(ptr noundef %27, double noundef %28)
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %42, %21
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %31 = icmp slt i32 %30, 3
  br i1 %31, label %32, label %45

32:                                               ; preds = %29
  %33 = load i32, ptr %2, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 %34
  %36 = getelementptr inbounds [1 x double], ptr %35, i64 0, i64 0
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [3 x [1 x double]], ptr %6, i64 0, i64 %39
  %41 = getelementptr inbounds [1 x double], ptr %40, i64 0, i64 0
  store double %37, ptr %41, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %32
  %43 = load i32, ptr %2, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %2, align 4, !tbaa !9
  br label %29, !llvm.loop !13

45:                                               ; preds = %29
  br label %46

46:                                               ; preds = %78, %45
  %47 = load double, ptr %4, align 8, !tbaa !5
  %48 = load double, ptr %5, align 8, !tbaa !5
  %49 = fsub double %47, %48
  %50 = call double @llvm.fabs.f64(double %49)
  %51 = load double, ptr %8, align 8, !tbaa !5
  %52 = fcmp ogt double %50, %51
  br i1 %52, label %53, label %79

53:                                               ; preds = %46
  %54 = load double, ptr %4, align 8, !tbaa !5
  store double %54, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds [3 x [3 x double]], ptr %1, i64 0, i64 0
  %56 = getelementptr inbounds [3 x [1 x double]], ptr %6, i64 0, i64 0
  %57 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 0
  call void @MatMult(ptr noundef %55, ptr noundef %56, ptr noundef %57)
  %58 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 0
  %59 = call double @Max_Arr(ptr noundef %58)
  store double %59, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 0
  %61 = load double, ptr %4, align 8, !tbaa !5
  call void @Divide_by_Eigen(ptr noundef %60, double noundef %61)
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %75, %53
  %63 = load i32, ptr %2, align 4, !tbaa !9
  %64 = icmp slt i32 %63, 3
  br i1 %64, label %65, label %78

65:                                               ; preds = %62
  %66 = load i32, ptr %2, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [3 x [1 x double]], ptr %7, i64 0, i64 %67
  %69 = getelementptr inbounds [1 x double], ptr %68, i64 0, i64 0
  %70 = load double, ptr %69, align 8, !tbaa !5
  %71 = load i32, ptr %2, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [3 x [1 x double]], ptr %6, i64 0, i64 %72
  %74 = getelementptr inbounds [1 x double], ptr %73, i64 0, i64 0
  store double %70, ptr %74, align 8, !tbaa !5
  br label %75

75:                                               ; preds = %65
  %76 = load i32, ptr %2, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %2, align 4, !tbaa !9
  br label %62, !llvm.loop !14

78:                                               ; preds = %62
  br label %46, !llvm.loop !15

79:                                               ; preds = %46
  %80 = load double, ptr %4, align 8, !tbaa !5
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %80)
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %93, %79
  %84 = load i32, ptr %2, align 4, !tbaa !9
  %85 = icmp slt i32 %84, 3
  br i1 %85, label %86, label %96

86:                                               ; preds = %83
  %87 = load i32, ptr %2, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [3 x [1 x double]], ptr %6, i64 0, i64 %88
  %90 = getelementptr inbounds [1 x double], ptr %89, i64 0, i64 0
  %91 = load double, ptr %90, align 8, !tbaa !5
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %91)
  br label %93

93:                                               ; preds = %86
  %94 = load i32, ptr %2, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %2, align 4, !tbaa !9
  br label %83, !llvm.loop !16

96:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %1) #4
  ret void
}

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 = { "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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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"

@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @Max_Arr(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

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

; Function Attrs: nounwind uwtable
define dso_local void @Power_Method() local_unnamed_addr #0 {
.preheader:
  %0 = alloca [3 x [3 x double]], align 16
  %1 = alloca [3 x [1 x double]], align 16
  %2 = alloca [3 x [1 x double]], align 16
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %0) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  call void @Matrix_Input(ptr noundef nonnull %0)
  store <2 x double> <double 1.000000e+00, double 1.000000e+00>, ptr %1, align 16, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store double 1.000000e+00, ptr %3, align 16, !tbaa !5
  call void @MatMult(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = call double @Max_Arr(ptr noundef nonnull %2)
  call void @Divide_by_Eigen(ptr noundef nonnull %2, double noundef %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %1, ptr noundef nonnull align 16 dereferenceable(24) %2, i64 24, i1 false), !tbaa !5
  %5 = call double @llvm.fabs.f64(double %4)
  %6 = fcmp ogt double %5, 1.000000e-04
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.02125 = phi double [ %7, %.lr.ph ], [ %4, %.preheader ]
  call void @MatMult(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %7 = call double @Max_Arr(ptr noundef nonnull %2)
  call void @Divide_by_Eigen(ptr noundef nonnull %2, double noundef %7)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %1, ptr noundef nonnull align 16 dereferenceable(24) %2, i64 24, i1 false), !tbaa !5
  %8 = fsub double %7, %.02125
  %9 = call double @llvm.fabs.f64(double %8)
  %10 = fcmp ogt double %9, 1.000000e-04
  br i1 %10, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.021.lcssa = phi double [ %4, %.preheader ], [ %7, %.lr.ph ]
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %.021.lcssa)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %14 = load double, ptr %1, align 16, !tbaa !5
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %14)
  %16 = load double, ptr %11, align 8, !tbaa !5
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %16)
  %18 = load double, ptr %3, align 16, !tbaa !5
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %18)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #5
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %0) #5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass