; LLVM IR from hadryansalles/Luz :: deps/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"

%struct.ImGuiTypingSelectRequest = type { i32, i32, ptr, i8, i8, i8 }

; 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 uwtable
define dso_local noundef i32 @_ZN5ImGui35TypingSelectFindNextSingleCharMatchEP24ImGuiTypingSelectRequestiPFPKcPviES4_i(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 -1, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #2
  store i8 0, ptr %13, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %74, %5
  %18 = load i32, ptr %14, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 2, ptr %15, align 4
  br label %77

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = load i32, ptr %14, align 4, !tbaa !9
  %26 = call noundef ptr %23(ptr noundef %24, i32 noundef %25)
  store ptr %26, ptr %16, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ImGuiTypingSelectRequest, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ImGuiTypingSelectRequest, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ImGuiTypingSelectRequest, ptr %33, i32 0, i32 5
  %35 = load i8, ptr %34, align 2, !tbaa !15
  %36 = sext i8 %35 to i32
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %32, i64 %37
  %39 = load ptr, ptr %16, align 8, !tbaa !5
  %40 = call noundef i32 @_ZL14ImStrimatchlenPKcS0_S0_(ptr noundef %29, ptr noundef %38, ptr noundef %39)
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ImGuiTypingSelectRequest, ptr %41, i32 0, i32 5
  %43 = load i8, ptr %42, align 2, !tbaa !15
  %44 = sext i8 %43 to i32
  %45 = icmp slt i32 %40, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %22
  store i32 4, ptr %15, align 4
  br label %71

47:                                               ; preds = %22
  %48 = load i8, ptr %13, align 1, !tbaa !11, !range !16, !noundef !17
  %49 = trunc i8 %48 to i1
  br i1 %49, label %50, label %52

50:                                               ; preds = %47
  %51 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %51, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %71

52:                                               ; preds = %47
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = icmp eq i32 %53, -1
  br i1 %54, label %55, label %60

55:                                               ; preds = %52
  %56 = load i32, ptr %11, align 4, !tbaa !9
  %57 = icmp eq i32 %56, -1
  br i1 %57, label %58, label %60

58:                                               ; preds = %55
  %59 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %59, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %71

60:                                               ; preds = %55, %52
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = icmp eq i32 %61, -1
  br i1 %62, label %63, label %65

63:                                               ; preds = %60
  %64 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %64, ptr %12, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %63, %60
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = load i32, ptr %14, align 4, !tbaa !9
  %68 = icmp eq i32 %66, %67
  br i1 %68, label %69, label %70

69:                                               ; preds = %65
  store i8 1, ptr %13, align 1, !tbaa !11
  br label %70

70:                                               ; preds = %69, %65
  store i32 0, ptr %15, align 4
  br label %71

71:                                               ; preds = %70, %58, %50, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  %72 = load i32, ptr %15, align 4
  switch i32 %72, label %77 [
    i32 0, label %73
    i32 4, label %74
  ]

73:                                               ; preds = %71
  br label %74

74:                                               ; preds = %73, %71
  %75 = load i32, ptr %14, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %14, align 4, !tbaa !9
  br label %17, !llvm.loop !18

77:                                               ; preds = %71, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  %78 = load i32, ptr %15, align 4
  switch i32 %78, label %81 [
    i32 2, label %79
  ]

79:                                               ; preds = %77
  %80 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %80, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %81

81:                                               ; preds = %79, %77
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %82 = load i32, ptr %6, align 4
  ret i32 %82
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"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 = !{!"bool", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS24ImGuiTypingSelectRequest", !10, i64 0, !10, i64 4, !6, i64 8, !12, i64 16, !12, i64 17, !7, i64 18}
!15 = !{!14, !7, i64 18}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"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 uwtable
define dso_local noundef i32 @_ZN5ImGui35TypingSelectFindNextSingleCharMatchEP24ImGuiTypingSelectRequestiPFPKcPviES4_i(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %.not40 = icmp sgt i32 %1, 0
  br i1 %.not40, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = getelementptr inbounds i8, ptr %0, i64 18
  br label %8

8:                                                ; preds = %.lr.ph, %23
  %.02643 = phi i32 [ 0, %.lr.ph ], [ %24, %23 ]
  %.02742 = phi i1 [ false, %.lr.ph ], [ %.229, %23 ]
  %.03041 = phi i32 [ -1, %.lr.ph ], [ %.232, %23 ]
  %9 = tail call noundef ptr %2(ptr noundef %3, i32 noundef %.02643)
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = load i8, ptr %7, align 2, !tbaa !12
  %12 = sext i8 %11 to i64
  %13 = getelementptr inbounds i8, ptr %10, i64 %12
  %14 = tail call noundef i32 @_ZL14ImStrimatchlenPKcS0_S0_(ptr noundef %10, ptr noundef %13, ptr noundef %9)
  %15 = load i8, ptr %7, align 2, !tbaa !12
  %16 = sext i8 %15 to i32
  %17 = icmp slt i32 %14, %16
  br i1 %17, label %23, label %18

18:                                               ; preds = %8
  %19 = and i32 %.03041, %4
  %or.cond = icmp eq i32 %19, -1
  %or.cond39 = select i1 %.02742, i1 true, i1 %or.cond
  br i1 %or.cond39, label %.thread, label %20

20:                                               ; preds = %18
  %21 = icmp eq i32 %.03041, -1
  %spec.select = select i1 %21, i32 %.02643, i32 %.03041
  %22 = icmp eq i32 %.02643, %4
  br label %23

23:                                               ; preds = %20, %8
  %.232 = phi i32 [ %spec.select, %20 ], [ %.03041, %8 ]
  %.229 = phi i1 [ %22, %20 ], [ %.02742, %8 ]
  %24 = add nuw nsw i32 %.02643, 1
  %exitcond.not = icmp eq i32 %24, %1
  br i1 %exitcond.not, label %.thread, label %8, !llvm.loop !13

.thread:                                          ; preds = %23, %18, %5
  %spec.select34 = phi i32 [ -1, %5 ], [ %.02643, %18 ], [ %.232, %23 ]
  ret i32 %spec.select34
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL14ImStrimatchlenPKcS0_S0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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" }

!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, !10, i64 8}
!6 = !{!"_ZTS24ImGuiTypingSelectRequest", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 17, !8, i64 18}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !8, i64 18}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass