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

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

17:                                               ; preds = %72, %3
  %18 = load i32, ptr %8, align 4, !tbaa !24
  %19 = icmp slt i32 %18, 3
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %17
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds [3 x [3 x float]], ptr %22, i64 0, i64 0
  %24 = load i32, ptr %8, align 4, !tbaa !24
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [3 x float], ptr %23, i64 0, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !22
  %28 = load float, ptr %7, align 4, !tbaa !22
  %29 = fmul float %27, %28
  %30 = getelementptr inbounds %class.AccelSensor, ptr %9, i32 0, i32 6
  %31 = getelementptr inbounds [3 x [3 x float]], ptr %30, i64 0, i64 0
  %32 = load i32, ptr %8, align 4, !tbaa !24
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [3 x float], ptr %31, i64 0, i64 %33
  store float %29, ptr %34, align 4, !tbaa !22
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds [3 x [3 x float]], ptr %35, i64 0, i64 1
  %37 = load i32, ptr %8, align 4, !tbaa !24
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [3 x float], ptr %36, i64 0, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !22
  %41 = load float, ptr %7, align 4, !tbaa !22
  %42 = fmul float %40, %41
  %43 = getelementptr inbounds %class.AccelSensor, ptr %9, i32 0, i32 6
  %44 = getelementptr inbounds [3 x [3 x float]], ptr %43, i64 0, i64 1
  %45 = load i32, ptr %8, align 4, !tbaa !24
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [3 x float], ptr %44, i64 0, i64 %46
  store float %42, ptr %47, align 4, !tbaa !22
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds [3 x [3 x float]], ptr %48, i64 0, i64 2
  %50 = load i32, ptr %8, align 4, !tbaa !24
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [3 x float], ptr %49, i64 0, i64 %51
  %53 = load float, ptr %52, align 4, !tbaa !22
  %54 = load float, ptr %7, align 4, !tbaa !22
  %55 = fmul float %53, %54
  %56 = getelementptr inbounds %class.AccelSensor, ptr %9, i32 0, i32 6
  %57 = getelementptr inbounds [3 x [3 x float]], ptr %56, i64 0, i64 2
  %58 = load i32, ptr %8, align 4, !tbaa !24
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [3 x float], ptr %57, i64 0, i64 %59
  store float %55, ptr %60, align 4, !tbaa !22
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load i32, ptr %8, align 4, !tbaa !24
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [3 x float], ptr %61, i64 0, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !22
  %66 = load float, ptr %7, align 4, !tbaa !22
  %67 = fmul float %65, %66
  %68 = getelementptr inbounds %class.AccelSensor, ptr %9, i32 0, i32 7
  %69 = load i32, ptr %8, align 4, !tbaa !24
  %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 !22
  br label %72

72:                                               ; preds = %21
  %73 = load i32, ptr %8, align 4, !tbaa !24
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %8, align 4, !tbaa !24
  br label %17, !llvm.loop !25

75:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #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 @_ZN11AccelSensor14SetCalibrationERA3_A3_fRS0_(ptr nocapture noundef nonnull align 8 dereferenceable(156) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(36) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 104
  %5 = load i16, ptr %4, align 8, !tbaa !5
  %6 = uitofp i16 %5 to float
  %7 = getelementptr inbounds i8, ptr %0, i64 68
  %8 = load i32, ptr %7, align 4, !tbaa !20
  %9 = uitofp i32 %8 to float
  %10 = fdiv float %6, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 108
  %12 = getelementptr inbounds i8, ptr %1, i64 12
  %13 = getelementptr inbounds i8, ptr %0, i64 120
  %14 = getelementptr inbounds i8, ptr %1, i64 24
  %15 = getelementptr inbounds i8, ptr %0, i64 132
  %16 = getelementptr inbounds i8, ptr %0, i64 144
  %17 = load float, ptr %1, align 4, !tbaa !21
  %18 = fmul float %10, %17
  store float %18, ptr %11, align 4, !tbaa !21
  %19 = load float, ptr %12, align 4, !tbaa !21
  %20 = fmul float %10, %19
  store float %20, ptr %13, align 8, !tbaa !21
  %21 = load float, ptr %14, align 4, !tbaa !21
  %22 = fmul float %10, %21
  store float %22, ptr %15, align 4, !tbaa !21
  %23 = load float, ptr %2, align 4, !tbaa !21
  %24 = fmul float %10, %23
  store float %24, ptr %16, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %1, i64 4
  %26 = load float, ptr %25, align 4, !tbaa !21
  %27 = fmul float %10, %26
  %28 = getelementptr inbounds i8, ptr %0, i64 112
  store float %27, ptr %28, align 8, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %1, i64 16
  %30 = load float, ptr %29, align 4, !tbaa !21
  %31 = fmul float %10, %30
  %32 = getelementptr inbounds i8, ptr %0, i64 124
  store float %31, ptr %32, align 4, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %1, i64 28
  %34 = load float, ptr %33, align 4, !tbaa !21
  %35 = fmul float %10, %34
  %36 = getelementptr inbounds i8, ptr %0, i64 136
  store float %35, ptr %36, align 8, !tbaa !21
  %37 = getelementptr inbounds i8, ptr %2, i64 4
  %38 = load float, ptr %37, align 4, !tbaa !21
  %39 = fmul float %10, %38
  %40 = getelementptr inbounds i8, ptr %0, i64 148
  store float %39, ptr %40, align 4, !tbaa !21
  %41 = getelementptr inbounds i8, ptr %1, i64 8
  %42 = load float, ptr %41, align 4, !tbaa !21
  %43 = fmul float %10, %42
  %44 = getelementptr inbounds i8, ptr %0, i64 116
  store float %43, ptr %44, align 4, !tbaa !21
  %45 = getelementptr inbounds i8, ptr %1, i64 20
  %46 = load float, ptr %45, align 4, !tbaa !21
  %47 = fmul float %10, %46
  %48 = getelementptr inbounds i8, ptr %0, i64 128
  store float %47, ptr %48, align 8, !tbaa !21
  %49 = getelementptr inbounds i8, ptr %1, i64 32
  %50 = load float, ptr %49, align 4, !tbaa !21
  %51 = fmul float %10, %50
  %52 = getelementptr inbounds i8, ptr %0, i64 140
  store float %51, ptr %52, align 4, !tbaa !21
  %53 = getelementptr inbounds i8, ptr %2, i64 8
  %54 = load float, ptr %53, align 4, !tbaa !21
  %55 = fmul float %10, %54
  %56 = getelementptr inbounds i8, ptr %0, i64 152
  store float %55, ptr %56, align 8, !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