; LLVM IR from cyberbotics/epuck_ros2 :: epuck_ros2_driver/src/mpu9250.ll (ZN7MPU92504readEv)

; 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.MPU9250 = type { [3 x float], [3 x float], [3 x i16], [3 x i16], i32, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZZN7MPU92504readEvE12rawGyroscope = external hidden global [3 x i16], align 2
@_ZZN7MPU92504readEvE16rawAccelerometer = external hidden global [3 x i16], align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7MPU92508read_rawEPsS0_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef, ptr noundef) #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7MPU92504readEv(ptr noundef nonnull align 8 dereferenceable(56) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @_ZN7MPU92508read_rawEPsS0_(ptr noundef nonnull align 8 dereferenceable(56) %5, ptr noundef @_ZZN7MPU92504readEvE16rawAccelerometer, ptr noundef @_ZZN7MPU92504readEvE12rawGyroscope)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %37, %1
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 3
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %40

10:                                               ; preds = %6
  %11 = getelementptr inbounds %class.MPU9250, ptr %5, i32 0, i32 3
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [3 x i16], ptr %11, i64 0, i64 %13
  %15 = load i16, ptr %14, align 2, !tbaa !11
  %16 = sext i16 %15 to i32
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [3 x i16], ptr @_ZZN7MPU92504readEvE16rawAccelerometer, i64 0, i64 %18
  %20 = load i16, ptr %19, align 2, !tbaa !11
  %21 = sext i16 %20 to i32
  %22 = sub nsw i32 %21, %16
  %23 = trunc i32 %22 to i16
  store i16 %23, ptr %19, align 2, !tbaa !11
  %24 = getelementptr inbounds %class.MPU9250, ptr %5, i32 0, i32 2
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [3 x i16], ptr %24, i64 0, i64 %26
  %28 = load i16, ptr %27, align 2, !tbaa !11
  %29 = sext i16 %28 to i32
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [3 x i16], ptr @_ZZN7MPU92504readEvE12rawGyroscope, i64 0, i64 %31
  %33 = load i16, ptr %32, align 2, !tbaa !11
  %34 = sext i16 %33 to i32
  %35 = sub nsw i32 %34, %29
  %36 = trunc i32 %35 to i16
  store i16 %36, ptr %32, align 2, !tbaa !11
  br label %37

37:                                               ; preds = %10
  %38 = load i32, ptr %3, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !13

40:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %72, %40
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 3
  br i1 %43, label %45, label %44

44:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %75

45:                                               ; preds = %41
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [3 x i16], ptr @_ZZN7MPU92504readEvE16rawAccelerometer, i64 0, i64 %47
  %49 = load i16, ptr %48, align 2, !tbaa !11
  %50 = sitofp i16 %49 to float
  %51 = fpext float %50 to double
  %52 = fdiv double %51, 1.638400e+04
  %53 = fmul double %52, 9.810000e+00
  %54 = fptrunc double %53 to float
  %55 = getelementptr inbounds %class.MPU9250, ptr %5, i32 0, i32 1
  %56 = load i32, ptr %4, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [3 x float], ptr %55, i64 0, i64 %57
  store float %54, ptr %58, align 4, !tbaa !15
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [3 x i16], ptr @_ZZN7MPU92504readEvE12rawGyroscope, i64 0, i64 %60
  %62 = load i16, ptr %61, align 2, !tbaa !11
  %63 = sitofp i16 %62 to float
  %64 = fpext float %63 to double
  %65 = fdiv double %64, 1.310720e+02
  %66 = fmul double %65, 0x3F91DF46A2529D39
  %67 = fptrunc double %66 to float
  %68 = getelementptr inbounds %class.MPU9250, ptr %5, i32 0, i32 0
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [3 x float], ptr %68, i64 0, i64 %70
  store float %67, ptr %71, align 4, !tbaa !15
  br label %72

72:                                               ; preds = %45
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !9
  br label %41, !llvm.loop !17

75:                                               ; preds = %44
  ret void
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !14}


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

@_ZZN7MPU92504readEvE12rawGyroscope = external hidden global [3 x i16], align 2
@_ZZN7MPU92504readEvE16rawAccelerometer = external hidden global [3 x i16], align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7MPU92504readEv(ptr noundef nonnull align 8 dereferenceable(56) %0) local_unnamed_addr #0 align 2 {
.preheader:
  tail call void @_ZN7MPU92508read_rawEPsS0_(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull @_ZZN7MPU92504readEvE16rawAccelerometer, ptr noundef nonnull @_ZZN7MPU92504readEvE12rawGyroscope)
  %1 = getelementptr inbounds i8, ptr %0, i64 30
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load <2 x i16>, ptr %1, align 2, !tbaa !5
  %4 = load <2 x i16>, ptr @_ZZN7MPU92504readEvE16rawAccelerometer, align 2, !tbaa !5
  %5 = sub <2 x i16> %4, %3
  store <2 x i16> %5, ptr @_ZZN7MPU92504readEvE16rawAccelerometer, align 2, !tbaa !5
  %6 = load <2 x i16>, ptr %2, align 8, !tbaa !5
  %7 = load <2 x i16>, ptr @_ZZN7MPU92504readEvE12rawGyroscope, align 2, !tbaa !5
  %8 = sub <2 x i16> %7, %6
  store <2 x i16> %8, ptr @_ZZN7MPU92504readEvE12rawGyroscope, align 2, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 34
  %10 = load i16, ptr %9, align 2, !tbaa !5
  %11 = load i16, ptr getelementptr inbounds (i8, ptr @_ZZN7MPU92504readEvE16rawAccelerometer, i64 4), align 2, !tbaa !5
  %12 = sub i16 %11, %10
  store i16 %12, ptr getelementptr inbounds (i8, ptr @_ZZN7MPU92504readEvE16rawAccelerometer, i64 4), align 2, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 28
  %14 = load i16, ptr %13, align 4, !tbaa !5
  %15 = load i16, ptr getelementptr inbounds (i8, ptr @_ZZN7MPU92504readEvE12rawGyroscope, i64 4), align 2, !tbaa !5
  %16 = sub i16 %15, %14
  store i16 %16, ptr getelementptr inbounds (i8, ptr @_ZZN7MPU92504readEvE12rawGyroscope, i64 4), align 2, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = sitofp <2 x i16> %5 to <2 x double>
  %19 = fmul <2 x double> %18, <double 0x3F10000000000000, double 0x3F10000000000000>
  %20 = fmul <2 x double> %19, <double 9.810000e+00, double 9.810000e+00>
  %21 = fptrunc <2 x double> %20 to <2 x float>
  store <2 x float> %21, ptr %17, align 4, !tbaa !9
  %22 = sitofp <2 x i16> %8 to <2 x double>
  %23 = fdiv <2 x double> %22, <double 1.310720e+02, double 1.310720e+02>
  %24 = fmul <2 x double> %23, <double 0x3F91DF46A2529D39, double 0x3F91DF46A2529D39>
  %25 = fptrunc <2 x double> %24 to <2 x float>
  store <2 x float> %25, ptr %0, align 8, !tbaa !9
  %26 = sitofp i16 %12 to double
  %27 = fmul double %26, 0x3F10000000000000
  %28 = fmul double %27, 9.810000e+00
  %29 = fptrunc double %28 to float
  %30 = getelementptr inbounds i8, ptr %0, i64 20
  store float %29, ptr %30, align 4, !tbaa !9
  %31 = sitofp i16 %16 to double
  %32 = fdiv double %31, 1.310720e+02
  %33 = fmul double %32, 0x3F91DF46A2529D39
  %34 = fptrunc double %33 to float
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  store float %34, ptr %35, align 8, !tbaa !9
  ret void
}

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

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass