; LLVM IR from IOsonata/IOsonata :: src/sensors/accel_sensor.ll (ZN11AccelSensor20SetCalibrationMatrixERA3_A3_f)

; 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.AccelSensor = type <{ %class.Sensor.base, %struct.__AccelSensor_Raw_Data, [5 x i8], ptr, i16, [2 x i8], [3 x [3 x float]], [3 x float], [4 x i8], %class.Device }>
%class.Sensor.base = type <{ ptr, i32, i32, i32, i32, i64, i8, [7 x i8], i64, i64, i32, i32, i32, i32, %"struct.std::atomic_flag" }>
%"struct.std::atomic_flag" = type { %"struct.std::__atomic_flag_base" }
%"struct.std::__atomic_flag_base" = type { i8 }
%struct.__AccelSensor_Raw_Data = type <{ i64, i16, i16, %union.anon }>
%union.anon = type { [3 x i16] }
%class.Device = type { ptr, i8, i32, ptr, ptr, i64, i8, ptr, i8, i32 }
%class.Sensor = type <{ ptr, i32, i32, i32, i32, i64, i8, [7 x i8], i64, i64, i32, i32, i32, i32, %"struct.std::atomic_flag", [7 x i8], %class.Device }>

; 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 nounwind uwtable
define dso_local void @_ZN11AccelSensor20SetCalibrationMatrixERA3_A3_f(ptr noundef nonnull align 8 dereferenceable(156) %0, ptr noundef nonnull align 4 dereferenceable(36) %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %8 = getelementptr inbounds %class.AccelSensor, ptr %7, i32 0, i32 4
  %9 = load i16, ptr %8, align 8, !tbaa !9
  %10 = uitofp i16 %9 to float
  %11 = getelementptr inbounds %class.Sensor, ptr %7, i32 0, i32 13
  %12 = load i32, ptr %11, align 4, !tbaa !21
  %13 = uitofp i32 %12 to float
  %14 = fdiv float %10, %13
  store float %14, ptr %5, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !24
  br label %15

15:                                               ; preds = %59, %2
  %16 = load i32, ptr %6, align 4, !tbaa !24
  %17 = icmp slt i32 %16, 3
  br i1 %17, label %19, label %18

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

19:                                               ; preds = %15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds [3 x [3 x float]], ptr %20, i64 0, i64 0
  %22 = load i32, ptr %6, align 4, !tbaa !24
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [3 x float], ptr %21, i64 0, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !22
  %26 = load float, ptr %5, align 4, !tbaa !22
  %27 = fmul float %25, %26
  %28 = getelementptr inbounds %class.AccelSensor, ptr %7, i32 0, i32 6
  %29 = getelementptr inbounds [3 x [3 x float]], ptr %28, i64 0, i64 0
  %30 = load i32, ptr %6, align 4, !tbaa !24
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [3 x float], ptr %29, i64 0, i64 %31
  store float %27, ptr %32, align 4, !tbaa !22
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds [3 x [3 x float]], ptr %33, i64 0, i64 1
  %35 = load i32, ptr %6, align 4, !tbaa !24
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [3 x float], ptr %34, i64 0, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !22
  %39 = load float, ptr %5, align 4, !tbaa !22
  %40 = fmul float %38, %39
  %41 = getelementptr inbounds %class.AccelSensor, ptr %7, i32 0, i32 6
  %42 = getelementptr inbounds [3 x [3 x float]], ptr %41, i64 0, i64 1
  %43 = load i32, ptr %6, align 4, !tbaa !24
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [3 x float], ptr %42, i64 0, i64 %44
  store float %40, ptr %45, align 4, !tbaa !22
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds [3 x [3 x float]], ptr %46, i64 0, i64 2
  %48 = load i32, ptr %6, align 4, !tbaa !24
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [3 x float], ptr %47, i64 0, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !22
  %52 = load float, ptr %5, align 4, !tbaa !22
  %53 = fmul float %51, %52
  %54 = getelementptr inbounds %class.AccelSensor, ptr %7, i32 0, i32 6
  %55 = getelementptr inbounds [3 x [3 x float]], ptr %54, i64 0, i64 2
  %56 = load i32, ptr %6, align 4, !tbaa !24
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [3 x float], ptr %55, i64 0, i64 %57
  store float %53, ptr %58, align 4, !tbaa !22
  br label %59

59:                                               ; preds = %19
  %60 = load i32, ptr %6, align 4, !tbaa !24
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %6, align 4, !tbaa !24
  br label %15, !llvm.loop !25

62:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !20, i64 104}
!10 = !{!"_ZTS11AccelSensor", !11, i64 0, !19, i64 73, !6, i64 96, !20, i64 104, !7, i64 108, !7, i64 144}
!11 = !{!"_ZTS6Sensor", !12, i64 8, !13, i64 12, !14, i64 16, !12, i64 20, !15, i64 24, !16, i64 32, !15, i64 40, !15, i64 48, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !17, i64 72}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS14__Sensor_State", !7, i64 0}
!14 = !{!"_ZTS15__Sensor_OpMode", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSSt11atomic_flag", !18, i64 0}
!18 = !{!"_ZTSSt18__atomic_flag_base", !16, i64 0}
!19 = !{!"_ZTS22__AccelSensor_Raw_Data", !15, i64 0, !20, i64 8, !20, i64 10, !7, i64 12}
!20 = !{!"short", !7, i64 0}
!21 = !{!11, !12, i64 68}
!22 = !{!23, !23, i64 0}
!23 = !{!"float", !7, i64 0}
!24 = !{!12, !12, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN11AccelSensor20SetCalibrationMatrixERA3_A3_f(ptr nocapture noundef nonnull align 8 dereferenceable(156) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = load i16, ptr %3, align 8, !tbaa !5
  %5 = uitofp i16 %4 to float
  %6 = getelementptr inbounds i8, ptr %0, i64 68
  %7 = load i32, ptr %6, align 4, !tbaa !20
  %8 = uitofp i32 %7 to float
  %9 = fdiv float %5, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 108
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = getelementptr inbounds i8, ptr %0, i64 120
  %13 = getelementptr inbounds i8, ptr %1, i64 24
  %14 = getelementptr inbounds i8, ptr %0, i64 132
  %15 = load float, ptr %1, align 4, !tbaa !21
  %16 = fmul float %9, %15
  store float %16, ptr %10, align 4, !tbaa !21
  %17 = load float, ptr %11, align 4, !tbaa !21
  %18 = fmul float %9, %17
  store float %18, ptr %12, align 8, !tbaa !21
  %19 = load float, ptr %13, align 4, !tbaa !21
  %20 = fmul float %9, %19
  store float %20, ptr %14, align 4, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %1, i64 4
  %22 = load float, ptr %21, align 4, !tbaa !21
  %23 = fmul float %9, %22
  %24 = getelementptr inbounds i8, ptr %0, i64 112
  store float %23, ptr %24, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  %26 = load float, ptr %25, align 4, !tbaa !21
  %27 = fmul float %9, %26
  %28 = getelementptr inbounds i8, ptr %0, i64 124
  store float %27, ptr %28, align 4, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %1, i64 28
  %30 = load float, ptr %29, align 4, !tbaa !21
  %31 = fmul float %9, %30
  %32 = getelementptr inbounds i8, ptr %0, i64 136
  store float %31, ptr %32, align 8, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %1, i64 8
  %34 = load float, ptr %33, align 4, !tbaa !21
  %35 = fmul float %9, %34
  %36 = getelementptr inbounds i8, ptr %0, i64 116
  store float %35, ptr %36, align 4, !tbaa !21
  %37 = getelementptr inbounds i8, ptr %1, i64 20
  %38 = load float, ptr %37, align 4, !tbaa !21
  %39 = fmul float %9, %38
  %40 = getelementptr inbounds i8, ptr %0, i64 128
  store float %39, ptr %40, align 8, !tbaa !21
  %41 = getelementptr inbounds i8, ptr %1, i64 32
  %42 = load float, ptr %41, align 4, !tbaa !21
  %43 = fmul float %9, %42
  %44 = getelementptr inbounds i8, ptr %0, i64 140
  store float %43, ptr %44, align 4, !tbaa !21
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !18, i64 104}
!6 = !{!"_ZTS11AccelSensor", !7, i64 0, !17, i64 73, !19, i64 96, !18, i64 104, !9, i64 108, !9, i64 144}
!7 = !{!"_ZTS6Sensor", !8, i64 8, !11, i64 12, !12, i64 16, !8, i64 20, !13, i64 24, !14, i64 32, !13, i64 40, !13, i64 48, !8, i64 56, !8, i64 60, !8, i64 64, !8, i64 68, !15, i64 72}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS14__Sensor_State", !9, i64 0}
!12 = !{!"_ZTS15__Sensor_OpMode", !9, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!"bool", !9, i64 0}
!15 = !{!"_ZTSSt11atomic_flag", !16, i64 0}
!16 = !{!"_ZTSSt18__atomic_flag_base", !14, i64 0}
!17 = !{!"_ZTS22__AccelSensor_Raw_Data", !13, i64 0, !18, i64 8, !18, i64 10, !9, i64 12}
!18 = !{!"short", !9, i64 0}
!19 = !{!"any pointer", !9, i64 0}
!20 = !{!7, !8, i64 68}
!21 = !{!22, !22, i64 0}
!22 = !{!"float", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass