; LLVM IR from simbody/simbody :: SimTKcommon/src/tinyxmlparser.ll (ZN5SimTK12TiXmlComment8StreamInEPSiPNS_6StringE)

; 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"

; 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 noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264)) #1 align 2

declare noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16)) #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5SimTK6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5SimTK12TiXmlComment8StreamInEPSiPNS_6StringE(ptr noundef nonnull align 8 dereferenceable(104) %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 i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  br label %11

11:                                               ; preds = %61, %3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %12, i64 %15
  %17 = call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264) %16)
  br i1 %17, label %18, label %62

18:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16) %19)
  store i32 %20, ptr %7, align 4, !tbaa !11
  %21 = load i32, ptr %7, align 4, !tbaa !11
  %22 = icmp sle i32 %21, 0
  br i1 %22, label %23, label %30

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %24 = call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %10)
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN5SimTK13TiXmlDocument8SetErrorEiPKcPNS_16TiXmlParsingDataENS_13TiXmlEncodingE(ptr noundef nonnull align 8 dereferenceable(192) %28, i32 noundef 14, ptr noundef null, ptr noundef null, i32 noundef 0)
  br label %29

29:                                               ; preds = %27, %23
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %59

30:                                               ; preds = %18
  %31 = load i32, ptr %7, align 4, !tbaa !11
  %32 = trunc i32 %31 to i8
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %33, i8 noundef signext %32)
  %35 = load i32, ptr %7, align 4, !tbaa !11
  %36 = icmp eq i32 %35, 62
  br i1 %36, label %37, label %58

37:                                               ; preds = %30
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call noundef i32 @_ZNK5SimTK6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %39)
  %41 = sub nsw i32 %40, 2
  %42 = sext i32 %41 to i64
  %43 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32) %38, i64 noundef %42)
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = sext i8 %44 to i32
  %46 = icmp eq i32 %45, 45
  br i1 %46, label %47, label %58

47:                                               ; preds = %37
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call noundef i32 @_ZNK5SimTK6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %49)
  %51 = sub nsw i32 %50, 3
  %52 = sext i32 %51 to i64
  %53 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32) %48, i64 noundef %52)
  %54 = load i8, ptr %53, align 1, !tbaa !13
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, 45
  br i1 %56, label %57, label %58

57:                                               ; preds = %47
  store i32 1, ptr %9, align 4
  br label %59

58:                                               ; preds = %47, %37, %30
  store i32 0, ptr %9, align 4
  br label %59

59:                                               ; preds = %58, %57, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %60 = load i32, ptr %9, align 4
  switch i32 %60, label %63 [
    i32 0, label %61
    i32 1, label %62
  ]

61:                                               ; preds = %59
  br label %11, !llvm.loop !14

62:                                               ; preds = %59, %11
  ret void

63:                                               ; preds = %59
  unreachable
}

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 = { "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 = { 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 #4 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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
declare noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264)) local_unnamed_addr #0 align 2

declare noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5SimTK12TiXmlComment8StreamInEPSiPNS_6StringE(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #0 align 2 {
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr %1, i64 %6
  %8 = tail call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264) %7)
  br i1 %8, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %3, %32
  %9 = tail call noundef i32 @_ZNSi3getEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %10 = icmp slt i32 %9, 1
  br i1 %10, label %11, label %14

11:                                               ; preds = %.lr.ph
  %12 = tail call noundef ptr @_ZN5SimTK9TiXmlNode11GetDocumentEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %.thread, label %13

13:                                               ; preds = %11
  tail call void @_ZN5SimTK13TiXmlDocument8SetErrorEiPKcPNS_16TiXmlParsingDataENS_13TiXmlEncodingE(ptr noundef nonnull align 8 dereferenceable(192) %12, i32 noundef 14, ptr noundef null, ptr noundef null, i32 noundef 0)
  br label %.thread

14:                                               ; preds = %.lr.ph
  %15 = trunc i32 %9 to i8
  %16 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %2, i8 noundef signext %15)
  %17 = icmp eq i32 %9, 62
  br i1 %17, label %18, label %32

18:                                               ; preds = %14
  %19 = tail call noundef i32 @_ZNK5SimTK6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %20 = add nsw i32 %19, -2
  %21 = sext i32 %20 to i64
  %22 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32) %2, i64 noundef %21)
  %23 = load i8, ptr %22, align 1, !tbaa !8
  %24 = icmp eq i8 %23, 45
  br i1 %24, label %25, label %32

25:                                               ; preds = %18
  %26 = tail call noundef i32 @_ZNK5SimTK6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %27 = add nsw i32 %26, -3
  %28 = sext i32 %27 to i64
  %29 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE2atEm(ptr noundef nonnull align 8 dereferenceable(32) %2, i64 noundef %28)
  %30 = load i8, ptr %29, align 1, !tbaa !8
  %31 = icmp eq i8 %30, 45
  br i1 %31, label %.thread, label %32

32:                                               ; preds = %14, %18, %25
  %33 = load ptr, ptr %1, align 8, !tbaa !5
  %34 = getelementptr i8, ptr %33, i64 -24
  %35 = load i64, ptr %34, align 8
  %36 = getelementptr inbounds i8, ptr %1, i64 %35
  %37 = tail call noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv(ptr noundef nonnull align 8 dereferenceable(264) %36)
  br i1 %37, label %.lr.ph, label %.thread

.thread:                                          ; preds = %32, %25, %3, %11, %13
  ret void
}

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"omnipotent char", !7, i64 0}


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