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

; 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.ImGuiStorage = type { %struct.ImVector.4 }
%struct.ImVector.4 = type { i32, i32, ptr }
%"struct.ImGuiStorage::ImGuiStoragePair" = type { i32, %union.anon.30 }
%union.anon.30 = type { ptr }

@.str.508 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.509 = external hidden unnamed_addr constant [27 x i8], align 1

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN12ImGuiStorage16ImGuiStoragePairEEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #1 align 2

declare void @_ZN5ImGui7TreePopEv() #2

declare noundef zeroext i1 @_ZN5ImGui8TreeNodeEPKcS1_z(ptr noundef, ptr noundef, ...) #2

declare void @_ZN5ImGui10BulletTextEPKcz(ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui16DebugNodeStorageEP12ImGuiStoragePKc(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.ImGuiStorage, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %struct.ImVector.4, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ImGuiStorage, ptr %13, i32 0, i32 0
  %15 = call noundef i32 @_ZNK8ImVectorIN12ImGuiStorage16ImGuiStoragePairEE13size_in_bytesEv(ptr noundef nonnull align 8 dereferenceable(16) %14)
  %16 = call noundef zeroext i1 (ptr, ptr, ...) @_ZN5ImGui8TreeNodeEPKcS1_z(ptr noundef %7, ptr noundef @.str.508, ptr noundef %8, i32 noundef %12, i32 noundef %15)
  br i1 %16, label %18, label %17

17:                                               ; preds = %2
  br label %42

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %19

19:                                               ; preds = %38, %18
  %20 = load i32, ptr %5, align 4, !tbaa !13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ImGuiStorage, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.ImVector.4, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = icmp slt i32 %20, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %41

27:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ImGuiStorage, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %5, align 4, !tbaa !13
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN12ImGuiStorage16ImGuiStoragePairEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %29, i32 noundef %30)
  store ptr %31, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.ImGuiStorage::ImGuiStoragePair", ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !14
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.ImGuiStorage::ImGuiStoragePair", ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !16
  call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef @.str.509, i32 noundef %34, i32 noundef %37)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %38

38:                                               ; preds = %27
  %39 = load i32, ptr %5, align 4, !tbaa !13
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %5, align 4, !tbaa !13
  br label %19, !llvm.loop !17

41:                                               ; preds = %26
  call void @_ZN5ImGui7TreePopEv()
  br label %42

42:                                               ; preds = %41, %17
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8ImVectorIN12ImGuiStorage16ImGuiStoragePairEE13size_in_bytesEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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, !12, i64 0}
!10 = !{!"_ZTS12ImGuiStorage", !11, i64 0}
!11 = !{!"_ZTS8ImVectorIN12ImGuiStorage16ImGuiStoragePairEE", !12, i64 0, !12, i64 4, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!15, !12, i64 0}
!15 = !{!"_ZTSN12ImGuiStorage16ImGuiStoragePairE", !12, i64 0, !7, i64 8}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

@.str.508 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.509 = external hidden unnamed_addr constant [27 x i8], align 1

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

declare void @_ZN5ImGui7TreePopEv() local_unnamed_addr #1

declare noundef zeroext i1 @_ZN5ImGui8TreeNodeEPKcS1_z(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare void @_ZN5ImGui10BulletTextEPKcz(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui16DebugNodeStorageEP12ImGuiStoragePKc(ptr noundef nonnull %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = tail call noundef i32 @_ZNK8ImVectorIN12ImGuiStorage16ImGuiStoragePairEE13size_in_bytesEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %5 = tail call noundef zeroext i1 (ptr, ptr, ...) @_ZN5ImGui8TreeNodeEPKcS1_z(ptr noundef %1, ptr noundef nonnull @.str.508, ptr noundef %1, i32 noundef %3, i32 noundef %4)
  br i1 %5, label %.preheader, label %15

.preheader:                                       ; preds = %2
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  tail call void @_ZN5ImGui7TreePopEv()
  br label %15

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.010 = phi i32 [ %12, %.lr.ph ], [ 0, %.preheader ]
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN12ImGuiStorage16ImGuiStoragePairEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %.010)
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !14
  tail call void (ptr, ...) @_ZN5ImGui10BulletTextEPKcz(ptr noundef nonnull @.str.509, i32 noundef %9, i32 noundef %11)
  %12 = add nuw nsw i32 %.010, 1
  %13 = load i32, ptr %0, align 8, !tbaa !5
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %.lr.ph, label %._crit_edge, !llvm.loop !15

15:                                               ; preds = %2, %._crit_edge
  ret void
}

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

attributes #0 = { 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 #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 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, !8, i64 0}
!6 = !{!"_ZTS12ImGuiStorage", !7, i64 0}
!7 = !{!"_ZTS8ImVectorIN12ImGuiStorage16ImGuiStoragePairEE", !8, i64 0, !8, i64 4, !11, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!13, !8, i64 0}
!13 = !{!"_ZTSN12ImGuiStorage16ImGuiStoragePairE", !8, i64 0, !9, i64 8}
!14 = !{!9, !9, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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