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

; 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.ImPlotRange = type { double, double }

; 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 nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL7ImLog10d(double noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL5ImMaxIiET_S0_S0_(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6ImPlot24CalcLogarithmicExponentsERK11ImPlotRangefbRiS3_S3_(ptr noundef nonnull align 8 dereferenceable(16) %0, float noundef %1, i1 noundef zeroext %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5) #3 {
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store float %1, ptr %9, align 4, !tbaa !9
  %19 = zext i1 %2 to i8
  store i8 %19, ptr %10, align 1, !tbaa !11
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImPlotRange, ptr %20, i32 0, i32 0
  %22 = load double, ptr %21, align 8, !tbaa !13
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ImPlotRange, ptr %23, i32 0, i32 1
  %25 = load double, ptr %24, align 8, !tbaa !16
  %26 = fmul double %22, %25
  %27 = fcmp ogt double %26, 0.000000e+00
  br i1 %27, label %28, label %104

28:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %29 = load i8, ptr %10, align 1, !tbaa !11, !range !17, !noundef !18
  %30 = trunc i8 %29 to i1
  br i1 %30, label %31, label %38

31:                                               ; preds = %28
  %32 = load float, ptr %9, align 4, !tbaa !9
  %33 = call float @llvm.fmuladd.f32(float %32, float 0x3F947AE140000000, float 5.000000e-01)
  %34 = fptosi float %33 to i32
  %35 = sitofp i32 %34 to float
  %36 = fptosi float %35 to i32
  %37 = call noundef i32 @_ZL5ImMaxIiET_S0_S0_(i32 noundef 2, i32 noundef %36)
  br label %45

38:                                               ; preds = %28
  %39 = load float, ptr %9, align 4, !tbaa !9
  %40 = call float @llvm.fmuladd.f32(float %39, float 0x3F847AE140000000, float 5.000000e-01)
  %41 = fptosi float %40 to i32
  %42 = sitofp i32 %41 to float
  %43 = fptosi float %42 to i32
  %44 = call noundef i32 @_ZL5ImMaxIiET_S0_S0_(i32 noundef 2, i32 noundef %43)
  br label %45

45:                                               ; preds = %38, %31
  %46 = phi i32 [ %37, %31 ], [ %44, %38 ]
  store i32 %46, ptr %14, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ImPlotRange, ptr %47, i32 0, i32 0
  %49 = load double, ptr %48, align 8, !tbaa !13
  %50 = call noundef double @_ZL5ImAbsd(double noundef %49)
  %51 = call noundef double @_ZL7ImLog10d(double noundef %50)
  store double %51, ptr %15, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ImPlotRange, ptr %52, i32 0, i32 1
  %54 = load double, ptr %53, align 8, !tbaa !16
  %55 = call noundef double @_ZL5ImAbsd(double noundef %54)
  %56 = call noundef double @_ZL7ImLog10d(double noundef %55)
  store double %56, ptr %16, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %57 = load double, ptr %15, align 8, !tbaa !21
  %58 = load double, ptr %16, align 8, !tbaa !21
  %59 = call noundef double @_ZL5ImMinIdET_S0_S0_(double noundef %57, double noundef %58)
  store double %59, ptr %17, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %60 = load double, ptr %15, align 8, !tbaa !21
  %61 = load double, ptr %16, align 8, !tbaa !21
  %62 = call noundef double @_ZL5ImMaxIdET_S0_S0_(double noundef %60, double noundef %61)
  store double %62, ptr %18, align 8, !tbaa !21
  %63 = load double, ptr %18, align 8, !tbaa !21
  %64 = load double, ptr %17, align 8, !tbaa !21
  %65 = fsub double %63, %64
  %66 = fptosi double %65 to i32
  %67 = load i32, ptr %14, align 4, !tbaa !19
  %68 = sdiv i32 %66, %67
  %69 = call noundef i32 @_ZL5ImMaxIiET_S0_S0_(i32 noundef 1, i32 noundef %68)
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %69, ptr %70, align 4, !tbaa !19
  %71 = load double, ptr %17, align 8, !tbaa !21
  %72 = fptosi double %71 to i32
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %72, ptr %73, align 4, !tbaa !19
  %74 = load double, ptr %18, align 8, !tbaa !21
  %75 = fptosi double %74 to i32
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %75, ptr %76, align 4, !tbaa !19
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = load i32, ptr %77, align 4, !tbaa !19
  %79 = icmp ne i32 %78, 1
  br i1 %79, label %80, label %103

80:                                               ; preds = %45
  br label %81

81:                                               ; preds = %86, %80
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = load i32, ptr %82, align 4, !tbaa !19
  %84 = srem i32 %83, 3
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %90

86:                                               ; preds = %81
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = load i32, ptr %87, align 4, !tbaa !19
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %87, align 4, !tbaa !19
  br label %81, !llvm.loop !22

90:                                               ; preds = %81
  br label %91

91:                                               ; preds = %98, %90
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = load i32, ptr %92, align 4, !tbaa !19
  %94 = load ptr, ptr %13, align 8, !tbaa !5
  %95 = load i32, ptr %94, align 4, !tbaa !19
  %96 = srem i32 %93, %95
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %102

98:                                               ; preds = %91
  %99 = load ptr, ptr %11, align 8, !tbaa !5
  %100 = load i32, ptr %99, align 4, !tbaa !19
  %101 = add nsw i32 %100, -1
  store i32 %101, ptr %99, align 4, !tbaa !19
  br label %91, !llvm.loop !24

102:                                              ; preds = %91
  br label %103

103:                                              ; preds = %102, %45
  store i1 true, ptr %7, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %105

104:                                              ; preds = %6
  store i1 false, ptr %7, align 1
  br label %105

105:                                              ; preds = %104, %103
  %106 = load i1, ptr %7, align 1
  ret i1 %106
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL5ImAbsd(double noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL5ImMinIdET_S0_S0_(double noundef, double noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL5ImMaxIdET_S0_S0_(double noundef, double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTS11ImPlotRange", !15, i64 0, !15, i64 8}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !15, i64 8}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!15, !15, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL7ImLog10d(double noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL5ImMaxIiET_S0_S0_(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN6ImPlot24CalcLogarithmicExponentsERK11ImPlotRangefbRiS3_S3_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, float noundef %1, i1 noundef zeroext %2, ptr nocapture noundef nonnull align 4 dereferenceable(4) %3, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %4, ptr nocapture noundef nonnull align 4 dereferenceable(4) %5) local_unnamed_addr #2 {
  %7 = load double, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !10
  %10 = fmul double %7, %9
  %11 = fcmp ogt double %10, 0.000000e+00
  br i1 %11, label %12, label %.loopexit

12:                                               ; preds = %6
  %13 = tail call float @llvm.fmuladd.f32(float %1, float 0x3F847AE140000000, float 5.000000e-01)
  %14 = tail call float @llvm.fmuladd.f32(float %1, float 0x3F947AE140000000, float 5.000000e-01)
  %.sink31 = select i1 %2, float %14, float %13
  %15 = fptosi float %.sink31 to i32
  %16 = tail call noundef i32 @_ZL5ImMaxIiET_S0_S0_(i32 noundef 2, i32 noundef %15)
  %17 = load double, ptr %0, align 8, !tbaa !5
  %18 = tail call noundef double @_ZL5ImAbsd(double noundef %17)
  %19 = tail call noundef double @_ZL7ImLog10d(double noundef %18)
  %20 = load double, ptr %8, align 8, !tbaa !10
  %21 = tail call noundef double @_ZL5ImAbsd(double noundef %20)
  %22 = tail call noundef double @_ZL7ImLog10d(double noundef %21)
  %23 = tail call noundef double @_ZL5ImMinIdET_S0_S0_(double noundef %19, double noundef %22)
  %24 = tail call noundef double @_ZL5ImMaxIdET_S0_S0_(double noundef %19, double noundef %22)
  %25 = fsub double %24, %23
  %26 = fptosi double %25 to i32
  %27 = sdiv i32 %26, %16
  %28 = tail call noundef i32 @_ZL5ImMaxIiET_S0_S0_(i32 noundef 1, i32 noundef %27)
  store i32 %28, ptr %5, align 4, !tbaa !11
  %29 = fptosi double %23 to i32
  store i32 %29, ptr %3, align 4, !tbaa !11
  %30 = fptosi double %24 to i32
  store i32 %30, ptr %4, align 4, !tbaa !11
  %31 = load i32, ptr %5, align 4, !tbaa !11
  %.not = icmp eq i32 %31, 1
  br i1 %.not, label %.loopexit, label %.preheader27

.preheader27:                                     ; preds = %12
  %32 = srem i32 %31, 3
  %.not2528 = icmp eq i32 %32, 0
  br i1 %.not2528, label %.preheader, label %.lr.ph

..preheader_crit_edge:                            ; preds = %.lr.ph
  store i32 %37, ptr %5, align 4, !tbaa !11
  br label %.preheader

.preheader:                                       ; preds = %..preheader_crit_edge, %.preheader27
  %33 = phi i32 [ %37, %..preheader_crit_edge ], [ %31, %.preheader27 ]
  %34 = load i32, ptr %3, align 4, !tbaa !11
  %35 = srem i32 %34, %33
  %.not2629 = icmp eq i32 %35, 0
  br i1 %.not2629, label %.loopexit, label %.lr.ph30

.lr.ph:                                           ; preds = %.preheader27, %.lr.ph
  %36 = phi i32 [ %37, %.lr.ph ], [ %31, %.preheader27 ]
  %37 = add nsw i32 %36, 1
  %38 = srem i32 %37, 3
  %.not25 = icmp eq i32 %38, 0
  br i1 %.not25, label %..preheader_crit_edge, label %.lr.ph, !llvm.loop !13

.lr.ph30:                                         ; preds = %.preheader, %.lr.ph30
  %39 = phi i32 [ %40, %.lr.ph30 ], [ %34, %.preheader ]
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %3, align 4, !tbaa !11
  %41 = load i32, ptr %5, align 4, !tbaa !11
  %42 = srem i32 %40, %41
  %.not26 = icmp eq i32 %42, 0
  br i1 %.not26, label %.loopexit, label %.lr.ph30, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph30, %.preheader, %6, %12
  ret i1 %11
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL5ImAbsd(double noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL5ImMinIdET_S0_S0_(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL5ImMaxIdET_S0_S0_(double noundef, double noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 0}
!6 = !{!"_ZTS11ImPlotRange", !7, i64 0, !7, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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