; LLVM IR from lanl/Fierro :: single-node-refactor/src/input/Yaml.ll (ZN4Yaml13ConstIteratoraSERKS0_)

; 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.Yaml::ConstIterator" = type { i32, ptr }
%"class.Yaml::SequenceConstIteratorImp" = type { %"class.Yaml::IteratorImp", %"struct.std::_Rb_tree_const_iterator" }
%"class.Yaml::IteratorImp" = type { ptr }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.Yaml::MapConstIteratorImp" = type { %"class.Yaml::IteratorImp", %"struct.std::_Rb_tree_const_iterator.6" }
%"struct.std::_Rb_tree_const_iterator.6" = type { 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN4Yaml13ConstIteratoraSERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %35

10:                                               ; preds = %2
  %11 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !12
  switch i32 %12, label %31 [
    i32 1, label %13
    i32 2, label %22
  ]

13:                                               ; preds = %10
  %14 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp eq ptr %15, null
  br i1 %16, label %21, label %17

17:                                               ; preds = %13
  %18 = load ptr, ptr %15, align 8, !tbaa !13
  %19 = getelementptr inbounds ptr, ptr %18, i64 1
  %20 = load ptr, ptr %19, align 8
  call void %20(ptr noundef nonnull align 8 dereferenceable(16) %15) #5
  br label %21

21:                                               ; preds = %17, %13
  br label %32

22:                                               ; preds = %10
  %23 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = icmp eq ptr %24, null
  br i1 %25, label %30, label %26

26:                                               ; preds = %22
  %27 = load ptr, ptr %24, align 8, !tbaa !13
  %28 = getelementptr inbounds ptr, ptr %27, i64 1
  %29 = load ptr, ptr %28, align 8
  call void %29(ptr noundef nonnull align 8 dereferenceable(16) %24) #5
  br label %30

30:                                               ; preds = %26, %22
  br label %32

31:                                               ; preds = %10
  br label %32

32:                                               ; preds = %31, %30, %21
  %33 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 1
  store ptr null, ptr %33, align 8, !tbaa !9
  %34 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 0
  store i32 0, ptr %34, align 8, !tbaa !12
  br label %35

35:                                               ; preds = %32, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store ptr null, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !12
  switch i32 %38, label %57 [
    i32 1, label %39
    i32 2, label %48
  ]

39:                                               ; preds = %35
  %40 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 0
  store i32 1, ptr %40, align 8, !tbaa !12
  %41 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #6
  call void @_ZN4Yaml24SequenceConstIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %41) #5
  store ptr %41, ptr %5, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = getelementptr inbounds %"class.Yaml::SequenceConstIteratorImp", ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.Yaml::SequenceConstIteratorImp", ptr %46, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %47, ptr align 8 %45, i64 8, i1 false), !tbaa.struct !15
  br label %58

48:                                               ; preds = %35
  %49 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 0
  store i32 2, ptr %49, align 8, !tbaa !12
  %50 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #6
  call void @_ZN4Yaml19MapConstIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %50) #5
  store ptr %50, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %"class.Yaml::MapConstIteratorImp", ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.Yaml::MapConstIteratorImp", ptr %55, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %56, ptr align 8 %54, i64 8, i1 false), !tbaa.struct !15
  br label %58

57:                                               ; preds = %35
  br label %58

58:                                               ; preds = %57, %48, %39
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.Yaml::ConstIterator", ptr %6, i32 0, i32 1
  store ptr %59, ptr %60, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret ptr %6
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4Yaml24SequenceConstIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4Yaml19MapConstIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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, !6, i64 8}
!10 = !{!"_ZTSN4Yaml13ConstIteratorE", !11, i64 0, !6, i64 8}
!11 = !{!"_ZTSN4Yaml13ConstIterator5eTypeE", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{i64 0, i64 8, !5}


; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN4Yaml13ConstIteratoraSERKS0_(ptr noundef nonnull returned align 8 dereferenceable(16) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %11, label %5

5:                                                ; preds = %2
  %6 = load i32, ptr %0, align 8, !tbaa !11
  %.off = add i32 %6, -1
  %switch = icmp ult i32 %.off, 2
  br i1 %switch, label %.sink.split, label %10

.sink.split:                                      ; preds = %5
  %7 = load ptr, ptr %4, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load ptr, ptr %8, align 8
  tail call void %9(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  br label %10

10:                                               ; preds = %5, %.sink.split
  store ptr null, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %0, align 8, !tbaa !11
  br label %11

11:                                               ; preds = %10, %2
  %12 = load i32, ptr %1, align 8, !tbaa !11
  switch i32 %12, label %22 [
    i32 1, label %13
    i32 2, label %15
  ]

13:                                               ; preds = %11
  store i32 1, ptr %0, align 8, !tbaa !11
  %14 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znwm(i64 noundef 16) #4
  tail call void @_ZN4Yaml24SequenceConstIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #3
  br label %.sink.split9

15:                                               ; preds = %11
  store i32 2, ptr %0, align 8, !tbaa !11
  %16 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znwm(i64 noundef 16) #4
  tail call void @_ZN4Yaml19MapConstIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %16) #3
  br label %.sink.split9

.sink.split9:                                     ; preds = %13, %15
  %.sink = phi ptr [ %16, %15 ], [ %14, %13 ]
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = getelementptr inbounds i8, ptr %.sink, i64 8
  %21 = load i64, ptr %19, align 8, !tbaa !14
  store i64 %21, ptr %20, align 8, !tbaa !14
  br label %22

22:                                               ; preds = %.sink.split9, %11
  %.0 = phi ptr [ null, %11 ], [ %.sink, %.sink.split9 ]
  store ptr %.0, ptr %3, align 8, !tbaa !5
  ret ptr %0
}

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

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

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 = { 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 = { inlinehint 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 #3 = { nounwind }
attributes #4 = { builtin allocsize(0) }

!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, !10, i64 8}
!6 = !{!"_ZTSN4Yaml13ConstIteratorE", !7, i64 0, !10, i64 8}
!7 = !{!"_ZTSN4Yaml13ConstIterator5eTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"vtable pointer", !9, i64 0}
!14 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass