; LLVM IR from ysyesilyurt/ComputerGraphics :: ForwardRenderingPipeline/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.6", i8, ptr, i32, i32, i8, i8, [64 x i8], [64 x i8], [6 x i8], %"class.tinyxml2::DynArray.7" }
%"class.tinyxml2::XMLVisitor" = type { ptr }
%"class.tinyxml2::DynArray.6" = type { ptr, [10 x ptr], i32, i32 }
%"class.tinyxml2::DynArray.7" = type <{ ptr, [20 x i8], i32, i32, [4 x i8] }>

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml210XMLPrinter5PrintEPKcz(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef, ...) #0 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 %22

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 %22, 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 %22, label %21

21:                                               ; preds = %18
  call void (ptr, ptr, ...) @_ZN8tinyxml210XMLPrinter5PrintEPKcz(ptr noundef nonnull align 8 dereferenceable(312) %8, ptr noundef @.str.47)
  br label %22

22:                                               ; preds = %21, %18, %14, %3
  %23 = load i8, ptr %6, align 1, !tbaa !9, !range !18, !noundef !19
  %24 = trunc i8 %23 to i1
  br i1 %24, label %31, label %25

25:                                               ; preds = %22
  %26 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 5
  %27 = load i32, ptr %26, align 8, !tbaa !20
  %28 = load ptr, ptr %8, align 8, !tbaa !21
  %29 = getelementptr inbounds ptr, ptr %28, i64 12
  %30 = load ptr, ptr %29, align 8
  call void %30(ptr noundef nonnull align 8 dereferenceable(312) %8, i32 noundef %27)
  br label %31

31:                                               ; preds = %25, %22
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, ptr, ...) @_ZN8tinyxml210XMLPrinter5PrintEPKcz(ptr noundef nonnull align 8 dereferenceable(312) %8, ptr noundef @.str.48, ptr noundef %32)
  %33 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 1
  store i8 1, ptr %33, align 8, !tbaa !23
  %34 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 3
  store i8 0, ptr %34, align 8, !tbaa !17
  %35 = getelementptr inbounds %"class.tinyxml2::XMLPrinter", ptr %8, i32 0, i32 5
  %36 = load i32, ptr %35, align 8, !tbaa !20
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, 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" }

!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.47 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8tinyxml210XMLPrinter5PrintEPKcz(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef, ...) local_unnamed_addr #0 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 %12, label %11

11:                                               ; preds = %3
  tail call void (ptr, ptr, ...) @_ZN8tinyxml210XMLPrinter5PrintEPKcz(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef nonnull @.str.47)
  br label %12

12:                                               ; preds = %11, %3
  br i1 %2, label %19, label %13

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

19:                                               ; preds = %13, %12
  tail call void (ptr, ptr, ...) @_ZN8tinyxml210XMLPrinter5PrintEPKcz(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef nonnull @.str.48, ptr noundef %1)
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 1, ptr %20, align 8, !tbaa !19
  store i8 0, ptr %8, align 8, !tbaa !20
  %21 = getelementptr inbounds i8, ptr %0, i64 128
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %21, 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" }

!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