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

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

; 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 uwtable
declare dso_local noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN9clearpath9Transport6getAckEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %29, %13, %1
  %8 = call noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %32

10:                                               ; preds = %7
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call noundef zeroext i1 @_ZN9clearpath7Message6isDataEv(ptr noundef nonnull align 8 dereferenceable(273) %11)
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN9clearpath9Transport14enqueueMessageEPNS_7MessageE(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef %14)
  br label %7, !llvm.loop !9

15:                                               ; preds = %10
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_ZN9clearpath7Message7isValidEPcm(ptr noundef nonnull align 8 dereferenceable(273) %16, ptr noundef null, i64 noundef 0)
  br i1 %17, label %30, label %18

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"class.clearpath::Transport", ptr %6, i32 0, i32 4
  %20 = getelementptr inbounds [4 x i64], ptr %19, i64 0, i64 1
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = add i64 %21, 1
  store i64 %22, ptr %20, align 8, !tbaa !11
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %29, label %25

25:                                               ; preds = %18
  %26 = load ptr, ptr %23, align 8, !tbaa !13
  %27 = getelementptr inbounds ptr, ptr %26, i64 1
  %28 = load ptr, ptr %27, align 8
  call void %28(ptr noundef nonnull align 8 dereferenceable(273) %23) #3
  br label %29

29:                                               ; preds = %25, %18
  br label %7, !llvm.loop !9

30:                                               ; preds = %15
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %31, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %33

32:                                               ; preds = %7
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %33

33:                                               ; preds = %32, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %34 = load ptr, ptr %2, align 8
  ret ptr %34
}

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

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

declare noundef zeroext i1 @_ZN9clearpath7Message7isValidEPcm(ptr noundef nonnull align 8 dereferenceable(273), ptr noundef, i64 noundef) #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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, 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: mustprogress uwtable
declare dso_local noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN9clearpath9Transport6getAckEv(ptr noundef nonnull align 8 dereferenceable(80) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %.not8 = icmp eq ptr %2, null
  br i1 %.not8, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  br label %4

4:                                                ; preds = %.lr.ph, %.backedge
  %5 = phi ptr [ %2, %.lr.ph ], [ %8, %.backedge ]
  %6 = tail call noundef zeroext i1 @_ZN9clearpath7Message6isDataEv(ptr noundef nonnull align 8 dereferenceable(273) %5)
  br i1 %6, label %7, label %9

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

.backedge:                                        ; preds = %7, %11
  %8 = tail call noundef ptr @_ZN9clearpath9Transport9rxMessageEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %._crit_edge, label %4, !llvm.loop !5

9:                                                ; preds = %4
  %10 = tail call noundef zeroext i1 @_ZN9clearpath7Message7isValidEPcm(ptr noundef nonnull align 8 dereferenceable(273) %5, ptr noundef null, i64 noundef 0)
  br i1 %10, label %._crit_edge, label %11

11:                                               ; preds = %9
  %12 = load i64, ptr %3, align 8, !tbaa !7
  %13 = add i64 %12, 1
  store i64 %13, ptr %3, align 8, !tbaa !7
  %14 = load ptr, ptr %5, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(273) %5) #2
  br label %.backedge

._crit_edge:                                      ; preds = %9, %.backedge, %1
  %.lcssa = phi ptr [ null, %1 ], [ null, %.backedge ], [ %5, %9 ]
  ret ptr %.lcssa
}

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

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

declare noundef zeroext i1 @_ZN9clearpath7Message7isValidEPcm(ptr noundef nonnull align 8 dereferenceable(273), ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !10, i64 0}


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