; LLVM IR from merpheus-dev/LavaEngine :: vendor/tinyxml2/tinyxml2.ll (ZN8tinyxml210XMLPrinter11OpenElementEPKcb)

; 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::XMLPrinter" = type { %"class.tinyxml2::XMLVisitor", i8, %"class.tinyxml2::DynArray.7", i8, ptr, i32, i32, i8, i8, [64 x i8], [64 x i8], [6 x i8], %"class.tinyxml2::DynArray.8" }
%"class.tinyxml2::XMLVisitor" = type { ptr }
%"class.tinyxml2::DynArray.7" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::DynArray.8" = type <{ ptr, [20 x i8], i32, i32, [4 x i8] }>

@.str.19 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml210XMLPrinter4PutcEc(ptr noundef nonnull align 8 dereferenceable(312), i8 noundef signext) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8tinyxml210XMLPrinter5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8tinyxml210XMLPrinter11OpenElementEPKcb(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1, i1 noundef zeroext %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %7 = zext i1 %2 to i8
  store i8 %7, ptr %6, align 1, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  call void @_ZN8tinyxml210XMLPrinter23SealElementIfJustOpenedEv(ptr noundef nonnull align 8 dereferenceable(312) %8)
  %9 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN8tinyxml28DynArrayIPKcLi10EE4PushES2_(ptr noundef nonnull align 8 dereferenceable(96) %9, ptr noundef %10)
  %11 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 6
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %14, label %27

14:                                               ; preds = %3
  %15 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 3
  %16 = load i8, ptr %15, align 8, !tbaa !17, !range !18, !noundef !19
  %17 = trunc i8 %16 to i1
  br i1 %17, label %27, label %18

18:                                               ; preds = %14
  %19 = load i8, ptr %6, align 1, !tbaa !9, !range !18, !noundef !19
  %20 = trunc i8 %19 to i1
  br i1 %20, label %27, label %21

21:                                               ; preds = %18
  call void @_ZN8tinyxml210XMLPrinter4PutcEc(ptr noundef nonnull align 8 dereferenceable(312) %8, i8 noundef signext 10)
  %22 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 5
  %23 = load i32, ptr %22, align 8, !tbaa !20
  %24 = load ptr, ptr %8, align 8, !tbaa !21
  %25 = getelementptr inbounds ptr, ptr %24, i64 12
  %26 = load ptr, ptr %25, align 8
  call void %26(ptr noundef nonnull align 8 dereferenceable(312) %8, i32 noundef %23)
  br label %27

27:                                               ; preds = %21, %18, %14, %3
  call void @_ZN8tinyxml210XMLPrinter5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(312) %8, ptr noundef @.str.19)
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN8tinyxml210XMLPrinter5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(312) %8, ptr noundef %28)
  %29 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 1
  store i8 1, ptr %29, align 8, !tbaa !23
  %30 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 3
  store i8 0, ptr %30, align 8, !tbaa !17
  %31 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 5
  %32 = load i32, ptr %31, align 8, !tbaa !20
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %31, align 8, !tbaa !20
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml28DynArrayIPKcLi10EE4PushES2_(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef) #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" }
attributes #1 = { inlinehint 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, !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 = !{!12, !15, i64 132}
!12 = !{!"_ZTSN8tinyxml210XMLPrinterE", !13, i64 0, !10, i64 8, !14, i64 16, !10, i64 112, !6, i64 120, !15, i64 128, !15, i64 132, !10, i64 136, !10, i64 137, !7, i64 138, !7, i64 202, !16, i64 272}
!13 = !{!"_ZTSN8tinyxml210XMLVisitorE"}
!14 = !{!"_ZTSN8tinyxml28DynArrayIPKcLi10EEE", !6, i64 0, !7, i64 8, !15, i64 88, !15, i64 92}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN8tinyxml28DynArrayIcLi20EEE", !6, i64 0, !7, i64 8, !15, i64 28, !15, i64 32}
!17 = !{!12, !10, i64 112}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!12, !15, i64 128}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !8, i64 0}
!23 = !{!12, !10, i64 8}


; 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.19 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml210XMLPrinter4PutcEc(ptr noundef nonnull align 8 dereferenceable(312), i8 noundef signext) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8tinyxml210XMLPrinter5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8tinyxml210XMLPrinter11OpenElementEPKcb(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  tail call void @_ZN8tinyxml210XMLPrinter23SealElementIfJustOpenedEv(ptr noundef nonnull align 8 dereferenceable(312) %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZN8tinyxml28DynArrayIPKcLi10EE4PushES2_(ptr noundef nonnull align 8 dereferenceable(96) %4, ptr noundef %1)
  %5 = getelementptr inbounds i8, ptr %0, i64 132
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, -1
  %8 = getelementptr inbounds i8, ptr %0, i64 112
  %9 = load i8, ptr %8, align 8, !range !15
  %10 = trunc nuw i8 %9 to i1
  %brmerge = or i1 %10, %2
  %or.cond = select i1 %7, i1 true, i1 %brmerge
  br i1 %or.cond, label %17, label %11

11:                                               ; preds = %3
  tail call void @_ZN8tinyxml210XMLPrinter4PutcEc(ptr noundef nonnull align 8 dereferenceable(312) %0, i8 noundef signext 10)
  %12 = getelementptr inbounds i8, ptr %0, i64 128
  %13 = load i32, ptr %12, align 8, !tbaa !16
  %14 = load ptr, ptr %0, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %14, i64 96
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(312) %0, i32 noundef %13)
  br label %17

17:                                               ; preds = %11, %3
  tail call void @_ZN8tinyxml210XMLPrinter5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef nonnull @.str.19)
  tail call void @_ZN8tinyxml210XMLPrinter5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1)
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 1, ptr %18, align 8, !tbaa !19
  store i8 0, ptr %8, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %0, i64 128
  %20 = load i32, ptr %19, align 8, !tbaa !16
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %19, align 8, !tbaa !16
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml28DynArrayIPKcLi10EE4PushES2_(ptr noundef nonnull align 8 dereferenceable(96), 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" }
attributes #1 = { inlinehint 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, !13, i64 132}
!6 = !{!"_ZTSN8tinyxml210XMLPrinterE", !7, i64 0, !8, i64 8, !11, i64 16, !8, i64 112, !12, i64 120, !13, i64 128, !13, i64 132, !8, i64 136, !8, i64 137, !9, i64 138, !9, i64 202, !14, i64 272}
!7 = !{!"_ZTSN8tinyxml210XMLVisitorE"}
!8 = !{!"bool", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN8tinyxml28DynArrayIPKcLi10EEE", !12, i64 0, !9, i64 8, !13, i64 88, !13, i64 92}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTSN8tinyxml28DynArrayIcLi20EEE", !12, i64 0, !9, i64 8, !13, i64 28, !13, i64 32}
!15 = !{i8 0, i8 2}
!16 = !{!6, !13, i64 128}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !10, i64 0}
!19 = !{!6, !8, i64 8}
!20 = !{!6, !8, i64 112}


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