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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN26KConnectedComponentLabeler11KLinkedListD2Ev(ptr noundef nonnull align 8 dereferenceable(12) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %7 = getelementptr inbounds %"class.KConnectedComponentLabeler::KLinkedList", ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %9 = getelementptr inbounds %"class.KConnectedComponentLabeler::KLinkedList", ptr %6, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %10, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %11 = getelementptr inbounds %"class.KConnectedComponentLabeler::KLinkedList", ptr %6, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.KConnectedComponentLabeler::KLinkedList", ptr %6, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %73

16:                                               ; preds = %1
  br label %17

17:                                               ; preds = %69, %16
  br label %18

18:                                               ; preds = %51, %17
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %28

23:                                               ; preds = %18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %24, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  store ptr %27, ptr %4, align 8, !tbaa !5
  br label %50

28:                                               ; preds = %18
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %49

33:                                               ; preds = %28
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %40, label %36

36:                                               ; preds = %33
  %37 = load ptr, ptr %34, align 8, !tbaa !14
  %38 = getelementptr inbounds ptr, ptr %37, i64 1
  %39 = load ptr, ptr %38, align 8
  call void %39(ptr noundef nonnull align 8 dereferenceable(28) %34) #2
  br label %40

40:                                               ; preds = %36, %33
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %46

43:                                               ; preds = %40
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %44, i32 0, i32 2
  store ptr null, ptr %45, align 8, !tbaa !12
  br label %46

46:                                               ; preds = %43, %40
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %47, ptr %4, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %48, ptr %5, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %46, %28
  br label %50

50:                                               ; preds = %49, %23
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !12
  %55 = icmp ne ptr %54, null
  br i1 %55, label %18, label %56, !llvm.loop !16

56:                                               ; preds = %51
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %"class.KConnectedComponentLabeler::KNode", ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  store ptr %59, ptr %3, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = icmp eq ptr %60, null
  br i1 %61, label %66, label %62

62:                                               ; preds = %56
  %63 = load ptr, ptr %60, align 8, !tbaa !14
  %64 = getelementptr inbounds ptr, ptr %63, i64 1
  %65 = load ptr, ptr %64, align 8
  call void %65(ptr noundef nonnull align 8 dereferenceable(28) %60) #2
  br label %66

66:                                               ; preds = %62, %56
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %67, ptr %4, align 8, !tbaa !5
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %68, ptr %5, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %66
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %17, label %72, !llvm.loop !19

72:                                               ; preds = %69
  br label %73

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

attributes #0 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN26KConnectedComponentLabeler11KLinkedListE", !6, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"_ZTSN26KConnectedComponentLabeler5KNodeE", !6, i64 8, !6, i64 16, !11, i64 24}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!13, !6, i64 8}
!19 = distinct !{!19, !17}


; 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 nounwind uwtable
define dso_local void @_ZN26KConnectedComponentLabeler11KLinkedListD2Ev(ptr nocapture noundef nonnull readonly align 8 dereferenceable(12) %0) unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %1, %.thread
  %.0 = phi ptr [ %15, %.thread ], [ %2, %1 ]
  %3 = getelementptr inbounds i8, ptr %.0, i64 16
  %.pre27.pre = load ptr, ptr %3, align 8, !tbaa !11
  br label %4

4:                                                ; preds = %13, %.preheader
  %.pre27 = phi ptr [ %.pre27.pre, %.preheader ], [ %.pre2728, %13 ]
  %.117 = phi ptr [ %.0, %.preheader ], [ %.218, %13 ]
  %.1 = phi ptr [ %.0, %.preheader ], [ %.2, %13 ]
  %5 = getelementptr inbounds i8, ptr %.117, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %.not23 = icmp eq ptr %6, null
  br i1 %.not23, label %7, label %13

7:                                                ; preds = %4
  %.not24 = icmp eq ptr %.pre27, null
  br i1 %.not24, label %.thread, label %8

8:                                                ; preds = %7
  %9 = load ptr, ptr %.117, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load ptr, ptr %10, align 8
  tail call void %11(ptr noundef nonnull align 8 dereferenceable(28) %.117) #1
  %12 = getelementptr inbounds i8, ptr %.1, i64 16
  store ptr null, ptr %12, align 8, !tbaa !11
  %.pre = load ptr, ptr %3, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %4, %8
  %.pre2728 = phi ptr [ %.pre, %8 ], [ %.pre27, %4 ]
  %.218 = phi ptr [ %.0, %8 ], [ %6, %4 ]
  %.2 = phi ptr [ %.0, %8 ], [ %.117, %4 ]
  %.not25 = icmp eq ptr %.pre2728, null
  br i1 %.not25, label %.thread, label %4, !llvm.loop !15

.thread:                                          ; preds = %7, %13
  %.21834 = phi ptr [ %.218, %13 ], [ %.117, %7 ]
  %14 = getelementptr inbounds i8, ptr %.0, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  %16 = load ptr, ptr %.21834, align 8, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load ptr, ptr %17, align 8
  tail call void %18(ptr noundef nonnull align 8 dereferenceable(28) %.21834) #1
  %.not26 = icmp eq ptr %15, null
  br i1 %.not26, label %.loopexit, label %.preheader, !llvm.loop !18

.loopexit:                                        ; preds = %.thread, %1
  ret void
}

attributes #0 = { 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 #1 = { 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 = !{!12, !7, i64 16}
!12 = !{!"_ZTSN26KConnectedComponentLabeler5KNodeE", !7, i64 8, !7, i64 16, !10, i64 24}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !9, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !7, i64 8}
!18 = distinct !{!18, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass