; LLVM IR from mackorone/mms :: old/v2/src/mouse/continuous/Continuous.ll (ZN10continuous10Continuous8gyroTestEv)

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

%"class.continuous::Continuous" = type { %class.IMouseAlgorithm, i32, i32, i32, i32, float, float, [256 x i8], [5 x i8], [3 x i8], i8, i8, i32, i8, i8, i8, i8, i32, i32, i32, i8, i8, i8, i8, i8, float, i32, i32, i32, double, double, double, double, double, double, i32, i32, ptr }
%class.IMouseAlgorithm = type { ptr }

; 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: mustprogress uwtable
declare dso_local noundef i64 @_ZN10continuous10Continuous6millisEv(ptr noundef nonnull align 8 dereferenceable(408)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10continuous10Continuous11readSensorsEv(ptr noundef nonnull align 8 dereferenceable(408)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10continuous10Continuous8setSpeedEdd(ptr noundef nonnull align 8 dereferenceable(408), double noundef, double noundef) #1 align 2

declare noundef double @_ZN3sim14MouseInterface22currentRotationDegreesEv(ptr noundef nonnull align 8 dereferenceable(296)) #2

; Function Attrs: uwtable
define dso_local void @_ZN10continuous10Continuous8gyroTestEv(ptr noundef nonnull align 8 dereferenceable(408) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store double 0.000000e+00, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %8 = call noundef i64 @_ZN10continuous10Continuous6millisEv(ptr noundef nonnull align 8 dereferenceable(408) %7)
  store i64 %8, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !13
  call void @_ZN10continuous10Continuous8setSpeedEdd(ptr noundef nonnull align 8 dereferenceable(408) %7, double noundef 2.000000e+02, double noundef 2.000000e+02)
  br label %9

9:                                                ; preds = %28, %1
  br label %10

10:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %11 = call noundef i64 @_ZN10continuous10Continuous6millisEv(ptr noundef nonnull align 8 dereferenceable(408) %7)
  %12 = load i64, ptr %4, align 8, !tbaa !11
  %13 = sub nsw i64 %11, %12
  store i64 %13, ptr %6, align 8, !tbaa !11
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = load i32, ptr %5, align 4, !tbaa !13
  %16 = sext i32 %15 to i64
  %17 = icmp sge i64 %14, %16
  br i1 %17, label %18, label %28

18:                                               ; preds = %10
  %19 = getelementptr inbounds %"class.continuous::Continuous", ptr %7, i32 0, i32 37
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = call noundef double @_ZN3sim14MouseInterface22currentRotationDegreesEv(ptr noundef nonnull align 8 dereferenceable(296) %20)
  store double %21, ptr %3, align 8, !tbaa !9
  %22 = load double, ptr %3, align 8, !tbaa !9
  %23 = fcmp oge double %22, 2.700000e+02
  br i1 %23, label %24, label %27

24:                                               ; preds = %18
  call void @_ZN10continuous10Continuous8setSpeedEdd(ptr noundef nonnull align 8 dereferenceable(408) %7, double noundef 0.000000e+00, double noundef 0.000000e+00)
  call void @_ZN10continuous10Continuous11readSensorsEv(ptr noundef nonnull align 8 dereferenceable(408) %7)
  br label %25

25:                                               ; preds = %26, %24
  br label %26

26:                                               ; preds = %25
  br label %25

27:                                               ; preds = %18
  br label %28

28:                                               ; preds = %27, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %9, !llvm.loop !21
}

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 = { 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 #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 = !{!"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, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 400}
!16 = !{!"_ZTSN10continuous10ContinuousE", !17, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !18, i64 24, !18, i64 28, !7, i64 32, !7, i64 288, !7, i64 293, !19, i64 296, !19, i64 297, !14, i64 300, !19, i64 304, !19, i64 305, !19, i64 306, !19, i64 307, !14, i64 308, !14, i64 312, !14, i64 316, !19, i64 320, !19, i64 321, !19, i64 322, !19, i64 323, !19, i64 324, !18, i64 328, !20, i64 332, !14, i64 336, !14, i64 340, !10, i64 344, !10, i64 352, !10, i64 360, !10, i64 368, !10, i64 376, !10, i64 384, !14, i64 392, !14, i64 396, !6, i64 400}
!17 = !{!"_ZTS15IMouseAlgorithm"}
!18 = !{!"float", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSN10continuous10ContinuousUt_E", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; 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 dso_local noundef i64 @_ZN10continuous10Continuous6millisEv(ptr noundef nonnull align 8 dereferenceable(408)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10continuous10Continuous11readSensorsEv(ptr noundef nonnull align 8 dereferenceable(408)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10continuous10Continuous8setSpeedEdd(ptr noundef nonnull align 8 dereferenceable(408), double noundef, double noundef) local_unnamed_addr #0 align 2

declare noundef double @_ZN3sim14MouseInterface22currentRotationDegreesEv(ptr noundef nonnull align 8 dereferenceable(296)) local_unnamed_addr #1

; Function Attrs: noreturn uwtable
define dso_local void @_ZN10continuous10Continuous8gyroTestEv(ptr noundef nonnull align 8 dereferenceable(408) %0) local_unnamed_addr #2 align 2 {
  %2 = tail call noundef i64 @_ZN10continuous10Continuous6millisEv(ptr noundef nonnull align 8 dereferenceable(408) %0)
  tail call void @_ZN10continuous10Continuous8setSpeedEdd(ptr noundef nonnull align 8 dereferenceable(408) %0, double noundef 2.000000e+02, double noundef 2.000000e+02)
  %3 = getelementptr inbounds i8, ptr %0, i64 400
  br label %4

4:                                                ; preds = %.backedge, %1
  %5 = tail call noundef i64 @_ZN10continuous10Continuous6millisEv(ptr noundef nonnull align 8 dereferenceable(408) %0)
  %6 = icmp sgt i64 %5, %2
  br i1 %6, label %7, label %.backedge

7:                                                ; preds = %4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = tail call noundef double @_ZN3sim14MouseInterface22currentRotationDegreesEv(ptr noundef nonnull align 8 dereferenceable(296) %8)
  %10 = fcmp ult double %9, 2.700000e+02
  br i1 %10, label %.backedge, label %11

.backedge:                                        ; preds = %7, %4
  br label %4, !llvm.loop !16

11:                                               ; preds = %7
  tail call void @_ZN10continuous10Continuous8setSpeedEdd(ptr noundef nonnull align 8 dereferenceable(408) %0, double noundef 0.000000e+00, double noundef 0.000000e+00)
  tail call void @_ZN10continuous10Continuous11readSensorsEv(ptr noundef nonnull align 8 dereferenceable(408) %0)
  br label %12

12:                                               ; preds = %12, %11
  br label %12
}

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" }
attributes #2 = { noreturn 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" }

!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, !15, i64 400}
!6 = !{!"_ZTSN10continuous10ContinuousE", !7, i64 0, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !11, i64 24, !11, i64 28, !9, i64 32, !9, i64 288, !9, i64 293, !12, i64 296, !12, i64 297, !8, i64 300, !12, i64 304, !12, i64 305, !12, i64 306, !12, i64 307, !8, i64 308, !8, i64 312, !8, i64 316, !12, i64 320, !12, i64 321, !12, i64 322, !12, i64 323, !12, i64 324, !11, i64 328, !13, i64 332, !8, i64 336, !8, i64 340, !14, i64 344, !14, i64 352, !14, i64 360, !14, i64 368, !14, i64 376, !14, i64 384, !8, i64 392, !8, i64 396, !15, i64 400}
!7 = !{!"_ZTS15IMouseAlgorithm"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"_ZTSN10continuous10ContinuousUt_E", !9, i64 0}
!14 = !{!"double", !9, i64 0}
!15 = !{!"any pointer", !9, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass