; LLVM IR from Razakhel/RaZ :: extern/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.ImGui_ImplGlfw_Data = type { ptr, i32, double, ptr, [5 x i8], [9 x ptr], i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%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, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.ImVec2, [5 x i8], float, float, i8, i8, i8, i8, [512 x i8], [20 x float], i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, i32, %struct.ImVec2, i32, 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], [20 x float], [20 x float], float, i16, %struct.ImVector }
%struct.ImVec2 = type { float, float }
%struct.ImVector = type { i32, i32, ptr }

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

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

; 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 void @_Z29ImGui_ImplGlfw_ScrollCallbackP10GLFWwindowdd(ptr noundef %0, double noundef %1, double noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  store ptr %9, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %10, i32 0, i32 10
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %27

14:                                               ; preds = %3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = icmp eq ptr %15, %18
  br i1 %19, label %20, label %27

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

27:                                               ; preds = %20, %14, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %28 = call noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv()
  store ptr %28, ptr %8, align 8, !tbaa !5
  %29 = load double, ptr %5, align 8, !tbaa !9
  %30 = fptrunc double %29 to float
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ImGuiIO, ptr %31, i32 0, i32 39
  %33 = load float, ptr %32, align 4, !tbaa !16
  %34 = fadd float %33, %30
  store float %34, ptr %32, align 4, !tbaa !16
  %35 = load double, ptr %6, align 8, !tbaa !9
  %36 = fptrunc double %35 to float
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ImGuiIO, ptr %37, i32 0, i32 38
  %39 = load float, ptr %38, align 8, !tbaa !23
  %40 = fadd float %39, %36
  store float %40, ptr %38, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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

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 = { "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, !6, i64 144}
!12 = !{!"_ZTS19ImGui_ImplGlfw_Data", !6, i64 0, !13, i64 8, !10, i64 16, !6, i64 24, !7, i64 32, !7, i64 40, !14, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168}
!13 = !{!"_ZTS13GlfwClientApi", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !20, i64 308}
!17 = !{!"_ZTS7ImGuiIO", !18, i64 0, !18, i64 4, !19, i64 8, !20, i64 16, !20, i64 20, !6, i64 24, !6, i64 32, !20, i64 40, !20, i64 44, !20, i64 48, !7, i64 52, !20, i64 140, !20, i64 144, !6, i64 152, !6, i64 160, !20, i64 168, !14, i64 172, !6, i64 176, !19, i64 184, !14, i64 192, !14, i64 193, !14, i64 194, !14, i64 195, !14, i64 196, !14, i64 197, !20, i64 200, !6, 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, !6, i64 280, !19, i64 288, !7, i64 296, !20, i64 304, !20, i64 308, !14, i64 312, !14, i64 313, !14, i64 314, !14, i64 315, !7, i64 316, !7, i64 828, !14, i64 908, !14, i64 909, !14, i64 910, !14, i64 911, !14, i64 912, !14, i64 913, !14, i64 914, !20, i64 916, !18, i64 920, !18, i64 924, !18, i64 928, !18, i64 932, !18, i64 936, !19, i64 940, !18, i64 948, !18, i64 952, !19, i64 956, !7, i64 964, !7, i64 1008, !7, i64 1048, !7, i64 1053, !7, i64 1058, !7, i64 1063, !7, i64 1068, !7, i64 1076, !7, i64 1096, !7, i64 1116, !7, i64 1156, !7, i64 1176, !7, i64 3224, !7, i64 5272, !7, i64 5352, !20, i64 5432, !21, i64 5436, !22, i64 5440}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTS6ImVec2", !20, i64 0, !20, i64 4}
!20 = !{!"float", !7, i64 0}
!21 = !{!"short", !7, i64 0}
!22 = !{!"_ZTS8ImVectorItE", !18, i64 0, !18, i64 4, !6, i64 8}
!23 = !{!17, !20, i64 304}


; 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
declare hidden noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav() local_unnamed_addr #0

; 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 = tail call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  %5 = getelementptr inbounds i8, ptr %4, i64 144
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %11, label %7

7:                                                ; preds = %3
  %8 = load ptr, ptr %4, align 8, !tbaa !13
  %9 = icmp eq ptr %8, %0
  br i1 %9, label %10, label %11

10:                                               ; preds = %7
  tail call void %6(ptr noundef %0, double noundef %1, double noundef %2)
  br label %11

11:                                               ; preds = %10, %7, %3
  %12 = tail call noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv()
  %13 = insertelement <2 x double> poison, double %2, i64 0
  %14 = insertelement <2 x double> %13, double %1, i64 1
  %15 = fptrunc <2 x double> %14 to <2 x float>
  %16 = getelementptr inbounds i8, ptr %12, i64 304
  %17 = load <2 x float>, ptr %16, align 8, !tbaa !14
  %18 = fadd <2 x float> %17, %15
  store <2 x float> %18, ptr %16, align 8, !tbaa !14
  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, !7, i64 144}
!6 = !{!"_ZTS19ImGui_ImplGlfw_Data", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !8, i64 32, !8, i64 40, !12, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168}
!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 = !{!6, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}


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