; LLVM IR from dmr-goncalves/HumanAwareRobotNavigation :: src/spencer_people_tracking/detection/rgbd_detectors/rwth_upper_body_detector/src_047de7ae (ZN26KConnectedComponentLabeler11KLinkedList10InsertDataEii)

; 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.KConnectedComponentLabeler::KLinkedList" = type <{ ptr, i32, [4 x i8] }>
%"class.KConnectedComponentLabeler::KNode" = type <{ ptr, ptr, ptr, i32, [4 x i8] }>

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN26KConnectedComponentLabeler11KLinkedList10InsertDataEii(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp ne i32 %11, %12
  br i1 %13, label %14, label %70

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %15 = getelementptr inbounds %"class.KConnectedComponentLabeler::KLinkedList", ptr %10, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %16, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %17 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN26KConnectedComponentLabeler11KLinkedList6SearchEiRPNS_5KNodeE(ptr noundef nonnull align 8 dereferenceable(12) %10, i32 noundef %17, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %18 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN26KConnectedComponentLabeler11KLinkedList6SearchEiRPNS_5KNodeE(ptr noundef nonnull align 8 dereferenceable(12) %10, i32 noundef %18, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %69

21:                                               ; preds = %14
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %69

24:                                               ; preds = %21
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = icmp ne ptr %25, %26
  br i1 %27, label %28, label %69

28:                                               ; preds = %24
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.KConnectedComponentLabeler::KLinkedList", ptr %10, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = icmp ne ptr %29, %31
  br i1 %32, label %33, label %50

33:                                               ; preds = %28
  br label %34

34:                                               ; preds = %40, %33
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = icmp ne ptr %37, %38
  br i1 %39, label %40, label %44

40:                                               ; preds = %34
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  store ptr %43, ptr %7, align 8, !tbaa !5
  br label %34, !llvm.loop !15

44:                                               ; preds = %34
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %48, i32 0, i32 1
  store ptr %47, ptr %49, align 8, !tbaa !13
  br label %55

50:                                               ; preds = %28
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = getelementptr inbounds %"class.KConnectedComponentLabeler::KLinkedList", ptr %10, i32 0, i32 0
  store ptr %53, ptr %54, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %50, %44
  br label %56

56:                                               ; preds = %61, %55
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %65

61:                                               ; preds = %56
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  store ptr %64, ptr %8, align 8, !tbaa !5
  br label %56, !llvm.loop !18

65:                                               ; preds = %56
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %67, i32 0, i32 2
  store ptr %66, ptr %68, align 8, !tbaa !17
  br label %69

69:                                               ; preds = %65, %24, %21, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %70

70:                                               ; preds = %69, %3
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN26KConnectedComponentLabeler11KLinkedList6SearchEiRPNS_5KNodeE(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef, ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 #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 = !{!"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 = !{!"_ZTSN26KConnectedComponentLabeler11KLinkedListE", !6, i64 0, !10, i64 8}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN26KConnectedComponentLabeler5KNodeE", !6, i64 8, !6, i64 16, !10, i64 24}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!14, !6, i64 16}
!18 = distinct !{!18, !16}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN26KConnectedComponentLabeler11KLinkedList10InsertDataEii(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %.not = icmp eq i32 %1, %2
  br i1 %.not, label %29, label %6

6:                                                ; preds = %3
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #2
  call void @_ZN26KConnectedComponentLabeler11KLinkedList6SearchEiRPNS_5KNodeE(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @_ZN26KConnectedComponentLabeler11KLinkedList6SearchEiRPNS_5KNodeE(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %8 = load ptr, ptr %5, align 8, !tbaa !11
  %9 = icmp eq ptr %8, null
  %10 = load ptr, ptr %4, align 8
  %11 = icmp eq ptr %10, null
  %.not15 = icmp eq ptr %8, %10
  %12 = or i1 %11, %.not15
  %or.cond19 = select i1 %9, i1 true, i1 %12
  br i1 %or.cond19, label %28, label %13

13:                                               ; preds = %6
  %14 = load ptr, ptr %0, align 8, !tbaa !5
  %.not16 = icmp eq ptr %8, %14
  br i1 %.not16, label %19, label %.preheader

.preheader:                                       ; preds = %13, %.preheader
  %.0 = phi ptr [ %16, %.preheader ], [ %7, %13 ]
  %15 = getelementptr inbounds i8, ptr %.0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %.not17 = icmp eq ptr %16, %8
  br i1 %.not17, label %17, label %.preheader, !llvm.loop !14

17:                                               ; preds = %.preheader
  %18 = getelementptr inbounds i8, ptr %.0, i64 8
  br label %19

19:                                               ; preds = %13, %17
  %.sink27 = phi ptr [ %18, %17 ], [ %0, %13 ]
  %20 = getelementptr inbounds i8, ptr %8, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  store ptr %21, ptr %.sink27, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %10, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %.not1825 = icmp eq ptr %23, null
  br i1 %.not1825, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %19, %.lr.ph
  %24 = phi ptr [ %26, %.lr.ph ], [ %23, %19 ]
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %.not18 = icmp eq ptr %26, null
  br i1 %.not18, label %._crit_edge, label %.lr.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %19
  %.lcssa24 = phi ptr [ %10, %19 ], [ %24, %.lr.ph ]
  %27 = getelementptr inbounds i8, ptr %.lcssa24, i64 16
  store ptr %8, ptr %27, align 8, !tbaa !16
  br label %28

28:                                               ; preds = %._crit_edge, %6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  br label %29

29:                                               ; preds = %28, %3
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN26KConnectedComponentLabeler11KLinkedList6SearchEiRPNS_5KNodeE(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #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, !7, i64 0}
!6 = !{!"_ZTSN26KConnectedComponentLabeler11KLinkedListE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 8}
!13 = !{!"_ZTSN26KConnectedComponentLabeler5KNodeE", !7, i64 8, !7, i64 16, !10, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !7, i64 16}
!17 = distinct !{!17, !15}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass