; LLVM IR from VAR-solutions/Algorithms :: Graphs/Minimum Spanning Tree/C++/data-structures (LinkedGraph)

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

%class.LinkedGraph = type { ptr }

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11LinkedGraph7addEdgeEiii(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = getelementptr inbounds %class.LinkedGraph, ptr %12, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = call noundef i32 @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(12) %15)
  %17 = icmp slt i32 %13, %16
  br i1 %17, label %18, label %53

18:                                               ; preds = %4
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = getelementptr inbounds %class.LinkedGraph, ptr %12, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = call noundef i32 @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(12) %21)
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %24, label %53

24:                                               ; preds = %18
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp sge i32 %25, 0
  br i1 %26, label %27, label %53

27:                                               ; preds = %24
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = icmp sge i32 %28, 0
  br i1 %29, label %30, label %53

30:                                               ; preds = %27
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %33, label %53

33:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %34 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 12) #6
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = load i32, ptr %8, align 4, !tbaa !9
  invoke void @_ZN15LinkedGraphEdgeC1Eiii(ptr noundef nonnull align 4 dereferenceable(12) %34, i32 noundef %35, i32 noundef %36, i32 noundef %37)
          to label %38 unwind label %49

38:                                               ; preds = %33
  store ptr %34, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %class.LinkedGraph, ptr %12, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = call noundef ptr @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE3getEi(ptr noundef nonnull align 8 dereferenceable(12) %40, i32 noundef %41)
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN10LinkedListIP15LinkedGraphEdgeE3addES1_(ptr noundef nonnull align 8 dereferenceable(20) %42, ptr noundef %43)
  %44 = getelementptr inbounds %class.LinkedGraph, ptr %12, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = call noundef ptr @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE3getEi(ptr noundef nonnull align 8 dereferenceable(12) %45, i32 noundef %46)
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN10LinkedListIP15LinkedGraphEdgeE3addES1_(ptr noundef nonnull align 8 dereferenceable(20) %47, ptr noundef %48)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %53

49:                                               ; preds = %33
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %10, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %11, align 4
  call void @_ZdlPvm(ptr noundef %34, i64 noundef 12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %54

53:                                               ; preds = %38, %30, %27, %24, %18, %4
  ret void

54:                                               ; preds = %49
  %55 = load ptr, ptr %10, align 8
  %56 = load i32, ptr %11, align 4
  %57 = insertvalue { ptr, i32 } poison, ptr %55, 0
  %58 = insertvalue { ptr, i32 } %57, i32 %56, 1
  resume { ptr, i32 } %58
}

declare noundef i32 @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(12)) #4

declare void @_ZN15LinkedGraphEdgeC1Eiii(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #4

declare noundef ptr @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE3getEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) #4

declare void @_ZN10LinkedListIP15LinkedGraphEdgeE3addES1_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef) #4

attributes #0 = { nobuiltin allocsize(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 = { nobuiltin 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 #4 = { "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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS11LinkedGraph", !6, i64 0}


; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11LinkedGraph7addEdgeEiii(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = tail call noundef i32 @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(12) %5)
  %7 = icmp sgt i32 %6, %1
  br i1 %7, label %8, label %24

8:                                                ; preds = %4
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = tail call noundef i32 @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(12) %9)
  %11 = icmp sgt i32 %10, %2
  %12 = or i32 %2, %1
  %13 = icmp sgt i32 %12, -1
  %or.cond3 = and i1 %13, %11
  %14 = icmp sgt i32 %3, 0
  %or.cond5 = and i1 %14, %or.cond3
  br i1 %or.cond5, label %15, label %24

15:                                               ; preds = %8
  %16 = tail call noalias noundef nonnull dereferenceable(12) ptr @_Znwm(i64 noundef 12) #4
  invoke void @_ZN15LinkedGraphEdgeC1Eiii(ptr noundef nonnull align 4 dereferenceable(12) %16, i32 noundef %1, i32 noundef %2, i32 noundef %3)
          to label %17 unwind label %22

17:                                               ; preds = %15
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = tail call noundef ptr @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE3getEi(ptr noundef nonnull align 8 dereferenceable(12) %18, i32 noundef %1)
  tail call void @_ZN10LinkedListIP15LinkedGraphEdgeE3addES1_(ptr noundef nonnull align 8 dereferenceable(20) %19, ptr noundef nonnull %16)
  %20 = load ptr, ptr %0, align 8, !tbaa !5
  %21 = tail call noundef ptr @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE3getEi(ptr noundef nonnull align 8 dereferenceable(12) %20, i32 noundef %2)
  tail call void @_ZN10LinkedListIP15LinkedGraphEdgeE3addES1_(ptr noundef nonnull align 8 dereferenceable(20) %21, ptr noundef nonnull %16)
  br label %24

22:                                               ; preds = %15
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %16, i64 noundef 12) #5
  resume { ptr, i32 } %23

24:                                               ; preds = %17, %8, %4
  ret void
}

declare noundef i32 @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE7getSizeEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #3

declare void @_ZN15LinkedGraphEdgeC1Eiii(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3

declare noundef ptr @_ZN9ArrayListIP10LinkedListIP15LinkedGraphEdgeEE3getEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) local_unnamed_addr #3

declare void @_ZN10LinkedListIP15LinkedGraphEdgeE3addES1_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef) local_unnamed_addr #3

attributes #0 = { nobuiltin allocsize(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 = { nobuiltin 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 #2 = { mustprogress 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 #3 = { "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 #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !7, i64 0}
!6 = !{!"_ZTS11LinkedGraph", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass