; LLVM IR from facebookresearch/habitat-sim :: src/deps/tinyxml2/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.17 = 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_8XMLErrorEiPKcz(ptr noundef nonnull align 8 dereferenceable(776), i32 noundef, i32 noundef, ptr 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 i32, align 4
  %11 = 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
  %12 = load ptr, ptr %6, align 8
  %13 = call noundef zeroext i1 @_ZNK8tinyxml27XMLText5CDataEv(ptr noundef nonnull align 8 dereferenceable(105) %12)
  br i1 %13, label %14, label %28

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

21:                                               ; preds = %14
  %22 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %12, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %12, i32 0, i32 4
  %25 = load i32, ptr %24, align 8, !tbaa !13
  call void (ptr, i32, i32, ptr, ...) @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEiPKcz(ptr noundef nonnull align 8 dereferenceable(776) %23, i32 noundef 11, i32 noundef %25, ptr noundef null)
  br label %26

26:                                               ; preds = %21, %14
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %27, ptr %5, align 8
  br label %69

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

38:                                               ; preds = %28
  %39 = load i32, ptr %10, align 4, !tbaa !14
  %40 = or i32 %39, 4
  store i32 %40, ptr %10, align 4, !tbaa !14
  br label %41

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

49:                                               ; preds = %41
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i8, ptr %50, align 1, !tbaa !15
  %52 = icmp ne i8 %51, 0
  br i1 %52, label %53, label %56

53:                                               ; preds = %49
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 -1
  store ptr %55, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %65

56:                                               ; preds = %49, %41
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %64, label %59

59:                                               ; preds = %56
  %60 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %12, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  %62 = getelementptr inbounds %"class.tinyxml2::XMLNode", ptr %12, i32 0, i32 4
  %63 = load i32, ptr %62, align 8, !tbaa !13
  call void (ptr, i32, i32, ptr, ...) @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEiPKcz(ptr noundef nonnull align 8 dereferenceable(776) %61, i32 noundef 10, i32 noundef %63, ptr noundef null)
  br label %64

64:                                               ; preds = %59, %56
  store i32 0, ptr %11, align 4
  br label %65

65:                                               ; preds = %64, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %66 = load i32, ptr %11, align 4
  switch i32 %66, label %71 [
    i32 0, label %67
    i32 1, label %69
  ]

67:                                               ; preds = %65
  br label %68

68:                                               ; preds = %67
  store ptr null, ptr %5, align 8
  br label %69

69:                                               ; preds = %68, %65, %26
  %70 = load ptr, ptr %5, align 8
  ret ptr %70

71:                                               ; preds = %65
  unreachable
}

; 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(776)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(776)) #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.17 = 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_8XMLErrorEiPKcz(ptr noundef nonnull align 8 dereferenceable(776), i32 noundef, i32 noundef, ptr 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.17, i32 noundef 2, ptr noundef %3)
  %.not18 = icmp eq ptr %8, null
  br i1 %.not18, 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 (ptr, i32, i32, ptr, ...) @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEiPKcz(ptr noundef nonnull align 8 dereferenceable(776) %11, i32 noundef 11, i32 noundef %13, ptr noundef null)
  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(776) %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(776) %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
  %.not17 = icmp eq i8 %26, 0
  %27 = getelementptr inbounds i8, ptr %24, i64 -1
  %spec.select23 = select i1 %.not17, 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 (ptr, i32, i32, ptr, ...) @_ZN8tinyxml211XMLDocument8SetErrorENS_8XMLErrorEiPKcz(ptr noundef nonnull align 8 dereferenceable(776) %28, i32 noundef 10, i32 noundef %30, ptr noundef null)
  br label %31

31:                                               ; preds = %25, %.critedge, %6, %9
  %.1 = phi ptr [ null, %9 ], [ %8, %6 ], [ null, %.critedge ], [ %spec.select23, %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(776)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8tinyxml211XMLDocument14WhitespaceModeEv(ptr noundef nonnull align 8 dereferenceable(776)) 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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass