; LLVM IR from ETH3D/dataset-pipeline :: thirdparty/tinyxml2/tinyxml2.ll (ZN8tinyxml27XMLText9ParseDeepEPcPNS_7StrPairE)

; 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.tinyxml2::XMLNode" = type { ptr, ptr, ptr, %"class.tinyxml2::StrPair", ptr, ptr, ptr, ptr, ptr }
%"class.tinyxml2::StrPair" = type { i32, ptr, ptr }

@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1

; 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 @_ZN8tinyxml27StrPair9ParseTextEPcPKci(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_(ptr noundef nonnull align 8 dereferenceable(640), i32 noundef, ptr noundef, ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8tinyxml27XMLText9ParseDeepEPcPNS_7StrPairE(ptr noundef nonnull align 8 dereferenceable(89) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %12, ptr %8, align 8, !tbaa !5
  %13 = call noundef zeroext i1 @_ZNK8tinyxml27XMLText5CDataEv(ptr noundef nonnull align 8 dereferenceable(89) %11)
  br i1 %13, label %14, label %26

14:                                               ; preds = %3
  %15 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %11, i32 0, i32 3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKci(ptr noundef nonnull align 8 dereferenceable(24) %15, ptr noundef %16, ptr noundef @.str.13, i32 noundef 2)
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %24, label %20

20:                                               ; preds = %14
  %21 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %11, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_(ptr noundef nonnull align 8 dereferenceable(640) %22, i32 noundef 11, ptr noundef %23, ptr noundef null)
  br label %24

24:                                               ; preds = %20, %14
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %25, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %65

26:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %27 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %11, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = call noundef zeroext i1 @_ZNK8tinyxml211XMLDocument15ProcessEntitiesEv(ptr noundef nonnull align 8 dereferenceable(640) %28)
  %30 = zext i1 %29 to i64
  %31 = select i1 %29, i32 3, i32 2
  store i32 %31, ptr %10, align 4, !tbaa !13
  %32 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %11, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(640) %33)
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %39

36:                                               ; preds = %26
  %37 = load i32, ptr %10, align 4, !tbaa !13
  %38 = or i32 %37, 4
  store i32 %38, ptr %10, align 4, !tbaa !13
  br label %39

39:                                               ; preds = %36, %26
  %40 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %11, i32 0, i32 3
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr %10, align 4, !tbaa !13
  %43 = call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKci(ptr noundef nonnull align 8 dereferenceable(24) %40, ptr noundef %41, ptr noundef @.str.12, i32 noundef %42)
  store ptr %43, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %53

46:                                               ; preds = %39
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load i8, ptr %47, align 1, !tbaa !14
  %49 = icmp ne i8 %48, 0
  br i1 %49, label %50, label %53

50:                                               ; preds = %46
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 -1
  store ptr %52, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %61

53:                                               ; preds = %46, %39
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %60, label %56

56:                                               ; preds = %53
  %57 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %11, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_(ptr noundef nonnull align 8 dereferenceable(640) %58, i32 noundef 10, ptr noundef %59, ptr noundef null)
  br label %60

60:                                               ; preds = %56, %53
  store i32 0, ptr %9, align 4
  br label %61

61:                                               ; preds = %60, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %62 = load i32, ptr %9, align 4
  switch i32 %62, label %65 [
    i32 0, label %63
  ]

63:                                               ; preds = %61
  br label %64

64:                                               ; preds = %63
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %65

65:                                               ; preds = %64, %61, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %66 = load ptr, ptr %4, align 8
  ret ptr %66
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8tinyxml27XMLText5CDataEv(ptr noundef nonnull align 8 dereferenceable(89)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8tinyxml211XMLDocument15ProcessEntitiesEv(ptr noundef nonnull align 8 dereferenceable(640)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(640)) #2 align 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 = { 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 }

!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 = !{!"_ZTSN8tinyxml27XMLNodeE", !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"_ZTSN8tinyxml27StrPairE", !12, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!7, !7, 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"

@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8tinyxml27XMLText9ParseDeepEPcPNS_7StrPairE(ptr noundef nonnull align 8 dereferenceable(89) %0, ptr noundef %1, ptr nocapture noundef readnone %2) unnamed_addr #0 align 2 {
  %4 = tail call noundef zeroext i1 @_ZNK8tinyxml27XMLText5CDataEv(ptr noundef nonnull align 8 dereferenceable(89) %0)
  br i1 %4, label %5, label %11

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = tail call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKci(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef %1, ptr noundef nonnull @.str.13, i32 noundef 2)
  %.not19 = icmp eq ptr %7, null
  br i1 %.not19, label %8, label %26

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  tail call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_(ptr noundef nonnull align 8 dereferenceable(640) %10, i32 noundef 11, ptr noundef %1, ptr noundef null)
  br label %26

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = tail call noundef zeroext i1 @_ZNK8tinyxml211XMLDocument15ProcessEntitiesEv(ptr noundef nonnull align 8 dereferenceable(640) %13)
  %15 = select i1 %14, i32 3, i32 2
  %16 = load ptr, ptr %12, align 8, !tbaa !5
  %17 = tail call noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(640) %16)
  %18 = icmp eq i32 %17, 1
  %19 = or disjoint i32 %15, 4
  %spec.select = select i1 %18, i32 %19, i32 %15
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = tail call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKci(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef %1, ptr noundef nonnull @.str.12, i32 noundef %spec.select)
  %.not = icmp eq ptr %21, null
  br i1 %.not, label %.critedge, label %22

22:                                               ; preds = %11
  %23 = load i8, ptr %21, align 1, !tbaa !12
  %.not18 = icmp eq i8 %23, 0
  %24 = getelementptr inbounds i8, ptr %21, i64 -1
  %spec.select23 = select i1 %.not18, ptr null, ptr %24
  br label %26

.critedge:                                        ; preds = %11
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  tail call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_(ptr noundef nonnull align 8 dereferenceable(640) %25, i32 noundef 10, ptr noundef %1, ptr noundef null)
  br label %26

26:                                               ; preds = %22, %.critedge, %5, %8
  %.1 = phi ptr [ null, %8 ], [ %7, %5 ], [ null, %.critedge ], [ %spec.select23, %22 ]
  ret ptr %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8tinyxml27XMLText5CDataEv(ptr noundef nonnull align 8 dereferenceable(89)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8tinyxml211XMLDocument15ProcessEntitiesEv(ptr noundef nonnull align 8 dereferenceable(640)) local_unnamed_addr #1 align 2

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

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

!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 = !{!"_ZTSN8tinyxml27XMLNodeE", !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN8tinyxml27StrPairE", !11, i64 0, !7, i64 8, !7, i64 16}
!11 = !{!"int", !8, i64 0}
!12 = !{!8, !8, i64 0}


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