; LLVM IR from ysyesilyurt/ComputerGraphics :: ForwardRenderingPipeline/tinyxml2.ll (ZN8tinyxml27XMLText9ParseDeepEPcPNS_7StrPairEPi)

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

@.str.14 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.15 = 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 @_ZN8tinyxml27StrPair9ParseTextEPcPKciPi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_i(ptr noundef nonnull align 8 dereferenceable(704), i32 noundef, ptr noundef, ptr noundef, i32 noundef) #1 align 2

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

16:                                               ; preds = %4
  %17 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKciPi(ptr noundef nonnull align 8 dereferenceable(24) %17, ptr noundef %18, ptr noundef @.str.15, i32 noundef 2, ptr noundef %19)
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %29, label %23

23:                                               ; preds = %16
  %24 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 4
  %28 = load i32, ptr %27, align 8, !tbaa !13
  call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_i(ptr noundef nonnull align 8 dereferenceable(704) %25, i32 noundef 11, ptr noundef %26, ptr noundef null, i32 noundef %28)
  br label %29

29:                                               ; preds = %23, %16
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %30, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %73

31:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %32 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call noundef zeroext i1 @_ZNK8tinyxml211XMLDocument15ProcessEntitiesEv(ptr noundef nonnull align 8 dereferenceable(704) %33)
  %35 = zext i1 %34 to i64
  %36 = select i1 %34, i32 3, i32 2
  store i32 %36, ptr %12, align 4, !tbaa !14
  %37 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = call noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(704) %38)
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %44

41:                                               ; preds = %31
  %42 = load i32, ptr %12, align 4, !tbaa !14
  %43 = or i32 %42, 4
  store i32 %43, ptr %12, align 4, !tbaa !14
  br label %44

44:                                               ; preds = %41, %31
  %45 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 3
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i32, ptr %12, align 4, !tbaa !14
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKciPi(ptr noundef nonnull align 8 dereferenceable(24) %45, ptr noundef %46, ptr noundef @.str.14, i32 noundef %47, ptr noundef %48)
  store ptr %49, ptr %7, align 8, !tbaa !5
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %59

52:                                               ; preds = %44
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load i8, ptr %53, align 1, !tbaa !15
  %55 = icmp ne i8 %54, 0
  br i1 %55, label %56, label %59

56:                                               ; preds = %52
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %57, i64 -1
  store ptr %58, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %69

59:                                               ; preds = %52, %44
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %68, label %62

62:                                               ; preds = %59
  %63 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %13, i32 0, i32 4
  %67 = load i32, ptr %66, align 8, !tbaa !13
  call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_i(ptr noundef nonnull align 8 dereferenceable(704) %64, i32 noundef 10, ptr noundef %65, ptr noundef null, i32 noundef %67)
  br label %68

68:                                               ; preds = %62, %59
  store i32 0, ptr %11, align 4
  br label %69

69:                                               ; preds = %68, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %70 = load i32, ptr %11, align 4
  switch i32 %70, label %73 [
    i32 0, label %71
  ]

71:                                               ; preds = %69
  br label %72

72:                                               ; preds = %71
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %73

73:                                               ; preds = %72, %69, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %74 = load ptr, ptr %5, align 8
  ret ptr %74
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(704)) #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, !12, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!11 = !{!"_ZTSN8tinyxml27StrPairE", !12, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 48}
!14 = !{!12, !12, i64 0}
!15 = !{!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.14 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = tail call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKciPi(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef %1, ptr noundef nonnull @.str.15, i32 noundef 2, ptr noundef %3)
  %.not21 = icmp eq ptr %8, null
  br i1 %.not21, label %9, label %31

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = load i32, ptr %12, align 8, !tbaa !12
  tail call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_i(ptr noundef nonnull align 8 dereferenceable(704) %11, i32 noundef 11, ptr noundef %1, ptr noundef null, i32 noundef %13)
  br label %31

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

25:                                               ; preds = %14
  %26 = load i8, ptr %24, align 1, !tbaa !13
  %.not20 = icmp eq i8 %26, 0
  %27 = getelementptr inbounds i8, ptr %24, i64 -1
  %spec.select25 = select i1 %.not20, ptr null, ptr %27
  br label %31

.critedge:                                        ; preds = %14
  %28 = load ptr, ptr %15, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 48
  %30 = load i32, ptr %29, align 8, !tbaa !12
  tail call void @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEPKcS3_i(ptr noundef nonnull align 8 dereferenceable(704) %28, i32 noundef 10, ptr noundef %1, ptr noundef null, i32 noundef %30)
  br label %31

31:                                               ; preds = %25, %.critedge, %6, %9
  %.1 = phi ptr [ null, %9 ], [ %8, %6 ], [ null, %.critedge ], [ %spec.select25, %25 ]
  ret ptr %.1
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(704)) 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, !11, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96}
!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 = !{!6, !11, i64 48}
!13 = !{!8, !8, i64 0}


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