; LLVM IR from Overload-Technologies/Overload :: Dependencies/ImGui/src (imgui_impl_glfw)

; 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.ImGui_ImplGlfw_Data = type { ptr, i32, double, ptr, [11 x ptr], i8, i8, %struct.ImVec2, [348 x ptr], i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.ImVec2 = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z34ImGui_ImplGlfw_MouseButtonCallbackP10GLFWwindowiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %12 = call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  store ptr %12, ptr %9, align 8, !tbaa !5
  %13 = load ptr, ptr %9, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %13, i32 0, i32 14
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %28

17:                                               ; preds = %4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef %18)
  br i1 %19, label %20, label %28

20:                                               ; preds = %17
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %21, i32 0, i32 14
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  call void %23(ptr noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27)
  br label %28

28:                                               ; preds = %20, %17, %4
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %29, i32 0, i32 6
  %31 = load i8, ptr %30, align 1, !tbaa !18, !range !19, !noundef !20
  %32 = trunc i8 %31 to i1
  br i1 %32, label %33, label %37

33:                                               ; preds = %28
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  store i32 1, ptr %10, align 4
  br label %51

37:                                               ; preds = %33, %28
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef %38)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %39 = call noundef nonnull align 8 dereferenceable(3088) ptr @_ZN5ImGui5GetIOEv()
  store ptr %39, ptr %11, align 8, !tbaa !5
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = icmp sge i32 %40, 0
  br i1 %41, label %42, label %50

42:                                               ; preds = %37
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = icmp slt i32 %43, 5
  br i1 %44, label %45, label %50

45:                                               ; preds = %42
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = icmp eq i32 %48, 1
  call void @_ZN7ImGuiIO19AddMouseButtonEventEib(ptr noundef nonnull align 8 dereferenceable(3088) %46, i32 noundef %47, i1 noundef zeroext %49)
  br label %50

50:                                               ; preds = %45, %42, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  store i32 0, ptr %10, align 4
  br label %51

51:                                               ; preds = %50, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %52 = load i32, ptr %10, align 4
  switch i32 %52, label %54 [
    i32 0, label %53
    i32 1, label %53
  ]

53:                                               ; preds = %51, %51
  ret void

54:                                               ; preds = %51
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav() #0

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef) #0

declare noundef nonnull align 8 dereferenceable(3088) ptr @_ZN5ImGui5GetIOEv() #2

declare void @_ZN7ImGuiIO19AddMouseButtonEventEib(ptr noundef nonnull align 8 dereferenceable(3088), i32 noundef, i1 noundef zeroext) #2

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !6, i64 2952}
!12 = !{!"_ZTS19ImGui_ImplGlfw_Data", !6, i64 0, !13, i64 8, !14, i64 16, !6, i64 24, !7, i64 32, !15, i64 120, !15, i64 121, !16, i64 124, !7, i64 136, !15, i64 2920, !15, i64 2921, !6, i64 2928, !6, i64 2936, !6, i64 2944, !6, i64 2952, !6, i64 2960, !6, i64 2968, !6, i64 2976, !6, i64 2984}
!13 = !{!"_ZTS13GlfwClientApi", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTS6ImVec2", !17, i64 0, !17, i64 4}
!17 = !{!"float", !7, i64 0}
!18 = !{!12, !15, i64 121}
!19 = !{i8 0, i8 2}
!20 = !{}


; 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 void @_Z34ImGui_ImplGlfw_MouseButtonCallbackP10GLFWwindowiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  %6 = getelementptr inbounds i8, ptr %5, i64 2952
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %12, label %8

8:                                                ; preds = %4
  %9 = tail call noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef %0)
  br i1 %9, label %10, label %12

10:                                               ; preds = %8
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  tail call void %11(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3)
  br label %12

12:                                               ; preds = %10, %8, %4
  %13 = getelementptr inbounds i8, ptr %5, i64 121
  %14 = load i8, ptr %13, align 1, !tbaa !15, !range !16, !noundef !17
  %15 = trunc nuw i8 %14 to i1
  %16 = icmp eq i32 %2, 0
  %or.cond = and i1 %16, %15
  br i1 %or.cond, label %21, label %17

17:                                               ; preds = %12
  tail call void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef %0)
  %18 = tail call noundef nonnull align 8 dereferenceable(3088) ptr @_ZN5ImGui5GetIOEv()
  %or.cond3 = icmp ult i32 %1, 5
  br i1 %or.cond3, label %19, label %21

19:                                               ; preds = %17
  %20 = icmp eq i32 %2, 1
  tail call void @_ZN7ImGuiIO19AddMouseButtonEventEib(ptr noundef nonnull align 8 dereferenceable(3088) %18, i32 noundef %1, i1 noundef zeroext %20)
  br label %21

21:                                               ; preds = %17, %19, %12
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL34ImGui_ImplGlfw_ShouldChainCallbackP10GLFWwindow(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL33ImGui_ImplGlfw_UpdateKeyModifiersP10GLFWwindow(ptr noundef) local_unnamed_addr #0

declare noundef nonnull align 8 dereferenceable(3088) ptr @_ZN5ImGui5GetIOEv() local_unnamed_addr #1

declare void @_ZN7ImGuiIO19AddMouseButtonEventEib(ptr noundef nonnull align 8 dereferenceable(3088), i32 noundef, i1 noundef zeroext) local_unnamed_addr #1

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" }
attributes #1 = { "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 2952}
!6 = !{!"_ZTS19ImGui_ImplGlfw_Data", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !8, i64 32, !12, i64 120, !12, i64 121, !13, i64 124, !8, i64 136, !12, i64 2920, !12, i64 2921, !7, i64 2928, !7, i64 2936, !7, i64 2944, !7, i64 2952, !7, i64 2960, !7, i64 2968, !7, i64 2976, !7, i64 2984}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS13GlfwClientApi", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"_ZTS6ImVec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !8, i64 0}
!15 = !{!6, !12, i64 121}
!16 = !{i8 0, i8 2}
!17 = !{}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass