; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui (imgui_draw)

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

%struct.ImDrawListSplitter = type { i32, i32, %struct.ImVector.5 }
%struct.ImVector.5 = type { i32, i32, ptr }
%struct.ImDrawChannel = type { %struct.ImVector.0, %struct.ImVector.1 }
%struct.ImVector.0 = type { i32, i32, ptr }
%struct.ImVector.1 = type { i32, i32, 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorI9ImDrawCmdE5clearEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorItE5clearEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18ImDrawListSplitter15ClearFreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %30, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 2
  %8 = getelementptr inbounds %struct.ImVector.5, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp slt i32 %6, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %33

12:                                               ; preds = %5
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %16 = icmp eq i32 %13, %15
  br i1 %16, label %17, label %21

17:                                               ; preds = %12
  %18 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 2
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16) %18, i32 noundef %19)
  call void @llvm.memset.p0.i64(ptr align 8 %20, i8 0, i64 32, i1 false)
  br label %21

21:                                               ; preds = %17, %12
  %22 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 2
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16) %22, i32 noundef %23)
  %25 = getelementptr inbounds %struct.ImDrawChannel, ptr %24, i32 0, i32 0
  call void @_ZN8ImVectorI9ImDrawCmdE5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %25)
  %26 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 2
  %27 = load i32, ptr %3, align 4, !tbaa !9
  %28 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16) %26, i32 noundef %27)
  %29 = getelementptr inbounds %struct.ImDrawChannel, ptr %28, i32 0, i32 1
  call void @_ZN8ImVectorItE5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %29)
  br label %30

30:                                               ; preds = %21
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !15

33:                                               ; preds = %11
  %34 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 0
  store i32 0, ptr %34, align 8, !tbaa !14
  %35 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 1
  store i32 1, ptr %35, align 4, !tbaa !17
  %36 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %4, i32 0, i32 2
  call void @_ZN8ImVectorI13ImDrawChannelE5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %36)
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorI13ImDrawChannelE5clearEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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" }
attributes #3 = { 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 #4 = { inlinehint 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 #5 = { 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, !10, i64 8}
!12 = !{!"_ZTS18ImDrawListSplitter", !10, i64 0, !10, i64 4, !13, i64 8}
!13 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !10, i64 0, !10, i64 4, !6, i64 8}
!14 = !{!12, !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 4}


; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18ImDrawListSplitter15ClearFreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %10, %1
  store i32 0, ptr %0, align 8, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 1, ptr %5, align 4, !tbaa !13
  tail call void @_ZN8ImVectorI13ImDrawChannelE5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
  ret void

.lr.ph:                                           ; preds = %1, %10
  %.06 = phi i32 [ %14, %10 ], [ 0, %1 ]
  %6 = load i32, ptr %0, align 8, !tbaa !12
  %7 = icmp eq i32 %.06, %6
  br i1 %7, label %8, label %10

8:                                                ; preds = %.lr.ph
  %9 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.06)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %9, i8 0, i64 32, i1 false)
  br label %10

10:                                               ; preds = %8, %.lr.ph
  %11 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.06)
  tail call void @_ZN8ImVectorI9ImDrawCmdE5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %12 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.06)
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  tail call void @_ZN8ImVectorItE5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  %14 = add nuw nsw i32 %.06, 1
  %15 = load i32, ptr %2, align 8, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !14
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN8ImVectorI13ImDrawChannelEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #3 align 2

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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" }
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 = { inlinehint 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, !7, i64 8}
!6 = !{!"_ZTS18ImDrawListSplitter", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !7, i64 0, !7, i64 4, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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