; LLVM IR from simbody/simbody :: SimTKcommon/src/Xml.ll (ZN5SimTK3Xml13node_iteratormmEi)

; 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.SimTK::Xml::node_iterator" = type <{ %"class.SimTK::Xml::Node", i32, [4 x i8] }>
%"class.SimTK::Xml::Node" = type { ptr }

; 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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL17nodeTypeIsAllowedN5SimTK3Xml8NodeTypeENS_9TiXmlNode8NodeTypeE(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(104) ptr @_ZN5SimTK3Xml4Node9updTiNodeEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5SimTK3Xml13node_iteratorC2ERNS0_4NodeENS0_8NodeTypeE(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5SimTK9TiXmlNode15PreviousSiblingEv(ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5SimTK3Xml13node_iteratormmEi(ptr dead_on_unwind noalias writable sret(%"class.SimTK::Xml::node_iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(12) %1, i32 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.SimTK::Xml::Node", align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"class.SimTK::Xml::Node", align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = getelementptr inbounds %"class.SimTK::Xml::node_iterator", ptr %12, i32 0, i32 0
  call void @_ZN5SimTK3Xml4NodeC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %14 = getelementptr inbounds %"class.SimTK::Xml::node_iterator", ptr %12, i32 0, i32 0
  %15 = invoke noundef nonnull align 8 dereferenceable(104) ptr @_ZN5SimTK3Xml4Node9updTiNodeEv(ptr noundef nonnull align 8 dereferenceable(8) %14)
          to label %16 unwind label %37

16:                                               ; preds = %3
  %17 = invoke noundef ptr @_ZN5SimTK9TiXmlNode15PreviousSiblingEv(ptr noundef nonnull align 8 dereferenceable(104) %15)
          to label %18 unwind label %37

18:                                               ; preds = %16
  store ptr %17, ptr %8, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %36, %18
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %31

22:                                               ; preds = %19
  %23 = getelementptr inbounds %"class.SimTK::Xml::node_iterator", ptr %12, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = invoke noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104) %25)
          to label %27 unwind label %37

27:                                               ; preds = %22
  %28 = invoke noundef zeroext i1 @_ZL17nodeTypeIsAllowedN5SimTK3Xml8NodeTypeENS_9TiXmlNode8NodeTypeE(i32 noundef %24, i32 noundef %26)
          to label %29 unwind label %37

29:                                               ; preds = %27
  %30 = xor i1 %28, true
  br label %31

31:                                               ; preds = %29, %19
  %32 = phi i1 [ false, %19 ], [ %30, %29 ]
  br i1 %32, label %33, label %41

33:                                               ; preds = %31
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = invoke noundef ptr @_ZN5SimTK9TiXmlNode15PreviousSiblingEv(ptr noundef nonnull align 8 dereferenceable(104) %34)
          to label %36 unwind label %37

36:                                               ; preds = %33
  store ptr %35, ptr %8, align 8, !tbaa !5
  br label %19, !llvm.loop !15

37:                                               ; preds = %46, %33, %27, %22, %16, %3
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %9, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %10, align 4
  br label %57

41:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  invoke void @_ZN5SimTK3Xml4NodeC2EPNS_9TiXmlNodeE(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef %42)
          to label %43 unwind label %48

43:                                               ; preds = %41
  %44 = getelementptr inbounds %"class.SimTK::Xml::node_iterator", ptr %12, i32 0, i32 0
  %45 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN5SimTK3Xml4NodeaSERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %46 unwind label %52

46:                                               ; preds = %43
  call void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  invoke void @_ZN5SimTK3Xml13node_iteratorC2ERNS0_4NodeENS0_8NodeTypeE(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef 15)
          to label %47 unwind label %37

47:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void

48:                                               ; preds = %41
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %9, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %10, align 4
  br label %56

52:                                               ; preds = %43
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %9, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %10, align 4
  call void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #3
  br label %56

56:                                               ; preds = %52, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %57

57:                                               ; preds = %56, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %58

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

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !14, i64 8}
!12 = !{!"_ZTSN5SimTK3Xml13node_iteratorE", !13, i64 0, !14, i64 8}
!13 = !{!"_ZTSN5SimTK3Xml4NodeE", !6, i64 0}
!14 = !{!"_ZTSN5SimTK3Xml8NodeTypeE", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%"class.SimTK::Xml::node_iterator" = type <{ %"class.SimTK::Xml::Node", i32, [4 x i8] }>
%"class.SimTK::Xml::Node" = type { ptr }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL17nodeTypeIsAllowedN5SimTK3Xml8NodeTypeENS_9TiXmlNode8NodeTypeE(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(104) ptr @_ZN5SimTK3Xml4Node9updTiNodeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5SimTK3Xml13node_iteratorC2ERNS0_4NodeENS0_8NodeTypeE(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5SimTK9TiXmlNode15PreviousSiblingEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5SimTK3Xml13node_iteratormmEi(ptr dead_on_unwind noalias writable sret(%"class.SimTK::Xml::node_iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(12) %1, i32 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.SimTK::Xml::Node", align 8
  %5 = alloca %"class.SimTK::Xml::Node", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @_ZN5SimTK3Xml4NodeC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %6 = call noundef nonnull align 8 dereferenceable(104) ptr @_ZN5SimTK3Xml4Node9updTiNodeEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %7 = call noundef ptr @_ZN5SimTK9TiXmlNode15PreviousSiblingEv(ptr noundef nonnull align 8 dereferenceable(104) %6)
  %.not6 = icmp eq ptr %7, null
  br i1 %.not6, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  br label %9

9:                                                ; preds = %.lr.ph, %13
  %.07 = phi ptr [ %7, %.lr.ph ], [ %14, %13 ]
  %10 = load i32, ptr %8, align 8, !tbaa !5
  %11 = call noundef i32 @_ZNK5SimTK9TiXmlNode4TypeEv(ptr noundef nonnull align 8 dereferenceable(104) %.07)
  %12 = call noundef zeroext i1 @_ZL17nodeTypeIsAllowedN5SimTK3Xml8NodeTypeENS_9TiXmlNode8NodeTypeE(i32 noundef %10, i32 noundef %11)
  br i1 %12, label %.critedge, label %13

13:                                               ; preds = %9
  %14 = call noundef ptr @_ZN5SimTK9TiXmlNode15PreviousSiblingEv(ptr noundef nonnull align 8 dereferenceable(104) %.07)
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %.critedge, label %9, !llvm.loop !12

15:                                               ; preds = %.critedge
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  resume { ptr, i32 } %16

.critedge:                                        ; preds = %9, %13, %3
  %.0.lcssa = phi ptr [ null, %3 ], [ null, %13 ], [ %.07, %9 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @_ZN5SimTK3Xml4NodeC2EPNS_9TiXmlNodeE(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef %.0.lcssa)
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5SimTK3Xml4NodeaSERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  invoke void @_ZN5SimTK3Xml13node_iteratorC2ERNS0_4NodeENS0_8NodeTypeE(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef 15)
          to label %18 unwind label %15

18:                                               ; preds = %.critedge
  call void @_ZN5SimTK3Xml4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret void
}

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


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