; LLVM IR from VAR-solutions/Algorithms :: Greedy Algorithms (prims)

; 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
declare dso_local i32 @minKey(ptr noundef, ptr noundef) #0

; 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 memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @primMST(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca [5 x i32], align 16
  %4 = alloca [5 x i32], align 16
  %5 = alloca [5 x i8], align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 20, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 20, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 5, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %22, %1
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 5
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %25

15:                                               ; preds = %11
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [5 x i32], ptr %4, i64 0, i64 %17
  store i32 2147483647, ptr %18, align 4, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [5 x i8], ptr %5, i64 0, i64 %20
  store i8 0, ptr %21, align 1, !tbaa !11
  br label %22

22:                                               ; preds = %15
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !13

25:                                               ; preds = %14
  %26 = getelementptr inbounds [5 x i32], ptr %4, i64 0, i64 0
  store i32 0, ptr %26, align 16, !tbaa !9
  %27 = getelementptr inbounds [5 x i32], ptr %3, i64 0, i64 0
  store i32 -1, ptr %27, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %99, %25
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %102

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %33 = getelementptr inbounds [5 x i32], ptr %4, i64 0, i64 0
  %34 = getelementptr inbounds [5 x i8], ptr %5, i64 0, i64 0
  %35 = call i32 @minKey(ptr noundef %33, ptr noundef %34)
  store i32 %35, ptr %9, align 4, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [5 x i8], ptr %5, i64 0, i64 %37
  store i8 1, ptr %38, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %92, %32
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = icmp slt i32 %40, 5
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %95

43:                                               ; preds = %39
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [5 x i32], ptr %44, i64 %46
  %48 = load i32, ptr %10, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [5 x i32], ptr %47, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %76

53:                                               ; preds = %43
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [5 x i8], ptr %5, i64 0, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !11, !range !15, !noundef !16
  %58 = trunc i8 %57 to i1
  %59 = zext i1 %58 to i32
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %76

61:                                               ; preds = %53
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [5 x i32], ptr %62, i64 %64
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [5 x i32], ptr %65, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !9
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [5 x i32], ptr %4, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = icmp slt i32 %69, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %61
  br label %76

76:                                               ; preds = %75, %61, %53, %43
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [5 x i32], ptr %3, i64 0, i64 %79
  store i32 %77, ptr %80, align 4, !tbaa !9
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = load i32, ptr %9, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [5 x i32], ptr %81, i64 %83
  %85 = load i32, ptr %10, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [5 x i32], ptr %84, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = load i32, ptr %10, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [5 x i32], ptr %4, i64 0, i64 %90
  store i32 %88, ptr %91, align 4, !tbaa !9
  br label %92

92:                                               ; preds = %76
  %93 = load i32, ptr %10, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %10, align 4, !tbaa !9
  br label %39, !llvm.loop !17

95:                                               ; preds = %42
  %96 = getelementptr inbounds [5 x i32], ptr %3, i64 0, i64 0
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = call i32 @printMST(ptr noundef %96, i32 noundef 5, ptr noundef %97)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %99

99:                                               ; preds = %95
  %100 = load i32, ptr %7, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %7, align 4, !tbaa !9
  br label %28, !llvm.loop !18

102:                                              ; preds = %31
  call void @llvm.lifetime.end.p0(i64 5, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 20, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 20, ptr %3) #2
  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 = { 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 = !{!"any pointer", !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 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


; 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
declare dso_local i32 @minKey(ptr noundef, 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: 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 i32 @printMST(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @primMST(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca [5 x i32], align 16
  %3 = alloca [5 x i32], align 16
  %4 = alloca [5 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %4) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(5) %4, i8 0, i64 5, i1 false), !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 2147483647, ptr %5, align 16, !tbaa !9
  store <4 x i32> <i32 0, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %3, align 16, !tbaa !9
  %6 = call i32 @minKey(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 %7
  store i8 1, ptr %8, align 1, !tbaa !5
  %9 = mul nsw i64 %7, 20
  %scevgep = getelementptr i8, ptr %0, i64 %9
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %3, ptr noundef nonnull align 4 dereferenceable(20) %scevgep, i64 20, i1 false), !tbaa !9
  %10 = insertelement <4 x i32> poison, i32 %6, i64 0
  %11 = shufflevector <4 x i32> %10, <4 x i32> poison, <4 x i32> zeroinitializer
  store <4 x i32> %11, ptr %2, align 16, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 %6, ptr %12, align 16, !tbaa !9
  %13 = call i32 @printMST(ptr noundef nonnull %2, i32 noundef 5, ptr noundef %0)
  %14 = call i32 @minKey(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 %15
  store i8 1, ptr %16, align 1, !tbaa !5
  %17 = mul nsw i64 %15, 20
  %scevgep.1 = getelementptr i8, ptr %0, i64 %17
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %3, ptr noundef nonnull align 4 dereferenceable(20) %scevgep.1, i64 20, i1 false), !tbaa !9
  %18 = insertelement <4 x i32> poison, i32 %14, i64 0
  %19 = shufflevector <4 x i32> %18, <4 x i32> poison, <4 x i32> zeroinitializer
  store <4 x i32> %19, ptr %2, align 16, !tbaa !9
  store i32 %14, ptr %12, align 16, !tbaa !9
  %20 = call i32 @printMST(ptr noundef nonnull %2, i32 noundef 5, ptr noundef %0)
  %21 = call i32 @minKey(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 %22
  store i8 1, ptr %23, align 1, !tbaa !5
  %24 = mul nsw i64 %22, 20
  %scevgep.2 = getelementptr i8, ptr %0, i64 %24
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %3, ptr noundef nonnull align 4 dereferenceable(20) %scevgep.2, i64 20, i1 false), !tbaa !9
  %25 = insertelement <4 x i32> poison, i32 %21, i64 0
  %26 = shufflevector <4 x i32> %25, <4 x i32> poison, <4 x i32> zeroinitializer
  store <4 x i32> %26, ptr %2, align 16, !tbaa !9
  store i32 %21, ptr %12, align 16, !tbaa !9
  %27 = call i32 @printMST(ptr noundef nonnull %2, i32 noundef 5, ptr noundef %0)
  %28 = call i32 @minKey(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 %29
  store i8 1, ptr %30, align 1, !tbaa !5
  %31 = mul nsw i64 %29, 20
  %scevgep.3 = getelementptr i8, ptr %0, i64 %31
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %3, ptr noundef nonnull align 4 dereferenceable(20) %scevgep.3, i64 20, i1 false), !tbaa !9
  %32 = insertelement <4 x i32> poison, i32 %28, i64 0
  %33 = shufflevector <4 x i32> %32, <4 x i32> poison, <4 x i32> zeroinitializer
  store <4 x i32> %33, ptr %2, align 16, !tbaa !9
  store i32 %28, ptr %12, align 16, !tbaa !9
  %34 = call i32 @printMST(ptr noundef nonnull %2, i32 noundef 5, ptr noundef %0)
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %2) #4
  ret void
}

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

; 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) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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