; 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__._Z32ImParseFormatSanitizeForScanningPKcPcm = external hidden unnamed_addr constant [75 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
define dso_local noundef ptr @_Z32ImParseFormatSanitizeForScanningPKcPcm(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 ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  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
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call noundef ptr @_Z20ImParseFormatFindEndPKc(ptr noundef %12)
  store ptr %13, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %14, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = ptrtoint ptr %15 to i64
  %18 = ptrtoint ptr %16 to i64
  %19 = sub i64 %17, %18
  %20 = add nsw i64 %19, 1
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = icmp ult i64 %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %3
  br label %26

24:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.47, ptr noundef @.str.4, i32 noundef 3315, ptr noundef @__PRETTY_FUNCTION__._Z32ImParseFormatSanitizeForScanningPKcPcm) #4
  unreachable

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25, %23
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  store i8 0, ptr %9, align 1, !tbaa !11
  br label %27

27:                                               ; preds = %103, %101, %26
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = icmp ult ptr %28, %29
  br i1 %30, label %31, label %104

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i32 1
  store ptr %33, ptr %4, align 8, !tbaa !5
  %34 = load i8, ptr %32, align 1, !tbaa !13
  store i8 %34, ptr %10, align 1, !tbaa !13
  %35 = load i8, ptr %9, align 1, !tbaa !11, !range !14, !noundef !15
  %36 = trunc i8 %35 to i1
  br i1 %36, label %58, label %37

37:                                               ; preds = %31
  %38 = load i8, ptr %10, align 1, !tbaa !13
  %39 = sext i8 %38 to i32
  %40 = icmp sge i32 %39, 48
  br i1 %40, label %41, label %45

41:                                               ; preds = %37
  %42 = load i8, ptr %10, align 1, !tbaa !13
  %43 = sext i8 %42 to i32
  %44 = icmp sle i32 %43, 57
  br i1 %44, label %57, label %45

45:                                               ; preds = %41, %37
  %46 = load i8, ptr %10, align 1, !tbaa !13
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 46
  br i1 %48, label %57, label %49

49:                                               ; preds = %45
  %50 = load i8, ptr %10, align 1, !tbaa !13
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 %51, 43
  br i1 %52, label %57, label %53

53:                                               ; preds = %49
  %54 = load i8, ptr %10, align 1, !tbaa !13
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, 35
  br i1 %56, label %57, label %58

57:                                               ; preds = %53, %49, %45, %41
  store i32 2, ptr %11, align 4
  br label %101, !llvm.loop !16

58:                                               ; preds = %53, %31
  %59 = load i8, ptr %10, align 1, !tbaa !13
  %60 = sext i8 %59 to i32
  %61 = icmp sge i32 %60, 97
  br i1 %61, label %62, label %66

62:                                               ; preds = %58
  %63 = load i8, ptr %10, align 1, !tbaa !13
  %64 = sext i8 %63 to i32
  %65 = icmp sle i32 %64, 122
  br i1 %65, label %76, label %66

66:                                               ; preds = %62, %58
  %67 = load i8, ptr %10, align 1, !tbaa !13
  %68 = sext i8 %67 to i32
  %69 = icmp sge i32 %68, 65
  br i1 %69, label %70, label %74

70:                                               ; preds = %66
  %71 = load i8, ptr %10, align 1, !tbaa !13
  %72 = sext i8 %71 to i32
  %73 = icmp sle i32 %72, 90
  br label %74

74:                                               ; preds = %70, %66
  %75 = phi i1 [ false, %66 ], [ %73, %70 ]
  br label %76

76:                                               ; preds = %74, %62
  %77 = phi i1 [ true, %62 ], [ %75, %74 ]
  %78 = zext i1 %77 to i32
  %79 = load i8, ptr %9, align 1, !tbaa !11, !range !14, !noundef !15
  %80 = trunc i8 %79 to i1
  %81 = zext i1 %80 to i32
  %82 = or i32 %81, %78
  %83 = icmp ne i32 %82, 0
  %84 = zext i1 %83 to i8
  store i8 %84, ptr %9, align 1, !tbaa !11
  %85 = load i8, ptr %10, align 1, !tbaa !13
  %86 = sext i8 %85 to i32
  %87 = icmp ne i32 %86, 39
  br i1 %87, label %88, label %100

88:                                               ; preds = %76
  %89 = load i8, ptr %10, align 1, !tbaa !13
  %90 = sext i8 %89 to i32
  %91 = icmp ne i32 %90, 36
  br i1 %91, label %92, label %100

92:                                               ; preds = %88
  %93 = load i8, ptr %10, align 1, !tbaa !13
  %94 = sext i8 %93 to i32
  %95 = icmp ne i32 %94, 95
  br i1 %95, label %96, label %100

96:                                               ; preds = %92
  %97 = load i8, ptr %10, align 1, !tbaa !13
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %98, i32 1
  store ptr %99, ptr %5, align 8, !tbaa !5
  store i8 %97, ptr %98, align 1, !tbaa !13
  br label %100

100:                                              ; preds = %96, %92, %88, %76
  store i32 0, ptr %11, align 4
  br label %101

101:                                              ; preds = %100, %57
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  %102 = load i32, ptr %11, align 4
  switch i32 %102, label %107 [
    i32 0, label %103
    i32 2, label %27
  ]

103:                                              ; preds = %101
  br label %27, !llvm.loop !16

104:                                              ; preds = %27
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 0, ptr %105, align 1, !tbaa !13
  %106 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret ptr %106

107:                                              ; preds = %101
  unreachable
}

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

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 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"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__._Z32ImParseFormatSanitizeForScanningPKcPcm = external hidden unnamed_addr constant [75 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
define dso_local noundef ptr @_Z32ImParseFormatSanitizeForScanningPKcPcm(ptr noundef %0, ptr noundef returned 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 %13

.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, 1
  %11 = add i64 %5, -1
  %12 = icmp eq i64 %11, %6
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %10, -2
  br label %.lr.ph

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

.lr.ph:                                           ; preds = %36, %.lr.ph.preheader.new
  %.051 = phi ptr [ %0, %.lr.ph.preheader.new ], [ %25, %36 ]
  %.04550 = phi i1 [ false, %.lr.ph.preheader.new ], [ %.1.1, %36 ]
  %.04649 = phi ptr [ %1, %.lr.ph.preheader.new ], [ %.2.1, %36 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %36 ]
  %14 = getelementptr inbounds i8, ptr %.051, i64 1
  %15 = load i8, ptr %.051, align 1, !tbaa !5
  %.fr48 = freeze i8 %15
  br i1 %.04550, label %18, label %16

16:                                               ; preds = %.lr.ph
  %17 = add i8 %.fr48, -48
  %or.cond = icmp ult i8 %17, 10
  br i1 %or.cond, label %.lr.ph.1, label %switch.early.test, !llvm.loop !8

switch.early.test:                                ; preds = %16
  switch i8 %.fr48, label %18 [
    i8 46, label %.lr.ph.1
    i8 43, label %.lr.ph.1
    i8 35, label %.lr.ph.1
  ], !llvm.loop !8

18:                                               ; preds = %switch.early.test, %.lr.ph
  %19 = and i8 %.fr48, -33
  %20 = add i8 %19, -65
  %21 = icmp ult i8 %20, 26
  %22 = or i1 %.04550, %21
  switch i8 %.fr48, label %23 [
    i8 95, label %.lr.ph.1
    i8 39, label %.lr.ph.1
    i8 36, label %.lr.ph.1
  ]

23:                                               ; preds = %18
  %24 = getelementptr inbounds i8, ptr %.04649, i64 1
  store i8 %.fr48, ptr %.04649, align 1, !tbaa !5
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %18, %18, %18, %23, %16, %switch.early.test, %switch.early.test, %switch.early.test
  %.2 = phi ptr [ %.04649, %switch.early.test ], [ %.04649, %switch.early.test ], [ %.04649, %switch.early.test ], [ %.04649, %16 ], [ %24, %23 ], [ %.04649, %18 ], [ %.04649, %18 ], [ %.04649, %18 ]
  %.1 = phi i1 [ false, %switch.early.test ], [ false, %switch.early.test ], [ false, %switch.early.test ], [ false, %16 ], [ %22, %23 ], [ %22, %18 ], [ %22, %18 ], [ %22, %18 ]
  %25 = getelementptr inbounds i8, ptr %.051, i64 2
  %26 = load i8, ptr %14, align 1, !tbaa !5
  %.fr48.1 = freeze i8 %26
  br i1 %.1, label %29, label %27

27:                                               ; preds = %.lr.ph.1
  %28 = add i8 %.fr48.1, -48
  %or.cond.1 = icmp ult i8 %28, 10
  br i1 %or.cond.1, label %36, label %switch.early.test.1, !llvm.loop !8

switch.early.test.1:                              ; preds = %27
  switch i8 %.fr48.1, label %29 [
    i8 46, label %36
    i8 43, label %36
    i8 35, label %36
  ], !llvm.loop !8

29:                                               ; preds = %switch.early.test.1, %.lr.ph.1
  %30 = and i8 %.fr48.1, -33
  %31 = add i8 %30, -65
  %32 = icmp ult i8 %31, 26
  %33 = or i1 %.1, %32
  switch i8 %.fr48.1, label %34 [
    i8 95, label %36
    i8 39, label %36
    i8 36, label %36
  ]

34:                                               ; preds = %29
  %35 = getelementptr inbounds i8, ptr %.2, i64 1
  store i8 %.fr48.1, ptr %.2, align 1, !tbaa !5
  br label %36

36:                                               ; preds = %34, %29, %29, %29, %switch.early.test.1, %switch.early.test.1, %switch.early.test.1, %27
  %.2.1 = phi ptr [ %.2, %switch.early.test.1 ], [ %.2, %switch.early.test.1 ], [ %.2, %switch.early.test.1 ], [ %.2, %27 ], [ %35, %34 ], [ %.2, %29 ], [ %.2, %29 ], [ %.2, %29 ]
  %.1.1 = phi i1 [ false, %switch.early.test.1 ], [ false, %switch.early.test.1 ], [ false, %switch.early.test.1 ], [ false, %27 ], [ %33, %34 ], [ %33, %29 ], [ %33, %29 ], [ %33, %29 ]
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %36, %.lr.ph.preheader
  %.2.lcssa.ph = phi ptr [ poison, %.lr.ph.preheader ], [ %.2.1, %36 ]
  %.051.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %25, %36 ]
  %.04550.unr = phi i1 [ false, %.lr.ph.preheader ], [ %.1.1, %36 ]
  %.04649.unr = phi ptr [ %1, %.lr.ph.preheader ], [ %.2.1, %36 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %37 = load i8, ptr %.051.unr, align 1, !tbaa !5
  %.fr48.epil = freeze i8 %37
  br i1 %.04550.unr, label %40, label %38

38:                                               ; preds = %.lr.ph.epil
  %39 = add i8 %.fr48.epil, -48
  %or.cond.epil = icmp ult i8 %39, 10
  br i1 %or.cond.epil, label %._crit_edge, label %switch.early.test.epil, !llvm.loop !8

switch.early.test.epil:                           ; preds = %38
  switch i8 %.fr48.epil, label %41 [
    i8 46, label %._crit_edge
    i8 43, label %._crit_edge
    i8 35, label %._crit_edge
    i8 95, label %._crit_edge
    i8 39, label %._crit_edge
    i8 36, label %._crit_edge
  ]

40:                                               ; preds = %.lr.ph.epil
  switch i8 %.fr48.epil, label %41 [
    i8 95, label %._crit_edge
    i8 39, label %._crit_edge
    i8 36, label %._crit_edge
  ]

41:                                               ; preds = %switch.early.test.epil, %40
  %42 = getelementptr inbounds i8, ptr %.04649.unr, i64 1
  store i8 %.fr48.epil, ptr %.04649.unr, align 1, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %switch.early.test.epil, %switch.early.test.epil, %switch.early.test.epil, %switch.early.test.epil, %switch.early.test.epil, %switch.early.test.epil, %41, %40, %40, %40, %38, %.preheader
  %.046.lcssa = phi ptr [ %1, %.preheader ], [ %.2.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.04649.unr, %switch.early.test.epil ], [ %.04649.unr, %switch.early.test.epil ], [ %.04649.unr, %switch.early.test.epil ], [ %.04649.unr, %38 ], [ %42, %41 ], [ %.04649.unr, %40 ], [ %.04649.unr, %40 ], [ %.04649.unr, %40 ], [ %.04649.unr, %switch.early.test.epil ], [ %.04649.unr, %switch.early.test.epil ], [ %.04649.unr, %switch.early.test.epil ]
  store i8 0, ptr %.046.lcssa, align 1, !tbaa !5
  ret ptr %1
}

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

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.mustprogress"}


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