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

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

@.str.4 = external hidden unnamed_addr constant [125 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [46 x i8], align 1
@__PRETTY_FUNCTION__._Z32ImParseFormatSanitizeForPrintingPKcPcm = external hidden unnamed_addr constant [68 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z20ImParseFormatFindEndPKc(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z32ImParseFormatSanitizeForPrintingPKcPcm(ptr noundef %0, ptr noundef %1, i64 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call noundef ptr @_Z20ImParseFormatFindEndPKc(ptr noundef %9)
  store ptr %10, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = ptrtoint ptr %11 to i64
  %14 = ptrtoint ptr %12 to i64
  %15 = sub i64 %13, %14
  %16 = add nsw i64 %15, 1
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  br label %22

20:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.47, ptr noundef @.str.4, i32 noundef 3299, ptr noundef @__PRETTY_FUNCTION__._Z32ImParseFormatSanitizeForPrintingPKcPcm) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  br label %23

23:                                               ; preds = %46, %22
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = icmp ult ptr %24, %25
  br i1 %26, label %27, label %47

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i32 1
  store ptr %29, ptr %4, align 8, !tbaa !5
  %30 = load i8, ptr %28, align 1, !tbaa !11
  store i8 %30, ptr %8, align 1, !tbaa !11
  %31 = load i8, ptr %8, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = icmp ne i32 %32, 39
  br i1 %33, label %34, label %46

34:                                               ; preds = %27
  %35 = load i8, ptr %8, align 1, !tbaa !11
  %36 = sext i8 %35 to i32
  %37 = icmp ne i32 %36, 36
  br i1 %37, label %38, label %46

38:                                               ; preds = %34
  %39 = load i8, ptr %8, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp ne i32 %40, 95
  br i1 %41, label %42, label %46

42:                                               ; preds = %38
  %43 = load i8, ptr %8, align 1, !tbaa !11
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i32 1
  store ptr %45, ptr %5, align 8, !tbaa !5
  store i8 %43, ptr %44, align 1, !tbaa !11
  br label %46

46:                                               ; preds = %42, %38, %34, %27
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  br label %23, !llvm.loop !12

47:                                               ; preds = %23
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 0, ptr %48, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #3 = { nounwind }
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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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.4 = external hidden unnamed_addr constant [125 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [46 x i8], align 1
@__PRETTY_FUNCTION__._Z32ImParseFormatSanitizeForPrintingPKcPcm = external hidden unnamed_addr constant [68 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z20ImParseFormatFindEndPKc(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z32ImParseFormatSanitizeForPrintingPKcPcm(ptr noundef %0, ptr nocapture noundef writeonly %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = tail call noundef ptr @_Z20ImParseFormatFindEndPKc(ptr noundef %0)
  %5 = ptrtoint ptr %4 to i64
  %6 = ptrtoint ptr %0 to i64
  %reass.sub = sub i64 %5, %6
  %7 = add i64 %reass.sub, 1
  %8 = icmp ult i64 %7, %2
  br i1 %8, label %.preheader, label %18

.preheader:                                       ; preds = %3
  %9 = icmp ugt ptr %4, %0
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader
  %10 = sub i64 %5, %6
  %xtraiter = and i64 %10, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %15
  %.019.prol = phi ptr [ %11, %15 ], [ %0, %.lr.ph.preheader ]
  %.01718.prol = phi ptr [ %.1.prol, %15 ], [ %1, %.lr.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %15 ], [ 0, %.lr.ph.preheader ]
  %11 = getelementptr inbounds i8, ptr %.019.prol, i64 1
  %12 = load i8, ptr %.019.prol, align 1, !tbaa !5
  switch i8 %12, label %13 [
    i8 95, label %15
    i8 39, label %15
    i8 36, label %15
  ]

13:                                               ; preds = %.lr.ph.prol
  %14 = getelementptr inbounds i8, ptr %.01718.prol, i64 1
  store i8 %12, ptr %.01718.prol, align 1, !tbaa !5
  br label %15

15:                                               ; preds = %13, %.lr.ph.prol, %.lr.ph.prol, %.lr.ph.prol
  %.1.prol = phi ptr [ %14, %13 ], [ %.01718.prol, %.lr.ph.prol ], [ %.01718.prol, %.lr.ph.prol ], [ %.01718.prol, %.lr.ph.prol ]
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !8

.lr.ph.prol.loopexit:                             ; preds = %15, %.lr.ph.preheader
  %.1.lcssa.unr = phi ptr [ poison, %.lr.ph.preheader ], [ %.1.prol, %15 ]
  %.019.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %11, %15 ]
  %.01718.unr = phi ptr [ %1, %.lr.ph.preheader ], [ %.1.prol, %15 ]
  %16 = sub i64 %6, %5
  %17 = icmp ugt i64 %16, -4
  br i1 %17, label %._crit_edge, label %.lr.ph

18:                                               ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.47, ptr noundef nonnull @.str.4, i32 noundef 3299, ptr noundef nonnull @__PRETTY_FUNCTION__._Z32ImParseFormatSanitizeForPrintingPKcPcm) #2
  unreachable

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %35
  %.019 = phi ptr [ %31, %35 ], [ %.019.unr, %.lr.ph.prol.loopexit ]
  %.01718 = phi ptr [ %.1.3, %35 ], [ %.01718.unr, %.lr.ph.prol.loopexit ]
  %19 = getelementptr inbounds i8, ptr %.019, i64 1
  %20 = load i8, ptr %.019, align 1, !tbaa !5
  switch i8 %20, label %21 [
    i8 95, label %.lr.ph.1
    i8 39, label %.lr.ph.1
    i8 36, label %.lr.ph.1
  ]

21:                                               ; preds = %.lr.ph
  %22 = getelementptr inbounds i8, ptr %.01718, i64 1
  store i8 %20, ptr %.01718, align 1, !tbaa !5
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.lr.ph, %.lr.ph, %.lr.ph, %21
  %.1 = phi ptr [ %22, %21 ], [ %.01718, %.lr.ph ], [ %.01718, %.lr.ph ], [ %.01718, %.lr.ph ]
  %23 = getelementptr inbounds i8, ptr %.019, i64 2
  %24 = load i8, ptr %19, align 1, !tbaa !5
  switch i8 %24, label %25 [
    i8 95, label %.lr.ph.2
    i8 39, label %.lr.ph.2
    i8 36, label %.lr.ph.2
  ]

25:                                               ; preds = %.lr.ph.1
  %26 = getelementptr inbounds i8, ptr %.1, i64 1
  store i8 %24, ptr %.1, align 1, !tbaa !5
  br label %.lr.ph.2

.lr.ph.2:                                         ; preds = %25, %.lr.ph.1, %.lr.ph.1, %.lr.ph.1
  %.1.1 = phi ptr [ %26, %25 ], [ %.1, %.lr.ph.1 ], [ %.1, %.lr.ph.1 ], [ %.1, %.lr.ph.1 ]
  %27 = getelementptr inbounds i8, ptr %.019, i64 3
  %28 = load i8, ptr %23, align 1, !tbaa !5
  switch i8 %28, label %29 [
    i8 95, label %.lr.ph.3
    i8 39, label %.lr.ph.3
    i8 36, label %.lr.ph.3
  ]

29:                                               ; preds = %.lr.ph.2
  %30 = getelementptr inbounds i8, ptr %.1.1, i64 1
  store i8 %28, ptr %.1.1, align 1, !tbaa !5
  br label %.lr.ph.3

.lr.ph.3:                                         ; preds = %29, %.lr.ph.2, %.lr.ph.2, %.lr.ph.2
  %.1.2 = phi ptr [ %30, %29 ], [ %.1.1, %.lr.ph.2 ], [ %.1.1, %.lr.ph.2 ], [ %.1.1, %.lr.ph.2 ]
  %31 = getelementptr inbounds i8, ptr %.019, i64 4
  %32 = load i8, ptr %27, align 1, !tbaa !5
  switch i8 %32, label %33 [
    i8 95, label %35
    i8 39, label %35
    i8 36, label %35
  ]

33:                                               ; preds = %.lr.ph.3
  %34 = getelementptr inbounds i8, ptr %.1.2, i64 1
  store i8 %32, ptr %.1.2, align 1, !tbaa !5
  br label %35

35:                                               ; preds = %33, %.lr.ph.3, %.lr.ph.3, %.lr.ph.3
  %.1.3 = phi ptr [ %34, %33 ], [ %.1.2, %.lr.ph.3 ], [ %.1.2, %.lr.ph.3 ], [ %.1.2, %.lr.ph.3 ]
  %exitcond.not.3 = icmp eq ptr %31, %4
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %35, %.preheader
  %.017.lcssa = phi ptr [ %1, %.preheader ], [ %.1.lcssa.unr, %.lr.ph.prol.loopexit ], [ %.1.3, %35 ]
  store i8 0, ptr %.017.lcssa, align 1, !tbaa !5
  ret void
}

attributes #0 = { 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 #1 = { 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.unroll.disable"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass