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

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

; 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: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z22ImParseFormatFindStartPKc(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z22ImParseFormatPrecisionPKci(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = call noundef ptr @_Z22ImParseFormatFindStartPKc(ptr noundef %7)
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 0
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = sext i8 %11 to i32
  %13 = icmp ne i32 %12, 37
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %15, ptr %3, align 4
  br label %85

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i32 1
  store ptr %18, ptr %4, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %31, %16
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = sext i8 %21 to i32
  %23 = icmp sge i32 %22, 48
  br i1 %23, label %24, label %29

24:                                               ; preds = %19
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = icmp sle i32 %27, 57
  br label %29

29:                                               ; preds = %24, %19
  %30 = phi i1 [ false, %19 ], [ %28, %24 ]
  br i1 %30, label %31, label %34

31:                                               ; preds = %29
  %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
  br label %19, !llvm.loop !12

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 2147483647, ptr %6, align 4, !tbaa !9
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 %37, 46
  br i1 %38, label %39, label %51

39:                                               ; preds = %34
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 1
  %42 = call noundef ptr @_ZL6ImAtoiIiEPKcS1_PT_(ptr noundef %41, ptr noundef %6)
  store ptr %42, ptr %4, align 8, !tbaa !5
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %48, label %45

45:                                               ; preds = %39
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = icmp sgt i32 %46, 99
  br i1 %47, label %48, label %50

48:                                               ; preds = %45, %39
  %49 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %49, ptr %6, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %48, %45
  br label %51

51:                                               ; preds = %50, %34
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 101
  br i1 %55, label %61, label %56

56:                                               ; preds = %51
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load i8, ptr %57, align 1, !tbaa !11
  %59 = sext i8 %58 to i32
  %60 = icmp eq i32 %59, 69
  br i1 %60, label %61, label %62

61:                                               ; preds = %56, %51
  store i32 -1, ptr %6, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %61, %56
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = load i8, ptr %63, align 1, !tbaa !11
  %65 = sext i8 %64 to i32
  %66 = icmp eq i32 %65, 103
  br i1 %66, label %72, label %67

67:                                               ; preds = %62
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = load i8, ptr %68, align 1, !tbaa !11
  %70 = sext i8 %69 to i32
  %71 = icmp eq i32 %70, 71
  br i1 %71, label %72, label %76

72:                                               ; preds = %67, %62
  %73 = load i32, ptr %6, align 4, !tbaa !9
  %74 = icmp eq i32 %73, 2147483647
  br i1 %74, label %75, label %76

75:                                               ; preds = %72
  store i32 -1, ptr %6, align 4, !tbaa !9
  br label %76

76:                                               ; preds = %75, %72, %67
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = icmp eq i32 %77, 2147483647
  br i1 %78, label %79, label %81

79:                                               ; preds = %76
  %80 = load i32, ptr %5, align 4, !tbaa !9
  br label %83

81:                                               ; preds = %76
  %82 = load i32, ptr %6, align 4, !tbaa !9
  br label %83

83:                                               ; preds = %81, %79
  %84 = phi i32 [ %80, %79 ], [ %82, %81 ]
  store i32 %84, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %85

85:                                               ; preds = %83, %14
  %86 = load i32, ptr %3, align 4
  ret i32 %86
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL6ImAtoiIiEPKcS1_PT_(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z22ImParseFormatPrecisionPKci(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = tail call noundef ptr @_Z22ImParseFormatFindStartPKc(ptr noundef %0)
  %5 = load i8, ptr %4, align 1, !tbaa !5
  %.not = icmp eq i8 %5, 37
  br i1 %.not, label %.preheader, label %26

.preheader:                                       ; preds = %2, %.preheader
  %.pn = phi ptr [ %.018, %.preheader ], [ %4, %2 ]
  %.018 = getelementptr inbounds i8, ptr %.pn, i64 1
  %6 = load i8, ptr %.018, align 1, !tbaa !5
  %7 = add i8 %6, -48
  %or.cond23 = icmp ult i8 %7, 10
  br i1 %or.cond23, label %.preheader, label %.critedge, !llvm.loop !8

.critedge:                                        ; preds = %.preheader
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  store i32 2147483647, ptr %3, align 4, !tbaa !10
  %8 = icmp eq i8 %6, 46
  br i1 %8, label %9, label %16

9:                                                ; preds = %.critedge
  %10 = getelementptr inbounds i8, ptr %.pn, i64 2
  %11 = call noundef ptr @_ZL6ImAtoiIiEPKcS1_PT_(ptr noundef nonnull %10, ptr noundef nonnull %3)
  %12 = load i32, ptr %3, align 4
  %or.cond = icmp ugt i32 %12, 99
  br i1 %or.cond, label %13, label %thread-pre-split

13:                                               ; preds = %9
  store i32 %1, ptr %3, align 4, !tbaa !10
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %9, %13
  %14 = phi i32 [ %12, %9 ], [ %1, %13 ]
  %.pr = load i8, ptr %11, align 1, !tbaa !5
  %15 = freeze i32 %14
  br label %16

16:                                               ; preds = %thread-pre-split, %.critedge
  %.fr = phi i32 [ %15, %thread-pre-split ], [ 2147483647, %.critedge ]
  %17 = phi i8 [ %.pr, %thread-pre-split ], [ %6, %.critedge ]
  switch i8 %17, label %18 [
    i8 101, label %.thread30
    i8 69, label %.thread30
    i8 103, label %21
  ]

18:                                               ; preds = %16
  %19 = icmp eq i8 %17, 71
  %20 = icmp eq i32 %.fr, 2147483647
  %or.cond3 = and i1 %19, %20
  br i1 %or.cond3, label %22, label %23

21:                                               ; preds = %16
  %.old2 = icmp eq i32 %.fr, 2147483647
  br i1 %.old2, label %22, label %.thread30

22:                                               ; preds = %18, %21
  br label %.thread30

23:                                               ; preds = %18
  %24 = icmp eq i32 %.fr, 2147483647
  %spec.select = select i1 %24, i32 %1, i32 %.fr
  br label %.thread30

.thread30:                                        ; preds = %23, %16, %16, %21, %22
  %25 = phi i32 [ %.fr, %21 ], [ -1, %22 ], [ -1, %16 ], [ -1, %16 ], [ %spec.select, %23 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  br label %26

26:                                               ; preds = %2, %.thread30
  %.0 = phi i32 [ %25, %.thread30 ], [ %1, %2 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL6ImAtoiIiEPKcS1_PT_(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass