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

; 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 void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80)) #3 align 2

declare i32 @usleep(i32 noundef) #4

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN9clearpath9Transport8waitNextENS_12MessageTypesEd(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1, double noundef %2) #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !11
  %13 = load ptr, ptr %5, align 8
  br label %14

14:                                               ; preds = %3
  %15 = getelementptr inbounds %"class.clearpath::Transport", ptr %13, i32 0, i32 0
  %16 = load i8, ptr %15, align 8, !tbaa !13, !range !23, !noundef !24
  %17 = trunc i8 %16 to i1
  br i1 %17, label %32, label %18

18:                                               ; preds = %14
  %19 = call ptr @__cxa_allocate_exception(i64 8) #5
  %20 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #6
          to label %21 unwind label %23

21:                                               ; preds = %18
  invoke void @_ZN9clearpath18TransportExceptionC1EPKcNS0_6errorsE(ptr noundef nonnull align 8 dereferenceable(12) %20, ptr noundef @.str.16, i32 noundef 1)
          to label %22 unwind label %27

22:                                               ; preds = %21
  store ptr %20, ptr %19, align 16, !tbaa !5
  call void @__cxa_throw(ptr %19, ptr @_ZTIPN9clearpath18TransportExceptionE, ptr null) #7
  unreachable

23:                                               ; preds = %18
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %8, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %9, align 4
  br label %31

27:                                               ; preds = %21
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %8, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %9, align 4
  call void @_ZdlPvm(ptr noundef %20, i64 noundef 16) #8
  br label %31

31:                                               ; preds = %27, %23
  call void @__cxa_free_exception(ptr %19) #5
  br label %56

32:                                               ; preds = %14
  br label %33

33:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store double 0.000000e+00, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  br label %34

34:                                               ; preds = %50, %33
  br label %35

35:                                               ; preds = %34
  call void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80) %13)
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = call noundef ptr @_ZN9clearpath9Transport7popNextENS_12MessageTypesE(ptr noundef nonnull align 8 dereferenceable(80) %13, i32 noundef %36)
  store ptr %37, ptr %11, align 8, !tbaa !5
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %42

40:                                               ; preds = %35
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %41, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %54

42:                                               ; preds = %35
  %43 = load double, ptr %7, align 8, !tbaa !11
  %44 = fcmp une double %43, 0.000000e+00
  br i1 %44, label %45, label %50

45:                                               ; preds = %42
  %46 = load double, ptr %10, align 8, !tbaa !11
  %47 = load double, ptr %7, align 8, !tbaa !11
  %48 = fcmp ogt double %46, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %45
  store ptr null, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %54

50:                                               ; preds = %45, %42
  %51 = call i32 @usleep(i32 noundef 1000)
  %52 = load double, ptr %10, align 8, !tbaa !11
  %53 = fadd double %52, 1.000000e-03
  store double %53, ptr %10, align 8, !tbaa !11
  br label %34, !llvm.loop !25

54:                                               ; preds = %49, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %55 = load ptr, ptr %4, align 8
  ret ptr %55

56:                                               ; preds = %31
  %57 = load ptr, ptr %8, align 8
  %58 = load i32, ptr %9, align 4
  %59 = insertvalue { ptr, i32 } poison, ptr %57, 0
  %60 = insertvalue { ptr, i32 } %59, i32 %58, 1
  resume { ptr, i32 } %60
}

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 = { "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 = { noreturn }
attributes #8 = { 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 = !{!"_ZTSN9clearpath12MessageTypesE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTSN9clearpath9TransportE", !15, i64 0, !6, i64 8, !16, i64 16, !17, i64 24, !7, i64 48}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTSNSt7__cxx114listIPN9clearpath7MessageESaIS3_EEE", !18, i64 0}
!18 = !{!"_ZTSNSt7__cxx1110_List_baseIPN9clearpath7MessageESaIS3_EEE", !19, i64 0}
!19 = !{!"_ZTSNSt7__cxx1110_List_baseIPN9clearpath7MessageESaIS3_EE10_List_implE", !20, i64 0}
!20 = !{!"_ZTSNSt8__detail17_List_node_headerE", !21, i64 0, !22, i64 16}
!21 = !{!"_ZTSNSt8__detail15_List_node_baseE", !6, i64 0, !6, i64 8}
!22 = !{!"long", !7, i64 0}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = distinct !{!25, !26}
!26 = !{!"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 void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

declare i32 @usleep(i32 noundef) local_unnamed_addr #3

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

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

.preheader:                                       ; preds = %3
  tail call void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %6 = tail call noundef ptr @_ZN9clearpath9Transport7popNextENS_12MessageTypesE(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1)
  %.not16 = icmp eq ptr %6, null
  br i1 %.not16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %7 = fcmp une double %2, 0.000000e+00
  br i1 %7, label %.lr.ph.split, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %8 = tail call i32 @usleep(i32 noundef 1000)
  tail call void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %9 = tail call noundef ptr @_ZN9clearpath9Transport7popNextENS_12MessageTypesE(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1)
  %.not.us = icmp eq ptr %9, null
  br i1 %.not.us, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !20

.lr.ph.split:                                     ; preds = %.lr.ph
  %10 = fcmp olt double %2, 0.000000e+00
  br i1 %10, label %._crit_edge, label %.lr.ph21

11:                                               ; preds = %3
  %12 = tail call ptr @__cxa_allocate_exception(i64 8) #4
  %13 = invoke noalias noundef nonnull dereferenceable(16) 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 nonnull @.str.16, i32 noundef 1)
          to label %15 unwind label %18

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

16:                                               ; preds = %11
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %20

18:                                               ; preds = %14
  %19 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %13, i64 noundef 16) #7
  br label %20

20:                                               ; preds = %18, %16
  %.pn = phi { ptr, i32 } [ %19, %18 ], [ %17, %16 ]
  tail call void @__cxa_free_exception(ptr %12) #4
  resume { ptr, i32 } %.pn

21:                                               ; preds = %.lr.ph21
  %22 = fadd double %.0101720, 1.000000e-03
  %23 = fcmp ogt double %22, %2
  br i1 %23, label %._crit_edge, label %.lr.ph21, !llvm.loop !20

.lr.ph21:                                         ; preds = %.lr.ph.split, %21
  %.0101720 = phi double [ %22, %21 ], [ 0.000000e+00, %.lr.ph.split ]
  %24 = tail call i32 @usleep(i32 noundef 1000)
  tail call void @_ZN9clearpath9Transport4pollEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %25 = tail call noundef ptr @_ZN9clearpath9Transport7popNextENS_12MessageTypesE(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1)
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %21, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %.lr.ph.split.us, %.lr.ph21, %21, %.lr.ph.split, %.preheader
  %.lcssa = phi ptr [ %6, %.preheader ], [ null, %.lr.ph.split ], [ %25, %.lr.ph21 ], [ null, %21 ], [ %9, %.lr.ph.split.us ]
  ret ptr %.lcssa
}

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 = { "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, !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 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!10, !10, i64 0}


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