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

; 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::XMLAttribute" = type { ptr, %"class.tinyxml2::StrPair", %"class.tinyxml2::StrPair", ptr, ptr }
%"class.tinyxml2::StrPair" = type { i32, ptr, 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: 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 uwtable
declare dso_local noundef ptr @_ZN8tinyxml27StrPair9ParseNameEPc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPc(ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8tinyxml212XMLAttribute9ParseDeepEPcb(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %1, i1 noundef zeroext %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca [2 x i8], align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  %9 = zext i1 %2 to i8
  store i8 %9, ptr %7, align 1, !tbaa !9
  %10 = load ptr, ptr %5, align 8
  %11 = getelementptr inbounds %"class.tinyxml2::XMLAttribute", ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = call noundef ptr @_ZN8tinyxml27StrPair9ParseNameEPc(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef %12)
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %20

16:                                               ; preds = %3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %21, label %20

20:                                               ; preds = %16, %3
  store ptr null, ptr %4, align 8
  br label %59

21:                                               ; preds = %16
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPc(ptr noundef %22)
  store ptr %23, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i8, ptr %24, align 1, !tbaa !11
  %26 = sext i8 %25 to i32
  %27 = icmp ne i32 %26, 61
  br i1 %27, label %28, label %29

28:                                               ; preds = %21
  store ptr null, ptr %4, align 8
  br label %59

29:                                               ; preds = %21
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i32 1
  store ptr %31, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPc(ptr noundef %32)
  store ptr %33, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !11
  %36 = sext i8 %35 to i32
  %37 = icmp ne i32 %36, 34
  br i1 %37, label %38, label %44

38:                                               ; preds = %29
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp ne i32 %41, 39
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  store ptr null, ptr %4, align 8
  br label %59

44:                                               ; preds = %38, %29
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #2
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i8, ptr %45, align 1, !tbaa !11
  store i8 %46, ptr %8, align 1, !tbaa !11
  %47 = getelementptr inbounds i8, ptr %8, i64 1
  store i8 0, ptr %47, align 1, !tbaa !11
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i32 1
  store ptr %49, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.tinyxml2::XMLAttribute", ptr %10, i32 0, i32 2
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds [2 x i8], ptr %8, i64 0, i64 0
  %53 = load i8, ptr %7, align 1, !tbaa !9, !range !12, !noundef !13
  %54 = trunc i8 %53 to i1
  %55 = zext i1 %54 to i64
  %56 = select i1 %54, i32 3, i32 2
  %57 = call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKci(ptr noundef nonnull align 8 dereferenceable(24) %50, ptr noundef %51, ptr noundef %52, i32 noundef %56)
  store ptr %57, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %58, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #2
  br label %59

59:                                               ; preds = %44, %43, %28, %20
  %60 = load ptr, ptr %4, align 8
  ret ptr %60
}

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 = { 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPc(ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8tinyxml212XMLAttribute9ParseDeepEPcb(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %1, i1 noundef zeroext %2) local_unnamed_addr #1 align 2 {
  %4 = alloca [2 x i8], align 1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = tail call noundef ptr @_ZN8tinyxml27StrPair9ParseNameEPc(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef %1)
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %22, label %7

7:                                                ; preds = %3
  %8 = load i8, ptr %6, align 1, !tbaa !5
  %.not17 = icmp eq i8 %8, 0
  br i1 %.not17, label %22, label %9

9:                                                ; preds = %7
  %10 = tail call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPc(ptr noundef nonnull %6)
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %.not18 = icmp eq i8 %11, 61
  br i1 %.not18, label %12, label %22

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %10, i64 1
  %14 = tail call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPc(ptr noundef nonnull %13)
  %15 = load i8, ptr %14, align 1, !tbaa !5
  switch i8 %15, label %22 [
    i8 34, label %16
    i8 39, label %16
  ]

16:                                               ; preds = %12, %12
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #2
  store i8 %15, ptr %4, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 0, ptr %17, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %14, i64 1
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = select i1 %2, i32 3, i32 2
  %21 = call noundef ptr @_ZN8tinyxml27StrPair9ParseTextEPcPKci(ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull %18, ptr noundef nonnull %4, i32 noundef %20)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #2
  br label %22

22:                                               ; preds = %12, %9, %3, %7, %16
  %.0 = phi ptr [ %21, %16 ], [ null, %7 ], [ null, %3 ], [ null, %9 ], [ null, %12 ]
  ret ptr %.0
}

attributes #0 = { mustprogress 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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