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

; 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::Iterator" = type { i32, ptr }
%"class.Yaml::Node" = type { ptr }
%"class.Yaml::NodeImp" = type { i32, 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Yaml4Node3EndEv(ptr dead_on_unwind noalias writable sret(%"class.Yaml::Iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZN4Yaml8IteratorC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %10 = getelementptr inbounds %"class.Yaml::Node", ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %"class.Yaml::NodeImp", ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %54

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.Yaml::Node", ptr %9, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = getelementptr inbounds %"class.Yaml::NodeImp", ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !14
  switch i32 %19, label %50 [
    i32 1, label %20
    i32 2, label %37
  ]

20:                                               ; preds = %15
  %21 = getelementptr inbounds %"class.Yaml::Iterator", ptr %0, i32 0, i32 0
  store i32 1, ptr %21, align 8, !tbaa !15
  %22 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #5
          to label %23 unwind label %33

23:                                               ; preds = %20
  call void @_ZN4Yaml19SequenceIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %22) #4
  store ptr %22, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"class.Yaml::Node", ptr %9, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds %"class.Yaml::NodeImp", ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %24, align 8, !tbaa !18
  %30 = getelementptr inbounds ptr, ptr %29, i64 4
  %31 = load ptr, ptr %30, align 8
  invoke void %31(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef %28)
          to label %32 unwind label %33

32:                                               ; preds = %23
  br label %51

33:                                               ; preds = %40, %37, %23, %20
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %7, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @_ZN4Yaml8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %58

37:                                               ; preds = %15
  %38 = getelementptr inbounds %"class.Yaml::Iterator", ptr %0, i32 0, i32 0
  store i32 2, ptr %38, align 8, !tbaa !15
  %39 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #5
          to label %40 unwind label %33

40:                                               ; preds = %37
  call void @_ZN4Yaml14MapIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %39) #4
  store ptr %39, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.Yaml::Node", ptr %9, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %"class.Yaml::NodeImp", ptr %43, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = load ptr, ptr %41, align 8, !tbaa !18
  %47 = getelementptr inbounds ptr, ptr %46, i64 6
  %48 = load ptr, ptr %47, align 8
  invoke void %48(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef %45)
          to label %49 unwind label %33

49:                                               ; preds = %40
  br label %51

50:                                               ; preds = %15
  br label %51

51:                                               ; preds = %50, %49, %32
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %"class.Yaml::Iterator", ptr %0, i32 0, i32 1
  store ptr %52, ptr %53, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %54

54:                                               ; preds = %51, %2
  store i1 true, ptr %5, align 1
  %55 = load i1, ptr %5, align 1
  br i1 %55, label %57, label %56

56:                                               ; preds = %54
  call void @_ZN4Yaml8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %57

57:                                               ; preds = %56, %54
  ret void

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

declare void @_ZN4Yaml8IteratorC1Ev(ptr)

declare void @_ZN4Yaml8IteratorD1Ev(ptr)

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 = { 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 = { 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 = { nounwind }
attributes #5 = { 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 0}
!10 = !{!"_ZTSN4Yaml4NodeE", !6, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN4Yaml7NodeImpE", !13, i64 0, !6, i64 8}
!13 = !{!"_ZTSN4Yaml4Node5eTypeE", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTSN4Yaml8IteratorE", !17, i64 0, !6, i64 8}
!17 = !{!"_ZTSN4Yaml8Iterator5eTypeE", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!16, !6, i64 8}


; 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.Yaml::Iterator" = type { i32, ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Yaml4Node3EndEv(ptr dead_on_unwind noalias writable sret(%"class.Yaml::Iterator") align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN4Yaml8IteratorC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !10
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %30, label %6

6:                                                ; preds = %2
  %7 = load i32, ptr %3, align 8, !tbaa !13
  switch i32 %7, label %28 [
    i32 1, label %8
    i32 2, label %19
  ]

8:                                                ; preds = %6
  store i32 1, ptr %0, align 8, !tbaa !14
  %9 = invoke noalias noundef nonnull dereferenceable(16) ptr @_Znwm(i64 noundef 16) #3
          to label %10 unwind label %17

10:                                               ; preds = %8
  tail call void @_ZN4Yaml19SequenceIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !10
  %14 = load ptr, ptr %9, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %14, i64 32
  %16 = load ptr, ptr %15, align 8
  invoke void %16(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef %13)
          to label %28 unwind label %17

17:                                               ; preds = %21, %19, %10, %8
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN4Yaml8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  resume { ptr, i32 } %18

19:                                               ; preds = %6
  store i32 2, ptr %0, align 8, !tbaa !14
  %20 = invoke noalias noundef nonnull dereferenceable(16) ptr @_Znwm(i64 noundef 16) #3
          to label %21 unwind label %17

21:                                               ; preds = %19
  tail call void @_ZN4Yaml14MapIteratorImpC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %20) #4
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !10
  %25 = load ptr, ptr %20, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %25, i64 48
  %27 = load ptr, ptr %26, align 8
  invoke void %27(ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef %24)
          to label %28 unwind label %17

28:                                               ; preds = %6, %21, %10
  %.0 = phi ptr [ null, %6 ], [ %20, %21 ], [ %9, %10 ]
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %.0, ptr %29, align 8, !tbaa !19
  br label %30

30:                                               ; preds = %2, %28
  ret void
}

declare void @_ZN4Yaml8IteratorC1Ev(ptr) local_unnamed_addr

declare void @_ZN4Yaml8IteratorD1Ev(ptr) 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 = { 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 #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 = { builtin allocsize(0) }
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, !7, i64 0}
!6 = !{!"_ZTSN4Yaml4NodeE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 8}
!11 = !{!"_ZTSN4Yaml7NodeImpE", !12, i64 0, !7, i64 8}
!12 = !{!"_ZTSN4Yaml4Node5eTypeE", !8, i64 0}
!13 = !{!11, !12, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTSN4Yaml8IteratorE", !16, i64 0, !7, i64 8}
!16 = !{!"_ZTSN4Yaml8Iterator5eTypeE", !8, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !9, i64 0}
!19 = !{!15, !7, i64 8}


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