; LLVM IR from mackorone/mms :: old/v2/src/sim/Mouse.ll (ZNK3sim5Mouse29getCurrentDiscretizedRotationEv)

; 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.sim::Radians" = type { %"class.sim::Angle" }
%"class.sim::Angle" = type { ptr, double }
%"class.sim::Degrees" = type { %"class.sim::Angle" }

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

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN3sim7DegreesC1Ed(ptr noundef nonnull align 8 dereferenceable(16), double noundef) unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK3sim5Mouse18getCurrentRotationEv(ptr dead_on_unwind noalias writable sret(%"class.sim::Radians") align 8, ptr noundef nonnull align 8 dereferenceable(528)) #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3sim5Mouse29getCurrentDiscretizedRotationEv(ptr noundef nonnull align 8 dereferenceable(528) %0) #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.sim::Radians", align 8
  %6 = alloca %"class.sim::Radians", align 8
  %7 = alloca %"class.sim::Degrees", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.sim::Degrees", align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  call void @_ZNK3sim5Mouse18getCurrentRotationEv(ptr dead_on_unwind writable sret(%"class.sim::Radians") align 8 %6, ptr noundef nonnull align 8 dereferenceable(528) %12)
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  invoke void @_ZN3sim7DegreesC1Ed(ptr noundef nonnull align 8 dereferenceable(16) %7, double noundef 4.500000e+01)
          to label %13 unwind label %24

13:                                               ; preds = %1
  invoke void @_ZNK3sim7RadiansplERKNS_5AngleE(ptr dead_on_unwind writable sret(%"class.sim::Radians") align 8 %5, ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %7)
          to label %14 unwind label %28

14:                                               ; preds = %13
  %15 = invoke noundef double @_ZNK3sim5Angle19getRadiansZeroTo2piEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %16 unwind label %32

16:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  invoke void @_ZN3sim7DegreesC1Ed(ptr noundef nonnull align 8 dereferenceable(16) %10, double noundef 9.000000e+01)
          to label %17 unwind label %36

17:                                               ; preds = %16
  %18 = invoke noundef double @_ZNK3sim5Angle19getRadiansZeroTo2piEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
          to label %19 unwind label %40

19:                                               ; preds = %17
  %20 = fdiv double %15, %18
  %21 = call double @llvm.floor.f64(double %20)
  %22 = fptosi double %21 to i32
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  store i32 %22, ptr %4, align 4, !tbaa !9
  %23 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %23, label %52 [
    i32 0, label %48
    i32 1, label %49
    i32 2, label %50
    i32 3, label %51
  ]

24:                                               ; preds = %1
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %8, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %9, align 4
  br label %47

28:                                               ; preds = %13
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %8, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %9, align 4
  br label %46

32:                                               ; preds = %14
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %8, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %9, align 4
  br label %45

36:                                               ; preds = %16
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %8, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %9, align 4
  br label %44

40:                                               ; preds = %17
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %8, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %9, align 4
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  br label %44

44:                                               ; preds = %40, %36
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  br label %45

45:                                               ; preds = %44, %32
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  br label %46

46:                                               ; preds = %45, %28
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #6
  br label %47

47:                                               ; preds = %46, %24
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %55

48:                                               ; preds = %19
  store i32 1, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %53

49:                                               ; preds = %19
  store i32 0, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %53

50:                                               ; preds = %19
  store i32 3, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %53

51:                                               ; preds = %19
  store i32 2, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %53

52:                                               ; preds = %19
  unreachable

53:                                               ; preds = %51, %50, %49, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %54 = load i32, ptr %2, align 4
  ret i32 %54

55:                                               ; preds = %47
  %56 = load ptr, ptr %8, align 8
  %57 = load i32, ptr %9, align 4
  %58 = insertvalue { ptr, i32 } poison, ptr %56, 0
  %59 = insertvalue { ptr, i32 } %58, i32 %57, 1
  resume { ptr, i32 } %59
}

declare void @_ZNK3sim7RadiansplERKNS_5AngleE(ptr dead_on_unwind writable sret(%"class.sim::Radians") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1

declare noundef double @_ZNK3sim5Angle19getRadiansZeroTo2piEv(ptr noundef nonnull align 8 dereferenceable(16)) #1

attributes #0 = { 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 "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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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 = !{!"int", !7, i64 0}


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

%"class.sim::Radians" = type { %"class.sim::Angle" }
%"class.sim::Angle" = type { ptr, double }
%"class.sim::Degrees" = type { %"class.sim::Angle" }

@switch.table._ZNK3sim5Mouse29getCurrentDiscretizedRotationEv = private unnamed_addr constant [4 x i32] [i32 1, i32 0, i32 3, i32 2], align 4

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

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN3sim7DegreesC1Ed(ptr noundef nonnull align 8 dereferenceable(16), double noundef) unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK3sim5Mouse18getCurrentRotationEv(ptr dead_on_unwind noalias writable sret(%"class.sim::Radians") align 8, ptr noundef nonnull align 8 dereferenceable(528)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 4) i32 @_ZNK3sim5Mouse29getCurrentDiscretizedRotationEv(ptr noundef nonnull align 8 dereferenceable(528) %0) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.sim::Radians", align 8
  %3 = alloca %"class.sim::Radians", align 8
  %4 = alloca %"class.sim::Degrees", align 8
  %5 = alloca %"class.sim::Degrees", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @_ZNK3sim5Mouse18getCurrentRotationEv(ptr dead_on_unwind nonnull writable sret(%"class.sim::Radians") align 8 %3, ptr noundef nonnull align 8 dereferenceable(528) %0)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  invoke void @_ZN3sim7DegreesC1Ed(ptr noundef nonnull align 8 dereferenceable(16) %4, double noundef 4.500000e+01)
          to label %6 unwind label %16

6:                                                ; preds = %1
  invoke void @_ZNK3sim7RadiansplERKNS_5AngleE(ptr dead_on_unwind nonnull writable sret(%"class.sim::Radians") align 8 %2, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4)
          to label %7 unwind label %18

7:                                                ; preds = %6
  %8 = invoke noundef double @_ZNK3sim5Angle19getRadiansZeroTo2piEv(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %9 unwind label %20

9:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  invoke void @_ZN3sim7DegreesC1Ed(ptr noundef nonnull align 8 dereferenceable(16) %5, double noundef 9.000000e+01)
          to label %10 unwind label %22

10:                                               ; preds = %9
  %11 = invoke noundef double @_ZNK3sim5Angle19getRadiansZeroTo2piEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %switch.lookup unwind label %24

switch.lookup:                                    ; preds = %10
  %12 = fdiv double %8, %11
  %13 = call double @llvm.floor.f64(double %12)
  %14 = fptosi double %13 to i32
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #6
  %15 = sext i32 %14 to i64
  %switch.gep = getelementptr inbounds [4 x i32], ptr @switch.table._ZNK3sim5Mouse29getCurrentDiscretizedRotationEv, i64 0, i64 %15
  %switch.load = load i32, ptr %switch.gep, align 4
  ret i32 %switch.load

16:                                               ; preds = %1
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %29

18:                                               ; preds = %6
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %28

20:                                               ; preds = %7
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %27

22:                                               ; preds = %9
  %23 = landingpad { ptr, i32 }
          cleanup
  br label %26

24:                                               ; preds = %10
  %25 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  br label %26

26:                                               ; preds = %24, %22
  %.pn = phi { ptr, i32 } [ %25, %24 ], [ %23, %22 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %27

27:                                               ; preds = %26, %20
  %.pn.pn = phi { ptr, i32 } [ %.pn, %26 ], [ %21, %20 ]
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #6
  br label %28

28:                                               ; preds = %27, %18
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %27 ], [ %19, %18 ]
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #6
  br label %29

29:                                               ; preds = %28, %16
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %28 ], [ %17, %16 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  call void @_ZN3sim5AngleD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #6
  resume { ptr, i32 } %.pn.pn.pn.pn
}

declare void @_ZNK3sim7RadiansplERKNS_5AngleE(ptr dead_on_unwind writable sret(%"class.sim::Radians") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

declare noundef double @_ZNK3sim5Angle19getRadiansZeroTo2piEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

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 "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 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { 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)"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass