; LLVM IR from facebookresearch/habitat-sim :: src/deps/tinyxml2/tinyxml2.ll (ZN8tinyxml27StrPair18CollapseWhitespaceEv)

; 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::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
define dso_local void @_ZN8tinyxml27StrPair18CollapseWhitespaceEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %"class.tinyxml2::StrPair", ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPcPi(ptr noundef %7, ptr noundef null)
  %9 = getelementptr inbounds %"class.tinyxml2::StrPair", ptr %5, i32 0, i32 1
  store ptr %8, ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.tinyxml2::StrPair", ptr %5, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = load i8, ptr %11, align 1, !tbaa !12
  %13 = icmp ne i8 %12, 0
  br i1 %13, label %14, label %49

14:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %15 = getelementptr inbounds %"class.tinyxml2::StrPair", ptr %5, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %16, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %17 = getelementptr inbounds %"class.tinyxml2::StrPair", ptr %5, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %4, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %39, %14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i8, ptr %20, align 1, !tbaa !12
  %22 = icmp ne i8 %21, 0
  br i1 %22, label %23, label %47

23:                                               ; preds = %19
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i8, ptr %24, align 1, !tbaa !12
  %26 = call noundef zeroext i1 @_ZN8tinyxml27XMLUtil12IsWhiteSpaceEc(i8 noundef signext %25)
  br i1 %26, label %27, label %39

27:                                               ; preds = %23
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPKcPi(ptr noundef %28, ptr noundef null)
  store ptr %29, ptr %3, align 8, !tbaa !5
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !12
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %27
  br label %47

35:                                               ; preds = %27
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  store i8 32, ptr %36, align 1, !tbaa !12
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i32 1
  store ptr %38, ptr %4, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %35, %23
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = load i8, ptr %40, align 1, !tbaa !12
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  store i8 %41, ptr %42, align 1, !tbaa !12
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i32 1
  store ptr %44, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i32 1
  store ptr %46, ptr %3, align 8, !tbaa !5
  br label %19, !llvm.loop !13

47:                                               ; preds = %34, %19
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  store i8 0, ptr %48, align 1, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  br label %49

49:                                               ; preds = %47, %1
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8tinyxml27XMLUtil12IsWhiteSpaceEc(i8 noundef signext) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPKcPi(ptr noundef, ptr noundef) #1 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 = { 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 = !{!"_ZTSN8tinyxml27StrPairE", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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 uwtable
define dso_local void @_ZN8tinyxml27StrPair18CollapseWhitespaceEv(ptr nocapture noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPcPi(ptr noundef %3, ptr noundef null)
  store ptr %4, ptr %2, align 8, !tbaa !5
  %5 = load i8, ptr %4, align 1, !tbaa !11
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %19, label %.preheader

.preheader:                                       ; preds = %1, %14
  %.017 = phi ptr [ %16, %14 ], [ %4, %1 ]
  %.01216 = phi ptr [ %17, %14 ], [ %4, %1 ]
  %6 = phi i8 [ %.pr, %14 ], [ %5, %1 ]
  %7 = tail call noundef zeroext i1 @_ZN8tinyxml27XMLUtil12IsWhiteSpaceEc(i8 noundef signext %6)
  br i1 %7, label %8, label %14

8:                                                ; preds = %.preheader
  %9 = tail call noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPKcPi(ptr noundef nonnull %.01216, ptr noundef null)
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = icmp eq i8 %10, 0
  br i1 %11, label %18, label %12

12:                                               ; preds = %8
  store i8 32, ptr %.017, align 1, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %.017, i64 1
  br label %14

14:                                               ; preds = %12, %.preheader
  %.113 = phi ptr [ %9, %12 ], [ %.01216, %.preheader ]
  %.1 = phi ptr [ %13, %12 ], [ %.017, %.preheader ]
  %15 = load i8, ptr %.113, align 1, !tbaa !11
  store i8 %15, ptr %.1, align 1, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %.1, i64 1
  %17 = getelementptr inbounds i8, ptr %.113, i64 1
  %.pr = load i8, ptr %17, align 1, !tbaa !11
  %.not15 = icmp eq i8 %.pr, 0
  br i1 %.not15, label %18, label %.preheader, !llvm.loop !12

18:                                               ; preds = %8, %14
  %.0.lcssa = phi ptr [ %.017, %8 ], [ %16, %14 ]
  store i8 0, ptr %.0.lcssa, align 1, !tbaa !11
  br label %19

19:                                               ; preds = %18, %1
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPcPi(ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8tinyxml27XMLUtil12IsWhiteSpaceEc(i8 noundef signext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8tinyxml27XMLUtil14SkipWhiteSpaceEPKcPi(ptr noundef, ptr noundef) local_unnamed_addr #0 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" }

!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, !10, i64 8}
!6 = !{!"_ZTSN8tinyxml27StrPairE", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!8, !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass