; LLVM IR from yangfengzzz/DigitalVox4 :: editor/imgui_node_editor.ll (ZN3vox10NodeEditor6Detail14NavigateAction14MatchZoomIndexEi)

; 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.vox::NodeEditor::Detail::NavigateAction" = type <{ %"struct.vox::NodeEditor::Detail::EditorAction", i8, [3 x i8], float, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, ptr, %struct.ImVec2, %struct.ImVec2, %"struct.vox::NodeEditor::Detail::NavigateAnimation", i32, [4 x i8], i64, ptr, i8, [3 x i8], %struct.ImVec2, [4 x i8] }>
%"struct.vox::NodeEditor::Detail::EditorAction" = type { ptr, ptr }
%"struct.vox::NodeEditor::Detail::NavigateAnimation" = type { %"struct.vox::NodeEditor::Detail::Animation.base", ptr, %struct.ImRect, %struct.ImRect }
%"struct.vox::NodeEditor::Detail::Animation.base" = type <{ ptr, ptr, i32, float, float }>
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }
%struct.ImVec2 = type { float, float }

@_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE = external dso_local constant [18 x float], align 16

; 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.fabs.f32(float) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN3vox10NodeEditor6Detail14NavigateAction14MatchZoomIndexEi(ptr noundef nonnull align 8 dereferenceable(184) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 -1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store float 0.000000e+00, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %33, %2
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 18
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %36

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [18 x float], ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 0, i64 %16
  %18 = load float, ptr %17, align 4, !tbaa !11
  %19 = getelementptr inbounds %"struct.vox::NodeEditor::Detail::NavigateAction", ptr %9, i32 0, i32 3
  %20 = load float, ptr %19, align 4, !tbaa !13
  %21 = fsub float %18, %20
  %22 = call float @llvm.fabs.f32(float %21)
  store float %22, ptr %8, align 4, !tbaa !11
  %23 = load float, ptr %8, align 4, !tbaa !11
  %24 = load float, ptr %6, align 4, !tbaa !11
  %25 = fcmp olt float %23, %24
  br i1 %25, label %29, label %26

26:                                               ; preds = %14
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %26, %14
  %30 = load float, ptr %8, align 4, !tbaa !11
  store float %30, ptr %6, align 4, !tbaa !11
  %31 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %31, ptr %5, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %29, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %7, align 4, !tbaa !9
  br label %10, !llvm.loop !24

36:                                               ; preds = %13
  %37 = load float, ptr %6, align 4, !tbaa !11
  %38 = fcmp ogt float %37, 0x3F50624DE0000000
  br i1 %38, label %39, label %61

39:                                               ; preds = %36
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %42, label %49

42:                                               ; preds = %39
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %5, align 4, !tbaa !9
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = icmp sge i32 %45, 18
  br i1 %46, label %47, label %48

47:                                               ; preds = %42
  store i32 17, ptr %5, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %47, %42
  br label %60

49:                                               ; preds = %39
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = icmp slt i32 %50, 0
  br i1 %51, label %52, label %59

52:                                               ; preds = %49
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = add nsw i32 %53, -1
  store i32 %54, ptr %5, align 4, !tbaa !9
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %52
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %57, %52
  br label %59

59:                                               ; preds = %58, %49
  br label %60

60:                                               ; preds = %59, %48
  br label %61

61:                                               ; preds = %60, %36
  %62 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %62
}

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

!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 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !12, i64 20}
!14 = !{!"_ZTSN3vox10NodeEditor6Detail14NavigateActionE", !15, i64 0, !16, i64 16, !12, i64 20, !17, i64 24, !17, i64 32, !17, i64 40, !6, i64 48, !17, i64 56, !17, i64 64, !18, i64 72, !22, i64 144, !23, i64 152, !6, i64 160, !16, i64 168, !17, i64 172}
!15 = !{!"_ZTSN3vox10NodeEditor6Detail12EditorActionE", !6, i64 8}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!18 = !{!"_ZTSN3vox10NodeEditor6Detail17NavigateAnimationE", !19, i64 0, !6, i64 32, !21, i64 40, !21, i64 56}
!19 = !{!"_ZTSN3vox10NodeEditor6Detail9AnimationE", !6, i64 8, !20, i64 16, !12, i64 20, !12, i64 24}
!20 = !{!"_ZTSN3vox10NodeEditor6Detail9Animation5StateE", !7, i64 0}
!21 = !{!"_ZTS6ImRect", !17, i64 0, !17, i64 8}
!22 = !{!"_ZTSN3vox10NodeEditor6Detail14NavigateAction16NavigationReasonE", !7, i64 0}
!23 = !{!"long", !7, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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"

@_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE = external dso_local local_unnamed_addr constant [18 x float], align 16

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef i32 @_ZN3vox10NodeEditor6Detail14NavigateAction14MatchZoomIndexEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(184) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = load float, ptr %3, align 4, !tbaa !5
  %5 = load <2 x float>, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, align 16, !tbaa !20
  %6 = insertelement <2 x float> poison, float %4, i64 0
  %7 = shufflevector <2 x float> %6, <2 x float> poison, <2 x i32> zeroinitializer
  %8 = fsub <2 x float> %5, %7
  %9 = tail call <2 x float> @llvm.fabs.v2f32(<2 x float> %8)
  %10 = extractelement <2 x float> %9, i64 0
  %11 = extractelement <2 x float> %9, i64 1
  %12 = fcmp olt float %11, %10
  %.120.1 = select i1 %12, float %11, float %10
  %.1.1 = zext i1 %12 to i32
  %13 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 8), align 8, !tbaa !20
  %14 = fsub float %13, %4
  %15 = tail call float @llvm.fabs.f32(float %14)
  %16 = fcmp olt float %15, %.120.1
  %.120.2 = select i1 %16, float %15, float %.120.1
  %.1.2 = select i1 %16, i32 2, i32 %.1.1
  %17 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 12), align 4, !tbaa !20
  %18 = fsub float %17, %4
  %19 = tail call float @llvm.fabs.f32(float %18)
  %20 = fcmp olt float %19, %.120.2
  %.120.3 = select i1 %20, float %19, float %.120.2
  %.1.3 = select i1 %20, i32 3, i32 %.1.2
  %21 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 16), align 16, !tbaa !20
  %22 = fsub float %21, %4
  %23 = tail call float @llvm.fabs.f32(float %22)
  %24 = fcmp olt float %23, %.120.3
  %.120.4 = select i1 %24, float %23, float %.120.3
  %.1.4 = select i1 %24, i32 4, i32 %.1.3
  %25 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 20), align 4, !tbaa !20
  %26 = fsub float %25, %4
  %27 = tail call float @llvm.fabs.f32(float %26)
  %28 = fcmp olt float %27, %.120.4
  %.120.5 = select i1 %28, float %27, float %.120.4
  %.1.5 = select i1 %28, i32 5, i32 %.1.4
  %29 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 24), align 8, !tbaa !20
  %30 = fsub float %29, %4
  %31 = tail call float @llvm.fabs.f32(float %30)
  %32 = fcmp olt float %31, %.120.5
  %.120.6 = select i1 %32, float %31, float %.120.5
  %.1.6 = select i1 %32, i32 6, i32 %.1.5
  %33 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 28), align 4, !tbaa !20
  %34 = fsub float %33, %4
  %35 = tail call float @llvm.fabs.f32(float %34)
  %36 = fcmp olt float %35, %.120.6
  %.120.7 = select i1 %36, float %35, float %.120.6
  %.1.7 = select i1 %36, i32 7, i32 %.1.6
  %37 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 32), align 16, !tbaa !20
  %38 = fsub float %37, %4
  %39 = tail call float @llvm.fabs.f32(float %38)
  %40 = fcmp olt float %39, %.120.7
  %.120.8 = select i1 %40, float %39, float %.120.7
  %.1.8 = select i1 %40, i32 8, i32 %.1.7
  %41 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 36), align 4, !tbaa !20
  %42 = fsub float %41, %4
  %43 = tail call float @llvm.fabs.f32(float %42)
  %44 = fcmp olt float %43, %.120.8
  %.120.9 = select i1 %44, float %43, float %.120.8
  %.1.9 = select i1 %44, i32 9, i32 %.1.8
  %45 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 40), align 8, !tbaa !20
  %46 = fsub float %45, %4
  %47 = tail call float @llvm.fabs.f32(float %46)
  %48 = fcmp olt float %47, %.120.9
  %.120.10 = select i1 %48, float %47, float %.120.9
  %.1.10 = select i1 %48, i32 10, i32 %.1.9
  %49 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 44), align 4, !tbaa !20
  %50 = fsub float %49, %4
  %51 = tail call float @llvm.fabs.f32(float %50)
  %52 = fcmp olt float %51, %.120.10
  %.120.11 = select i1 %52, float %51, float %.120.10
  %.1.11 = select i1 %52, i32 11, i32 %.1.10
  %53 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 48), align 16, !tbaa !20
  %54 = fsub float %53, %4
  %55 = tail call float @llvm.fabs.f32(float %54)
  %56 = fcmp olt float %55, %.120.11
  %.120.12 = select i1 %56, float %55, float %.120.11
  %.1.12 = select i1 %56, i32 12, i32 %.1.11
  %57 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 52), align 4, !tbaa !20
  %58 = fsub float %57, %4
  %59 = tail call float @llvm.fabs.f32(float %58)
  %60 = fcmp olt float %59, %.120.12
  %.120.13 = select i1 %60, float %59, float %.120.12
  %.1.13 = select i1 %60, i32 13, i32 %.1.12
  %61 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 56), align 8, !tbaa !20
  %62 = fsub float %61, %4
  %63 = tail call float @llvm.fabs.f32(float %62)
  %64 = fcmp olt float %63, %.120.13
  %.120.14 = select i1 %64, float %63, float %.120.13
  %.1.14 = select i1 %64, i32 14, i32 %.1.13
  %65 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 60), align 4, !tbaa !20
  %66 = fsub float %65, %4
  %67 = tail call float @llvm.fabs.f32(float %66)
  %68 = fcmp olt float %67, %.120.14
  %.120.15 = select i1 %68, float %67, float %.120.14
  %.1.15 = select i1 %68, i32 15, i32 %.1.14
  %69 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 64), align 16, !tbaa !20
  %70 = fsub float %69, %4
  %71 = tail call float @llvm.fabs.f32(float %70)
  %72 = fcmp olt float %71, %.120.15
  %.120.16 = select i1 %72, float %71, float %.120.15
  %.1.16 = select i1 %72, i32 16, i32 %.1.15
  %73 = load float, ptr getelementptr inbounds (i8, ptr @_ZN3vox10NodeEditor6Detail14NavigateAction12s_ZoomLevelsE, i64 68), align 4, !tbaa !20
  %74 = fsub float %73, %4
  %75 = tail call float @llvm.fabs.f32(float %74)
  %76 = fcmp olt float %75, %.120.16
  %.120.17 = select i1 %76, float %75, float %.120.16
  %.1.17 = select i1 %76, i32 17, i32 %.1.16
  %77 = fcmp ogt float %.120.17, 0x3F50624DE0000000
  br i1 %77, label %78, label %86

78:                                               ; preds = %2
  %79 = icmp sgt i32 %1, 0
  br i1 %79, label %80, label %82

80:                                               ; preds = %78
  %81 = tail call i32 @llvm.umin.i32(i32 %.1.17, i32 16)
  %spec.store.select = add nuw nsw i32 %81, 1
  br label %86

82:                                               ; preds = %78
  %83 = icmp slt i32 %1, 0
  br i1 %83, label %84, label %86

84:                                               ; preds = %82
  %85 = tail call i32 @llvm.umax.i32(i32 %.1.17, i32 1)
  %spec.store.select2 = add nsw i32 %85, -1
  br label %86

86:                                               ; preds = %80, %84, %82, %2
  %.2 = phi i32 [ %spec.store.select, %80 ], [ %spec.store.select2, %84 ], [ %.1.17, %82 ], [ %.1.17, %2 ]
  ret i32 %.2
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fabs.v2f32(<2 x float>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !12, i64 20}
!6 = !{!"_ZTSN3vox10NodeEditor6Detail14NavigateActionE", !7, i64 0, !11, i64 16, !12, i64 20, !13, i64 24, !13, i64 32, !13, i64 40, !8, i64 48, !13, i64 56, !13, i64 64, !14, i64 72, !18, i64 144, !19, i64 152, !8, i64 160, !11, i64 168, !13, i64 172}
!7 = !{!"_ZTSN3vox10NodeEditor6Detail12EditorActionE", !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!14 = !{!"_ZTSN3vox10NodeEditor6Detail17NavigateAnimationE", !15, i64 0, !8, i64 32, !17, i64 40, !17, i64 56}
!15 = !{!"_ZTSN3vox10NodeEditor6Detail9AnimationE", !8, i64 8, !16, i64 16, !12, i64 20, !12, i64 24}
!16 = !{!"_ZTSN3vox10NodeEditor6Detail9Animation5StateE", !9, i64 0}
!17 = !{!"_ZTS6ImRect", !13, i64 0, !13, i64 8}
!18 = !{!"_ZTSN3vox10NodeEditor6Detail14NavigateAction16NavigationReasonE", !9, i64 0}
!19 = !{!"long", !9, i64 0}
!20 = !{!12, !12, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass