; LLVM IR from chiraqL/Engine3D :: src/imgui/imgui_impl_glfw.ll (Z29ImGui_ImplGlfw_ScrollCallbackP10GLFWwindowdd)

; 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.ImGuiIO = type { i32, i32, %struct.ImVec2, float, float, ptr, ptr, float, float, float, [22 x i32], float, float, ptr, ptr, float, i8, ptr, %struct.ImVec2, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.ImVec2, [5 x i8], float, float, i32, i8, i8, i8, i8, [512 x i8], [21 x float], i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, i32, %struct.ImVec2, i32, %struct.ImVec2, [5 x %struct.ImVec2], [5 x double], [5 x i8], [5 x i8], [5 x i8], [5 x i8], [5 x i8], [5 x float], [5 x float], [5 x %struct.ImVec2], [5 x float], [512 x float], [512 x float], [21 x float], [21 x float], float, i16, %struct.ImVector }
%struct.ImVec2 = type { float, float }
%struct.ImVector = type { i32, i32, ptr }

@_ZL8g_Window = external hidden global ptr, align 8
@_ZL24g_PrevUserCallbackScroll = external hidden global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z29ImGui_ImplGlfw_ScrollCallbackP10GLFWwindowdd(ptr noundef %0, double noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr @_ZL24g_PrevUserCallbackScroll, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %19

10:                                               ; preds = %3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !5
  %13 = icmp eq ptr %11, %12
  br i1 %13, label %14, label %19

14:                                               ; preds = %10
  %15 = load ptr, ptr @_ZL24g_PrevUserCallbackScroll, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load double, ptr %5, align 8, !tbaa !9
  %18 = load double, ptr %6, align 8, !tbaa !9
  call void %15(ptr noundef %16, double noundef %17, double noundef %18)
  br label %19

19:                                               ; preds = %14, %10, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %20 = call noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv()
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = load double, ptr %5, align 8, !tbaa !9
  %22 = fptrunc double %21 to float
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ImGuiIO, ptr %23, i32 0, i32 45
  %25 = load float, ptr %24, align 4, !tbaa !11
  %26 = fadd float %25, %22
  store float %26, ptr %24, align 4, !tbaa !11
  %27 = load double, ptr %6, align 8, !tbaa !9
  %28 = fptrunc double %27 to float
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ImGuiIO, ptr %29, i32 0, i32 44
  %31 = load float, ptr %30, align 8, !tbaa !19
  %32 = fadd float %31, %28
  store float %32, ptr %30, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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

declare noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv() #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 = !{!"double", !7, i64 0}
!11 = !{!12, !15, i64 300}
!12 = !{!"_ZTS7ImGuiIO", !13, i64 0, !13, i64 4, !14, i64 8, !15, i64 16, !15, i64 20, !6, i64 24, !6, i64 32, !15, i64 40, !15, i64 44, !15, i64 48, !7, i64 52, !15, i64 140, !15, i64 144, !6, i64 152, !6, i64 160, !15, i64 168, !16, i64 172, !6, i64 176, !14, i64 184, !16, i64 192, !16, i64 193, !16, i64 194, !16, i64 195, !16, i64 196, !16, i64 197, !16, i64 198, !16, i64 199, !16, i64 200, !16, i64 201, !16, i64 202, !16, i64 203, !16, i64 204, !16, i64 205, !15, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !14, i64 280, !7, i64 288, !15, i64 296, !15, i64 300, !13, i64 304, !16, i64 308, !16, i64 309, !16, i64 310, !16, i64 311, !7, i64 312, !7, i64 824, !16, i64 908, !16, i64 909, !16, i64 910, !16, i64 911, !16, i64 912, !16, i64 913, !16, i64 914, !15, i64 916, !13, i64 920, !13, i64 924, !13, i64 928, !13, i64 932, !13, i64 936, !14, i64 940, !13, i64 948, !14, i64 952, !7, i64 960, !7, i64 1000, !7, i64 1040, !7, i64 1045, !7, i64 1050, !7, i64 1055, !7, i64 1060, !7, i64 1068, !7, i64 1088, !7, i64 1108, !7, i64 1148, !7, i64 1168, !7, i64 3216, !7, i64 5264, !7, i64 5348, !15, i64 5432, !17, i64 5436, !18, i64 5440}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS6ImVec2", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!"_ZTS8ImVectorItE", !13, i64 0, !13, i64 4, !6, i64 8}
!19 = !{!12, !15, i64 296}


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

@_ZL8g_Window = external hidden local_unnamed_addr global ptr, align 8
@_ZL24g_PrevUserCallbackScroll = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z29ImGui_ImplGlfw_ScrollCallbackP10GLFWwindowdd(ptr noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr @_ZL24g_PrevUserCallbackScroll, align 8, !tbaa !5
  %.not = icmp ne ptr %4, null
  %5 = load ptr, ptr @_ZL8g_Window, align 8
  %6 = icmp eq ptr %5, %0
  %or.cond = select i1 %.not, i1 %6, i1 false
  br i1 %or.cond, label %7, label %8

7:                                                ; preds = %3
  tail call void %4(ptr noundef %0, double noundef %1, double noundef %2)
  br label %8

8:                                                ; preds = %7, %3
  %9 = tail call noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv()
  %10 = insertelement <2 x double> poison, double %2, i64 0
  %11 = insertelement <2 x double> %10, double %1, i64 1
  %12 = fptrunc <2 x double> %11 to <2 x float>
  %13 = getelementptr inbounds i8, ptr %9, i64 296
  %14 = load <2 x float>, ptr %13, align 8, !tbaa !9
  %15 = fadd <2 x float> %14, %12
  store <2 x float> %15, ptr %13, align 8, !tbaa !9
  ret void
}

declare noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv() 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, !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}


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