; LLVM IR from HiroIshida/tinyfk :: urdf_parser/tinyxml (tinyxmlparser)

; 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.TiXmlDocument = type <{ %class.TiXmlNode, i8, [3 x i8], i32, %"class.std::__cxx11::basic_string", i32, %struct.TiXmlCursor, i8, [3 x i8] }>
%class.TiXmlNode = type { %class.TiXmlBase, ptr, i32, ptr, ptr, %"class.std::__cxx11::basic_string", ptr, ptr }
%class.TiXmlBase = type { ptr, %struct.TiXmlCursor, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%struct.TiXmlCursor = type { i32, i32 }

@.str.6 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [42 x i8], align 1
@__PRETTY_FUNCTION__._ZN13TiXmlDocument8SetErrorEiPKcP16TiXmlParsingData13TiXmlEncoding = external hidden unnamed_addr constant [83 x i8], align 1
@_ZN9TiXmlBase11errorStringE = external global [16 x ptr], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN16TiXmlParsingData5StampEPKc13TiXmlEncoding(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef, i32 noundef) #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13TiXmlDocument8SetErrorEiPKcP16TiXmlParsingData13TiXmlEncoding(ptr noundef nonnull align 8 dereferenceable(157) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !11
  %11 = load ptr, ptr %6, align 8
  %12 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 1
  %13 = load i8, ptr %12, align 8, !tbaa !13, !range !23, !noundef !24
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %16

15:                                               ; preds = %5
  br label %51

16:                                               ; preds = %5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 16
  br label %22

22:                                               ; preds = %19, %16
  %23 = phi i1 [ false, %16 ], [ %21, %19 ]
  br i1 %23, label %24, label %25

24:                                               ; preds = %22
  br label %27

25:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.6, i32 noundef 804, ptr noundef @__PRETTY_FUNCTION__._ZN13TiXmlDocument8SetErrorEiPKcP16TiXmlParsingData13TiXmlEncoding) #4
  unreachable

26:                                               ; No predecessors!
  br label %27

27:                                               ; preds = %26, %24
  %28 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 1
  store i8 1, ptr %28, align 8, !tbaa !13
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 3
  store i32 %29, ptr %30, align 4, !tbaa !25
  %31 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 3
  %32 = load i32, ptr %31, align 4, !tbaa !25
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [16 x ptr], ptr @_ZN9TiXmlBase11errorStringE, i64 0, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 4
  %37 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %36, ptr noundef %35)
  %38 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 6
  call void @_ZN11TiXmlCursor5ClearEv(ptr noundef nonnull align 4 dereferenceable(8) %38)
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %51

41:                                               ; preds = %27
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %51

44:                                               ; preds = %41
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !11
  call void @_ZN16TiXmlParsingData5StampEPKc13TiXmlEncoding(ptr noundef nonnull align 8 dereferenceable(20) %45, ptr noundef %46, i32 noundef %47)
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK16TiXmlParsingData6CursorEv(ptr noundef nonnull align 8 dereferenceable(20) %48)
  %50 = getelementptr inbounds %class.TiXmlDocument, ptr %11, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %50, ptr align 4 %49, i64 8, i1 false), !tbaa.struct !26
  br label %51

51:                                               ; preds = %44, %41, %27, %15
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11TiXmlCursor5ClearEv(ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK16TiXmlParsingData6CursorEv(ptr noundef nonnull align 8 dereferenceable(20)) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { 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 #1 = { noreturn nounwind "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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { noreturn 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS13TiXmlEncoding", !7, i64 0}
!13 = !{!14, !22, i64 104}
!14 = !{!"_ZTS13TiXmlDocument", !15, i64 0, !22, i64 104, !10, i64 108, !19, i64 112, !10, i64 144, !17, i64 148, !22, i64 156}
!15 = !{!"_ZTS9TiXmlNode", !16, i64 0, !6, i64 24, !18, i64 32, !6, i64 40, !6, i64 48, !19, i64 56, !6, i64 88, !6, i64 96}
!16 = !{!"_ZTS9TiXmlBase", !17, i64 8, !6, i64 16}
!17 = !{!"_ZTS11TiXmlCursor", !10, i64 0, !10, i64 4}
!18 = !{!"_ZTSN9TiXmlNode8NodeTypeE", !7, i64 0}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !21, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!14, !10, i64 108}
!26 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}


; 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.6 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [42 x i8], align 1
@__PRETTY_FUNCTION__._ZN13TiXmlDocument8SetErrorEiPKcP16TiXmlParsingData13TiXmlEncoding = external hidden unnamed_addr constant [83 x i8], align 1
@_ZN9TiXmlBase11errorStringE = external local_unnamed_addr global [16 x ptr], align 16

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13TiXmlDocument8SetErrorEiPKcP16TiXmlParsingData13TiXmlEncoding(ptr noundef nonnull align 8 dereferenceable(157) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #2 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 104
  %7 = load i8, ptr %6, align 8, !tbaa !5, !range !19, !noundef !20
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %26, label %9

9:                                                ; preds = %5
  %10 = add i32 %1, -1
  %11 = icmp ult i32 %10, 15
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.6, i32 noundef 804, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN13TiXmlDocument8SetErrorEiPKcP16TiXmlParsingData13TiXmlEncoding) #3
  unreachable

13:                                               ; preds = %9
  store i8 1, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 108
  store i32 %1, ptr %14, align 4, !tbaa !21
  %15 = zext nneg i32 %1 to i64
  %16 = getelementptr inbounds [16 x ptr], ptr @_ZN9TiXmlBase11errorStringE, i64 0, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !22
  %18 = getelementptr inbounds i8, ptr %0, i64 112
  %19 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc(ptr noundef nonnull align 8 dereferenceable(32) %18, ptr noundef %17)
  %20 = getelementptr inbounds i8, ptr %0, i64 148
  tail call void @_ZN11TiXmlCursor5ClearEv(ptr noundef nonnull align 4 dereferenceable(8) %20)
  %21 = icmp ne ptr %2, null
  %22 = icmp ne ptr %3, null
  %or.cond = and i1 %21, %22
  br i1 %or.cond, label %23, label %26

23:                                               ; preds = %13
  tail call void @_ZN16TiXmlParsingData5StampEPKc13TiXmlEncoding(ptr noundef nonnull align 8 dereferenceable(20) %3, ptr noundef nonnull %2, i32 noundef %4)
  %24 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK16TiXmlParsingData6CursorEv(ptr noundef nonnull align 8 dereferenceable(20) %3)
  %25 = load i64, ptr %24, align 4
  store i64 %25, ptr %20, align 4
  br label %26

26:                                               ; preds = %5, %23, %13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11TiXmlCursor5ClearEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK16TiXmlParsingData6CursorEv(ptr noundef nonnull align 8 dereferenceable(20)) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { noreturn nounwind "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 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 = { noreturn 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, !18, i64 104}
!6 = !{!"_ZTS13TiXmlDocument", !7, i64 0, !18, i64 104, !10, i64 108, !15, i64 112, !10, i64 144, !9, i64 148, !18, i64 156}
!7 = !{!"_ZTS9TiXmlNode", !8, i64 0, !13, i64 24, !14, i64 32, !13, i64 40, !13, i64 48, !15, i64 56, !13, i64 88, !13, i64 96}
!8 = !{!"_ZTS9TiXmlBase", !9, i64 8, !13, i64 16}
!9 = !{!"_ZTS11TiXmlCursor", !10, i64 0, !10, i64 4}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"any pointer", !11, i64 0}
!14 = !{!"_ZTSN9TiXmlNode8NodeTypeE", !11, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !11, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!17 = !{!"long", !11, i64 0}
!18 = !{!"bool", !11, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!6, !10, i64 108}
!22 = !{!13, !13, i64 0}


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