; LLVM IR from HRI-EU/Rcs :: src/RcsCore/MotionControlLayer.ll (ZN3Rcs18MotionControlLayer11updateGraphEv)

; 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.Rcs::MotionControlLayer" = type { ptr, ptr, ptr, %"class.std::vector", ptr, i8, i8, i8, i8, i32, i32, double, double, double, double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Rcs::HardwareComponent *, std::allocator<Rcs::HardwareComponent *>>::_Vector_impl" }
%"struct.std::_Vector_base<Rcs::HardwareComponent *, std::allocator<Rcs::HardwareComponent *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Rcs::HardwareComponent *, std::allocator<Rcs::HardwareComponent *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Rcs::HardwareComponent *, std::allocator<Rcs::HardwareComponent *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct._RcsGraph = type { ptr, [10 x %struct._RcsBody], i32, i32, ptr, ptr, ptr, ptr, ptr }
%struct._RcsBody = type { double, i8, i32, [3 x double], [3 x double], double, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN3Rcs17HardwareComponentESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; 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
define dso_local void @_ZN3Rcs18MotionControlLayer11updateGraphEv(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %22, %1
  %7 = load i64, ptr %3, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 3
  %9 = call noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #4
  %10 = icmp ult i64 %7, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %25

12:                                               ; preds = %6
  %13 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 3
  %14 = load i64, ptr %3, align 8, !tbaa !9
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN3Rcs17HardwareComponentESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %14) #4
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %16, align 8, !tbaa !20
  %20 = getelementptr inbounds ptr, ptr %19, i64 2
  %21 = load ptr, ptr %20, align 8
  call void %21(ptr noundef nonnull align 8 dereferenceable(25) %16, ptr noundef %18)
  br label %22

22:                                               ; preds = %12
  %23 = load i64, ptr %3, align 8, !tbaa !9
  %24 = add i64 %23, 1
  store i64 %24, ptr %3, align 8, !tbaa !9
  br label %6, !llvm.loop !22

25:                                               ; preds = %11
  %26 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !24
  %28 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 7
  %29 = load i8, ptr %28, align 2, !tbaa !25, !range !26, !noundef !27
  %30 = trunc i8 %29 to i1
  br i1 %30, label %31, label %36

31:                                               ; preds = %25
  %32 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !24
  %34 = getelementptr inbounds %struct._RcsGraph, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !28
  br label %37

36:                                               ; preds = %25
  br label %37

37:                                               ; preds = %36, %31
  %38 = phi ptr [ %35, %31 ], [ null, %36 ]
  %39 = call zeroext i1 @RcsGraph_setState(ptr noundef %27, ptr noundef null, ptr noundef %38)
  %40 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 7
  %43 = load i8, ptr %42, align 2, !tbaa !25, !range !26, !noundef !27
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %50

45:                                               ; preds = %37
  %46 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct._RcsGraph, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !28
  br label %51

50:                                               ; preds = %37
  br label %51

51:                                               ; preds = %50, %45
  %52 = phi ptr [ %49, %45 ], [ null, %50 ]
  %53 = call zeroext i1 @RcsGraph_setState(ptr noundef %41, ptr noundef null, ptr noundef %52)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %68, %51
  %55 = load i64, ptr %4, align 8, !tbaa !9
  %56 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 3
  %57 = call noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %56) #4
  %58 = icmp ult i64 %55, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %71

60:                                               ; preds = %54
  %61 = getelementptr inbounds %"class.Rcs::MotionControlLayer", ptr %5, i32 0, i32 3
  %62 = load i64, ptr %4, align 8, !tbaa !9
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN3Rcs17HardwareComponentESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %61, i64 noundef %62) #4
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = load ptr, ptr %64, align 8, !tbaa !20
  %66 = getelementptr inbounds ptr, ptr %65, i64 3
  %67 = load ptr, ptr %66, align 8
  call void %67(ptr noundef nonnull align 8 dereferenceable(25) %64)
  br label %68

68:                                               ; preds = %60
  %69 = load i64, ptr %4, align 8, !tbaa !9
  %70 = add i64 %69, 1
  store i64 %70, ptr %4, align 8, !tbaa !9
  br label %54, !llvm.loop !30

71:                                               ; preds = %59
  ret void
}

declare zeroext i1 @RcsGraph_setState(ptr noundef, ptr noundef, ptr noundef) #3

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 = { 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 }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTSN3Rcs18MotionControlLayerE", !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 48, !17, i64 56, !17, i64 57, !17, i64 58, !17, i64 59, !18, i64 60, !18, i64 64, !19, i64 72, !19, i64 80, !19, i64 88, !19, i64 96}
!13 = !{!"_ZTSSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIPN3Rcs17HardwareComponentESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIPN3Rcs17HardwareComponentESaIS2_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN3Rcs17HardwareComponentESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!"double", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !8, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!12, !6, i64 8}
!25 = !{!12, !17, i64 58}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!29, !6, i64 1864}
!29 = !{!"_ZTS9_RcsGraph", !6, i64 0, !7, i64 8, !18, i64 1848, !18, i64 1852, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888}
!30 = distinct !{!30, !23}


; 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
declare dso_local noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN3Rcs17HardwareComponentESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Rcs18MotionControlLayer11updateGraphEv(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = tail call noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

._crit_edge:                                      ; preds = %10, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 58
  %8 = load i8, ptr %7, align 2, !tbaa !17, !range !18, !noundef !19
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %20, label %23

10:                                               ; preds = %.lr.ph, %10
  %.067 = phi i64 [ 0, %.lr.ph ], [ %17, %10 ]
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN3Rcs17HardwareComponentESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.067) #3
  %12 = load ptr, ptr %11, align 8, !tbaa !20
  %13 = load ptr, ptr %4, align 8, !tbaa !21
  %14 = load ptr, ptr %12, align 8, !tbaa !22
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(25) %12, ptr noundef %13)
  %17 = add nuw i64 %.067, 1
  %18 = tail call noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %10, label %._crit_edge, !llvm.loop !24

20:                                               ; preds = %._crit_edge
  %21 = getelementptr inbounds i8, ptr %6, i64 1864
  %22 = load ptr, ptr %21, align 8, !tbaa !26
  br label %23

23:                                               ; preds = %._crit_edge, %20
  %24 = phi ptr [ %22, %20 ], [ null, %._crit_edge ]
  %25 = tail call zeroext i1 @RcsGraph_setState(ptr noundef %6, ptr noundef null, ptr noundef %24)
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  %28 = load i8, ptr %7, align 2, !tbaa !17, !range !18, !noundef !19
  %29 = trunc nuw i8 %28 to i1
  br i1 %29, label %30, label %33

30:                                               ; preds = %23
  %31 = getelementptr inbounds i8, ptr %27, i64 1864
  %32 = load ptr, ptr %31, align 8, !tbaa !26
  br label %33

33:                                               ; preds = %23, %30
  %34 = phi ptr [ %32, %30 ], [ null, %23 ]
  %35 = tail call zeroext i1 @RcsGraph_setState(ptr noundef %27, ptr noundef null, ptr noundef %34)
  %36 = tail call noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %.not12 = icmp eq i64 %36, 0
  br i1 %.not12, label %._crit_edge11, label %.lr.ph10

._crit_edge11:                                    ; preds = %.lr.ph10, %33
  ret void

.lr.ph10:                                         ; preds = %33, %.lr.ph10
  %.08 = phi i64 [ %42, %.lr.ph10 ], [ 0, %33 ]
  %37 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN3Rcs17HardwareComponentESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.08) #3
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = load ptr, ptr %38, align 8, !tbaa !22
  %40 = getelementptr inbounds i8, ptr %39, i64 24
  %41 = load ptr, ptr %40, align 8
  tail call void %41(ptr noundef nonnull align 8 dereferenceable(25) %38)
  %42 = add nuw i64 %.08, 1
  %43 = tail call noundef i64 @_ZNKSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %.lr.ph10, label %._crit_edge11, !llvm.loop !28
}

declare zeroext i1 @RcsGraph_setState(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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 = { 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, !7, i64 8}
!6 = !{!"_ZTSN3Rcs18MotionControlLayerE", !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 48, !14, i64 56, !14, i64 57, !14, i64 58, !14, i64 59, !15, i64 60, !15, i64 64, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIPN3Rcs17HardwareComponentESaIS2_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIPN3Rcs17HardwareComponentESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIPN3Rcs17HardwareComponentESaIS2_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIPN3Rcs17HardwareComponentESaIS2_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!"bool", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!"double", !8, i64 0}
!17 = !{!6, !14, i64 58}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !7, i64 16}
!22 = !{!23, !23, i64 0}
!23 = !{!"vtable pointer", !9, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!27, !7, i64 1864}
!27 = !{!"_ZTS9_RcsGraph", !7, i64 0, !8, i64 8, !15, i64 1848, !15, i64 1852, !7, i64 1856, !7, i64 1864, !7, i64 1872, !7, i64 1880, !7, i64 1888}
!28 = distinct !{!28, !25}


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