; LLVM IR from dmr-goncalves/HumanAwareRobotNavigation :: src/husky/husky_base/src/horizon_legacy/Transport.ll (ZN9clearpath9Transport4pollEv)

; 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.clearpath::Transport" = type { i8, ptr, i32, %"class.std::__cxx11::list", [4 x i64] }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<clearpath::Message *, std::allocator<clearpath::Message *>>::_List_impl" }
%"struct.std::__cxx11::_List_base<clearpath::Message *, std::allocator<clearpath::Message *>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }

@_ZTIPN9clearpath18TransportExceptionE = external dso_local constant { ptr, ptr, i32, ptr }, align 8
@.str.16 = external hidden unnamed_addr constant [25 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

declare ptr @__cxa_allocate_exception(i64)

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

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

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9clearpath7Message6isDataEv(ptr noundef nonnull align 8 dereferenceable(273)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9clearpath9Transport14enqueueMessageEPNS_7MessageE(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  br label %7

7:                                                ; preds = %1
  %8 = getelementptr inbounds %"class.clearpath::Transport", ptr %6, i32 0, i32 0
  %9 = load i8, ptr %8, align 8, !tbaa !9, !range !19, !noundef !20
  %10 = trunc i8 %9 to i1
  br i1 %10, label %25, label %11

11:                                               ; preds = %7
  %12 = call ptr @__cxa_allocate_exception(i64 8) #4
  %13 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #5
          to label %14 unwind label %16

14:                                               ; preds = %11
  invoke void @_ZN9clearpath18TransportExceptionC1EPKcNS0_6errorsE(ptr noundef nonnull align 8 dereferenceable(12) %13, ptr noundef @.str.16, i32 noundef 1)
          to label %15 unwind label %20

15:                                               ; preds = %14
  store ptr %13, ptr %12, align 16, !tbaa !5
  call void @__cxa_throw(ptr %12, ptr @_ZTIPN9clearpath18TransportExceptionE, ptr null) #6
  unreachable

16:                                               ; preds = %11
  %17 = landingpad { ptr, i32 }
          cleanup
  %18 = extractvalue { ptr, i32 } %17, 0
  store ptr %18, ptr %3, align 8
  %19 = extractvalue { ptr, i32 } %17, 1
  store i32 %19, ptr %4, align 4
  br label %24

20:                                               ; preds = %14
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %3, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %13, i64 noundef 16) #7
  br label %24

24:                                               ; preds = %20, %16
  call void @__cxa_free_exception(ptr %12) #4
  br label %48

25:                                               ; preds = %7
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %45, %44, %26
  %28 = call noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  store ptr %28, ptr %5, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %47

30:                                               ; preds = %27
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call noundef zeroext i1 @_ZN9clearpath7Message6isDataEv(ptr noundef nonnull align 8 dereferenceable(273) %31)
  br i1 %32, label %45, label %33

33:                                               ; preds = %30
  %34 = getelementptr inbounds %"class.clearpath::Transport", ptr %6, i32 0, i32 4
  %35 = getelementptr inbounds [4 x i64], ptr %34, i64 0, i64 2
  %36 = load i64, ptr %35, align 8, !tbaa !21
  %37 = add i64 %36, 1
  store i64 %37, ptr %35, align 8, !tbaa !21
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %44, label %40

40:                                               ; preds = %33
  %41 = load ptr, ptr %38, align 8, !tbaa !22
  %42 = getelementptr inbounds ptr, ptr %41, i64 1
  %43 = load ptr, ptr %42, align 8
  call void %43(ptr noundef nonnull align 8 dereferenceable(273) %38) #4
  br label %44

44:                                               ; preds = %40, %33
  br label %27, !llvm.loop !24

45:                                               ; preds = %30
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN9clearpath9Transport14enqueueMessageEPNS_7MessageE(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef %46)
  br label %27, !llvm.loop !24

47:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void

48:                                               ; preds = %24
  %49 = load ptr, ptr %3, align 8
  %50 = load i32, ptr %4, align 4
  %51 = insertvalue { ptr, i32 } poison, ptr %49, 0
  %52 = insertvalue { ptr, i32 } %51, i32 %50, 1
  resume { ptr, i32 } %52
}

declare void @_ZN9clearpath18TransportExceptionC1EPKcNS0_6errorsE(ptr, ptr, i32)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { nounwind }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { noreturn }
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, !11, i64 0}
!10 = !{!"_ZTSN9clearpath9TransportE", !11, i64 0, !6, i64 8, !12, i64 16, !13, i64 24, !7, i64 48}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSNSt7__cxx114listIPN9clearpath7MessageESaIS3_EEE", !14, i64 0}
!14 = !{!"_ZTSNSt7__cxx1110_List_baseIPN9clearpath7MessageESaIS3_EEE", !15, i64 0}
!15 = !{!"_ZTSNSt7__cxx1110_List_baseIPN9clearpath7MessageESaIS3_EE10_List_implE", !16, i64 0}
!16 = !{!"_ZTSNSt8__detail17_List_node_headerE", !17, i64 0, !18, i64 16}
!17 = !{!"_ZTSNSt8__detail15_List_node_baseE", !6, i64 0, !6, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!18, !18, i64 0}
!22 = !{!23, !23, i64 0}
!23 = !{!"vtable pointer", !8, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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

@_ZTIPN9clearpath18TransportExceptionE = external dso_local constant { ptr, ptr, i32, ptr }, align 8
@.str.16 = external hidden unnamed_addr constant [25 x i8], align 1

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

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

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

declare void @__cxa_free_exception(ptr) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN9clearpath7Message6isDataEv(ptr noundef nonnull align 8 dereferenceable(273)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9clearpath9Transport14enqueueMessageEPNS_7MessageE(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80) %0) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = load i8, ptr %0, align 8, !tbaa !5, !range !18, !noundef !19
  %3 = trunc nuw i8 %2 to i1
  br i1 %3, label %.preheader, label %6

.preheader:                                       ; preds = %1
  %4 = tail call noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %.not8 = icmp eq ptr %4, null
  br i1 %.not8, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  br label %16

6:                                                ; preds = %1
  %7 = tail call ptr @__cxa_allocate_exception(i64 8) #3
  %8 = invoke noalias noundef nonnull dereferenceable(16) ptr @_Znwm(i64 noundef 16) #4
          to label %9 unwind label %11

9:                                                ; preds = %6
  invoke void @_ZN9clearpath18TransportExceptionC1EPKcNS0_6errorsE(ptr noundef nonnull align 8 dereferenceable(12) %8, ptr noundef nonnull @.str.16, i32 noundef 1)
          to label %10 unwind label %13

10:                                               ; preds = %9
  store ptr %8, ptr %7, align 16, !tbaa !20
  tail call void @__cxa_throw(ptr nonnull %7, ptr nonnull @_ZTIPN9clearpath18TransportExceptionE, ptr null) #5
  unreachable

11:                                               ; preds = %6
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %15

13:                                               ; preds = %9
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %8, i64 noundef 16) #6
  br label %15

15:                                               ; preds = %13, %11
  %.pn = phi { ptr, i32 } [ %14, %13 ], [ %12, %11 ]
  tail call void @__cxa_free_exception(ptr %7) #3
  resume { ptr, i32 } %.pn

16:                                               ; preds = %.lr.ph, %.backedge
  %17 = phi ptr [ %4, %.lr.ph ], [ %25, %.backedge ]
  %18 = tail call noundef zeroext i1 @_ZN9clearpath7Message6isDataEv(ptr noundef nonnull align 8 dereferenceable(273) %17)
  br i1 %18, label %26, label %19

19:                                               ; preds = %16
  %20 = load i64, ptr %5, align 8, !tbaa !21
  %21 = add i64 %20, 1
  store i64 %21, ptr %5, align 8, !tbaa !21
  %22 = load ptr, ptr %17, align 8, !tbaa !22
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8
  tail call void %24(ptr noundef nonnull align 8 dereferenceable(273) %17) #3
  br label %.backedge

.backedge:                                        ; preds = %19, %26
  %25 = tail call noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %._crit_edge, label %16, !llvm.loop !24

26:                                               ; preds = %16
  tail call void @_ZN9clearpath9Transport14enqueueMessageEPNS_7MessageE(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull %17)
  br label %.backedge

._crit_edge:                                      ; preds = %.backedge, %.preheader
  ret void
}

declare void @_ZN9clearpath18TransportExceptionC1EPKcNS0_6errorsE(ptr, ptr, i32) local_unnamed_addr

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 = { nounwind }
attributes #4 = { builtin allocsize(0) }
attributes #5 = { noreturn }
attributes #6 = { 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 = !{!"_ZTSN9clearpath9TransportE", !7, i64 0, !10, i64 8, !11, i64 16, !12, i64 24, !8, i64 48}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_ZTSNSt7__cxx114listIPN9clearpath7MessageESaIS3_EEE", !13, i64 0}
!13 = !{!"_ZTSNSt7__cxx1110_List_baseIPN9clearpath7MessageESaIS3_EEE", !14, i64 0}
!14 = !{!"_ZTSNSt7__cxx1110_List_baseIPN9clearpath7MessageESaIS3_EE10_List_implE", !15, i64 0}
!15 = !{!"_ZTSNSt8__detail17_List_node_headerE", !16, i64 0, !17, i64 16}
!16 = !{!"_ZTSNSt8__detail15_List_node_baseE", !10, i64 0, !10, i64 8}
!17 = !{!"long", !8, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!10, !10, i64 0}
!21 = !{!17, !17, i64 0}
!22 = !{!23, !23, i64 0}
!23 = !{!"vtable pointer", !9, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass