; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/tests (inputlag)

; 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.nk_vec2 = type { float, float }

@cursor_method = external dso_local global i32, align 4
@cursor_new = external dso_local global %struct.nk_vec2, align 4
@cursor_pos = external dso_local global %struct.nk_vec2, align 4
@cursor_vel = external dso_local global %struct.nk_vec2, align 4

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

declare void @glfwGetCursorPos(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @sample_input(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 2.500000e-01, ptr %3, align 4, !tbaa !9
  %6 = load i32, ptr @cursor_method, align 4, !tbaa !11
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %14

8:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  call void @glfwGetCursorPos(ptr noundef %9, ptr noundef %4, ptr noundef %5)
  %10 = load double, ptr %4, align 8, !tbaa !13
  %11 = fptrunc double %10 to float
  store float %11, ptr @cursor_new, align 4, !tbaa !15
  %12 = load double, ptr %5, align 8, !tbaa !13
  %13 = fptrunc double %12 to float
  store float %13, ptr getelementptr inbounds (%struct.nk_vec2, ptr @cursor_new, i32 0, i32 1), align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %14

14:                                               ; preds = %8, %1
  %15 = load float, ptr @cursor_new, align 4, !tbaa !15
  %16 = load float, ptr @cursor_pos, align 4, !tbaa !15
  %17 = fsub float %15, %16
  %18 = load float, ptr %3, align 4, !tbaa !9
  %19 = load float, ptr @cursor_vel, align 4, !tbaa !15
  %20 = load float, ptr %3, align 4, !tbaa !9
  %21 = fsub float 1.000000e+00, %20
  %22 = fmul float %19, %21
  %23 = call float @llvm.fmuladd.f32(float %17, float %18, float %22)
  store float %23, ptr @cursor_vel, align 4, !tbaa !15
  %24 = load float, ptr getelementptr inbounds (%struct.nk_vec2, ptr @cursor_new, i32 0, i32 1), align 4, !tbaa !17
  %25 = load float, ptr getelementptr inbounds (%struct.nk_vec2, ptr @cursor_pos, i32 0, i32 1), align 4, !tbaa !17
  %26 = fsub float %24, %25
  %27 = load float, ptr %3, align 4, !tbaa !9
  %28 = load float, ptr getelementptr inbounds (%struct.nk_vec2, ptr @cursor_vel, i32 0, i32 1), align 4, !tbaa !17
  %29 = load float, ptr %3, align 4, !tbaa !9
  %30 = fsub float 1.000000e+00, %29
  %31 = fmul float %28, %30
  %32 = call float @llvm.fmuladd.f32(float %26, float %27, float %31)
  store float %32, ptr getelementptr inbounds (%struct.nk_vec2, ptr @cursor_vel, i32 0, i32 1), align 4, !tbaa !17
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @cursor_pos, ptr align 4 @cursor_new, i64 8, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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 #4 = { 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 #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"nk_vec2", !10, i64 0, !10, i64 4}
!17 = !{!16, !10, i64 4}
!18 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}


; 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.nk_vec2 = type { float, float }

@cursor_method = external dso_local local_unnamed_addr global i32, align 4
@cursor_new = external dso_local local_unnamed_addr global %struct.nk_vec2, align 4
@cursor_pos = external dso_local local_unnamed_addr global %struct.nk_vec2, align 4
@cursor_vel = external dso_local local_unnamed_addr global %struct.nk_vec2, align 4

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

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

declare void @glfwGetCursorPos(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @sample_input(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = load i32, ptr @cursor_method, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %7, label %._crit_edge

._crit_edge:                                      ; preds = %1
  %6 = load <2 x float>, ptr @cursor_new, align 4, !tbaa !9
  br label %13

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @glfwGetCursorPos(ptr noundef %0, ptr noundef nonnull %2, ptr noundef nonnull %3) #4
  %8 = load double, ptr %2, align 8, !tbaa !11
  %9 = load double, ptr %3, align 8, !tbaa !11
  %10 = insertelement <2 x double> poison, double %8, i64 0
  %11 = insertelement <2 x double> %10, double %9, i64 1
  %12 = fptrunc <2 x double> %11 to <2 x float>
  store <2 x float> %12, ptr @cursor_new, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  br label %13

13:                                               ; preds = %._crit_edge, %7
  %14 = phi <2 x float> [ %6, %._crit_edge ], [ %12, %7 ]
  %15 = load <2 x float>, ptr @cursor_pos, align 4, !tbaa !9
  %16 = fsub <2 x float> %14, %15
  %17 = load <2 x float>, ptr @cursor_vel, align 4, !tbaa !9
  %18 = fmul <2 x float> %17, <float 7.500000e-01, float 7.500000e-01>
  %19 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %16, <2 x float> <float 2.500000e-01, float 2.500000e-01>, <2 x float> %18)
  store <2 x float> %19, ptr @cursor_vel, align 4, !tbaa !9
  %20 = load i64, ptr @cursor_new, align 4
  store i64 %20, ptr @cursor_pos, align 4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass