; LLVM IR from Sonryle/JoePhys :: testbed/src/WindowManager.ll (ZN13WindowManager16MousePosCallbackEP10GLFWwindowdd)

; 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.Camera = type { %struct.vec2, float, i32, i32 }
%struct.vec2 = type { float, float }
%struct.WindowManager = type <{ %struct.vec2, i32, i32, ptr, ptr, ptr, i8, i8, i8, i8, [4 x i8] }>
%struct.ImGuiIO = type { i32, i32, %struct.ImVec2, float, float, ptr, ptr, ptr, ptr, float, i8, ptr, %struct.ImVec2, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, float, float, float, float, float, float, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, %struct.ImVec2, ptr, %struct.ImVec2, [5 x i8], float, float, i32, i8, i8, i8, i8, i32, [154 x %struct.ImGuiKeyData], i8, %struct.ImVec2, [5 x %struct.ImVec2], [5 x double], [5 x i8], [5 x i8], [5 x i16], [5 x i16], [5 x i8], [5 x double], [5 x i8], [5 x i8], i8, i8, [5 x float], [5 x float], [5 x float], float, i8, i8, i16, %struct.ImVector, ptr, ptr, ptr }
%struct.ImGuiKeyData = type { i8, float, float, float }
%struct.ImVec2 = type { float, float }
%struct.ImVector = type { i32, i32, ptr }

@camera = external global %struct.Camera, align 4
@window_mgr = external dso_local global %struct.WindowManager, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13WindowManager16MousePosCallbackEP10GLFWwindowdd(ptr noundef %0, double noundef %1, double noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca %struct.vec2, align 4
  %8 = alloca %struct.vec2, align 4
  %9 = alloca %struct.vec2, align 4
  %10 = alloca %struct.vec2, align 4
  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
  %11 = call noundef nonnull align 8 dereferenceable(3016) ptr @_ZN5ImGui5GetIOEv()
  %12 = getelementptr inbounds %struct.ImGuiIO, ptr %11, i32 0, i32 52
  %13 = load i8, ptr %12, align 8, !tbaa !11, !range !20, !noundef !21
  %14 = trunc i8 %13 to i1
  br i1 %14, label %43, label %15

15:                                               ; preds = %3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call i32 @glfwGetMouseButton(ptr noundef %16, i32 noundef 0)
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %42

19:                                               ; preds = %15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i32 @glfwGetKey(ptr noundef %20, i32 noundef 341)
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %23, label %41

23:                                               ; preds = %19
  %24 = load float, ptr @window_mgr, align 8, !tbaa !22
  %25 = fpext float %24 to double
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = fsub double %25, %26
  %28 = fptrunc double %27 to float
  %29 = load double, ptr %6, align 8, !tbaa !9
  %30 = load float, ptr getelementptr inbounds (%struct.vec2, ptr @window_mgr, i32 0, i32 1), align 4, !tbaa !25
  %31 = fpext float %30 to double
  %32 = fsub double %29, %31
  %33 = fptrunc double %32 to float
  call void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %9, float noundef %28, float noundef %33)
  %34 = load float, ptr getelementptr inbounds (%struct.Camera, ptr @camera, i32 0, i32 1), align 4, !tbaa !26
  %35 = load <2 x float>, ptr %9, align 4
  %36 = call <2 x float> @_Zml4vec2f(<2 x float> %35, float noundef %34)
  store <2 x float> %36, ptr %8, align 4
  %37 = load <2 x float>, ptr %8, align 4
  %38 = call <2 x float> @_Zdv4vec2f(<2 x float> %37, float noundef 1.000000e+02)
  store <2 x float> %38, ptr %7, align 4
  %39 = load <2 x float>, ptr %7, align 4
  %40 = call <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8) @camera, <2 x float> %39)
  store <2 x float> %40, ptr %10, align 4
  br label %41

41:                                               ; preds = %23, %19
  br label %42

42:                                               ; preds = %41, %15
  br label %43

43:                                               ; preds = %42, %3
  %44 = load double, ptr %5, align 8, !tbaa !9
  %45 = fptrunc double %44 to float
  %46 = load double, ptr %6, align 8, !tbaa !9
  %47 = fptrunc double %46 to float
  call void @_ZN4vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) @window_mgr, float noundef %45, float noundef %47)
  ret void
}

declare i32 @glfwGetKey(ptr noundef, i32 noundef) #2

declare i32 @glfwGetMouseButton(ptr noundef, i32 noundef) #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zdv4vec2f(<2 x float>, float noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zml4vec2f(<2 x float>, float noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) #3 align 2

attributes #0 = { 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 #1 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 = !{!"double", !7, i64 0}
!11 = !{!12, !16, i64 176}
!12 = !{!"_ZTS7ImGuiIO", !13, i64 0, !13, i64 4, !14, i64 8, !15, i64 16, !15, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !16, i64 60, !6, i64 64, !14, i64 72, !16, i64 80, !16, i64 81, !16, i64 82, !16, i64 83, !16, i64 84, !16, i64 85, !16, i64 86, !16, i64 87, !16, i64 88, !16, i64 89, !16, i64 90, !16, i64 91, !16, i64 92, !16, i64 93, !16, i64 94, !16, i64 95, !16, i64 96, !15, i64 100, !15, i64 104, !15, i64 108, !15, i64 112, !15, i64 116, !15, i64 120, !16, i64 124, !16, i64 125, !16, i64 126, !16, i64 127, !16, i64 128, !16, i64 129, !16, i64 130, !16, i64 131, !16, i64 132, !16, i64 133, !16, i64 134, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !16, i64 176, !16, i64 177, !16, i64 178, !16, i64 179, !16, i64 180, !16, i64 181, !16, i64 182, !15, i64 184, !13, i64 188, !13, i64 192, !13, i64 196, !13, i64 200, !14, i64 204, !6, i64 216, !14, i64 224, !7, i64 232, !15, i64 240, !15, i64 244, !17, i64 248, !16, i64 252, !16, i64 253, !16, i64 254, !16, i64 255, !13, i64 256, !7, i64 260, !16, i64 2724, !14, i64 2728, !7, i64 2736, !7, i64 2776, !7, i64 2816, !7, i64 2821, !7, i64 2826, !7, i64 2836, !7, i64 2846, !7, i64 2856, !7, i64 2896, !7, i64 2901, !16, i64 2906, !16, i64 2907, !7, i64 2908, !7, i64 2928, !7, i64 2948, !15, i64 2968, !16, i64 2972, !16, i64 2973, !18, i64 2974, !19, i64 2976, !6, i64 2992, !6, i64 3000, !6, i64 3008}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS6ImVec2", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS16ImGuiMouseSource", !7, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!"_ZTS8ImVectorItE", !13, i64 0, !13, i64 4, !6, i64 8}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!23, !15, i64 0}
!23 = !{!"_ZTS13WindowManager", !24, i64 0, !13, i64 8, !13, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !16, i64 40, !16, i64 41, !16, i64 42, !16, i64 43}
!24 = !{!"_ZTS4vec2", !15, i64 0, !15, i64 4}
!25 = !{!23, !15, i64 4}
!26 = !{!27, !15, i64 8}
!27 = !{!"_ZTS6Camera", !24, i64 0, !15, i64 8, !13, i64 12, !13, i64 16}


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

%struct.Camera = type { %struct.vec2, float, i32, i32 }
%struct.vec2 = type { float, float }
%struct.WindowManager = type <{ %struct.vec2, i32, i32, ptr, ptr, ptr, i8, i8, i8, i8, [4 x i8] }>

@camera = external global %struct.Camera, align 4
@window_mgr = external dso_local global %struct.WindowManager, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13WindowManager16MousePosCallbackEP10GLFWwindowdd(ptr noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %struct.vec2, align 8
  %5 = tail call noundef nonnull align 8 dereferenceable(3016) ptr @_ZN5ImGui5GetIOEv()
  %6 = getelementptr inbounds i8, ptr %5, i64 176
  %7 = load i8, ptr %6, align 8, !tbaa !5, !range !17, !noundef !18
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %29, label %9

9:                                                ; preds = %3
  %10 = tail call i32 @glfwGetMouseButton(ptr noundef %0, i32 noundef 0)
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %12, label %29

12:                                               ; preds = %9
  %13 = tail call i32 @glfwGetKey(ptr noundef %0, i32 noundef 341)
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %29

15:                                               ; preds = %12
  %16 = load float, ptr @window_mgr, align 8, !tbaa !19
  %17 = fpext float %16 to double
  %18 = fsub double %17, %1
  %19 = fptrunc double %18 to float
  %20 = load float, ptr getelementptr inbounds (i8, ptr @window_mgr, i64 4), align 4, !tbaa !22
  %21 = fpext float %20 to double
  %22 = fsub double %2, %21
  %23 = fptrunc double %22 to float
  call void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef %19, float noundef %23)
  %24 = load float, ptr getelementptr inbounds (i8, ptr @camera, i64 8), align 4, !tbaa !23
  %25 = load <2 x float>, ptr %4, align 8
  %26 = call <2 x float> @_Zml4vec2f(<2 x float> %25, float noundef %24)
  %27 = call <2 x float> @_Zdv4vec2f(<2 x float> %26, float noundef 1.000000e+02)
  %28 = call <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8) @camera, <2 x float> %27)
  br label %29

29:                                               ; preds = %9, %15, %12, %3
  %30 = fptrunc double %1 to float
  %31 = fptrunc double %2 to float
  call void @_ZN4vec23SetEff(ptr noundef nonnull align 4 dereferenceable(8) @window_mgr, float noundef %30, float noundef %31)
  ret void
}

declare i32 @glfwGetKey(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @glfwGetMouseButton(ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zdv4vec2f(<2 x float>, float noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zml4vec2f(<2 x float>, float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4vec2pLES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) local_unnamed_addr #3 align 2

attributes #0 = { 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 #1 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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, !13, i64 176}
!6 = !{!"_ZTS7ImGuiIO", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 20, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !11, i64 56, !13, i64 60, !12, i64 64, !10, i64 72, !13, i64 80, !13, i64 81, !13, i64 82, !13, i64 83, !13, i64 84, !13, i64 85, !13, i64 86, !13, i64 87, !13, i64 88, !13, i64 89, !13, i64 90, !13, i64 91, !13, i64 92, !13, i64 93, !13, i64 94, !13, i64 95, !13, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !13, i64 124, !13, i64 125, !13, i64 126, !13, i64 127, !13, i64 128, !13, i64 129, !13, i64 130, !13, i64 131, !13, i64 132, !13, i64 133, !13, i64 134, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !13, i64 176, !13, i64 177, !13, i64 178, !13, i64 179, !13, i64 180, !13, i64 181, !13, i64 182, !11, i64 184, !7, i64 188, !7, i64 192, !7, i64 196, !7, i64 200, !10, i64 204, !12, i64 216, !10, i64 224, !8, i64 232, !11, i64 240, !11, i64 244, !14, i64 248, !13, i64 252, !13, i64 253, !13, i64 254, !13, i64 255, !7, i64 256, !8, i64 260, !13, i64 2724, !10, i64 2728, !8, i64 2736, !8, i64 2776, !8, i64 2816, !8, i64 2821, !8, i64 2826, !8, i64 2836, !8, i64 2846, !8, i64 2856, !8, i64 2896, !8, i64 2901, !13, i64 2906, !13, i64 2907, !8, i64 2908, !8, i64 2928, !8, i64 2948, !11, i64 2968, !13, i64 2972, !13, i64 2973, !15, i64 2974, !16, i64 2976, !12, i64 2992, !12, i64 3000, !12, i64 3008}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS6ImVec2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"_ZTS16ImGuiMouseSource", !8, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!"_ZTS8ImVectorItE", !7, i64 0, !7, i64 4, !12, i64 8}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!20, !11, i64 0}
!20 = !{!"_ZTS13WindowManager", !21, i64 0, !7, i64 8, !7, i64 12, !12, i64 16, !12, i64 24, !12, i64 32, !13, i64 40, !13, i64 41, !13, i64 42, !13, i64 43}
!21 = !{!"_ZTS4vec2", !11, i64 0, !11, i64 4}
!22 = !{!20, !11, i64 4}
!23 = !{!24, !11, i64 8}
!24 = !{!"_ZTS6Camera", !21, i64 0, !11, i64 8, !7, i64 12, !7, i64 16}


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