; LLVM IR from IOsonata/IOsonata :: src/sensors/mag_sensor.ll (ZN9MagSensor11SensitivityERA3_t)

; 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.MagSensor = type { %class.Sensor.base, [3 x i16], i32, %struct.__MagSensor_Raw_Data, [3 x [3 x float]], [3 x float], %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.__MagSensor_Raw_Data = type <{ i64, [3 x i16], %union.anon }>
%union.anon = type { [3 x i32] }
%class.Device = type { ptr, i8, i32, ptr, ptr, i64, i8, ptr, i8, i32 }

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

7:                                                ; preds = %139, %2
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 3
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %142

11:                                               ; preds = %7
  %12 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 4
  %13 = getelementptr inbounds [3 x [3 x float]], ptr %12, i64 0, i64 0
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [3 x float], ptr %13, i64 0, i64 %15
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [3 x i16], ptr %18, i64 0, i64 %20
  %22 = load i16, ptr %21, align 2, !tbaa !13
  %23 = zext i16 %22 to i32
  %24 = sitofp i32 %23 to float
  %25 = fmul float %17, %24
  %26 = fpext float %25 to double
  %27 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 1
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [3 x i16], ptr %27, i64 0, i64 %29
  %31 = load i16, ptr %30, align 2, !tbaa !13
  %32 = zext i16 %31 to i32
  %33 = sitofp i32 %32 to double
  %34 = fmul double %33, 1.000000e+03
  %35 = fdiv double %26, %34
  %36 = fptrunc double %35 to float
  %37 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 4
  %38 = getelementptr inbounds [3 x [3 x float]], ptr %37, i64 0, i64 0
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [3 x float], ptr %38, i64 0, i64 %40
  store float %36, ptr %41, align 4, !tbaa !11
  %42 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 4
  %43 = getelementptr inbounds [3 x [3 x float]], ptr %42, i64 0, i64 1
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [3 x float], ptr %43, i64 0, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !11
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [3 x i16], ptr %48, i64 0, i64 %50
  %52 = load i16, ptr %51, align 2, !tbaa !13
  %53 = zext i16 %52 to i32
  %54 = sitofp i32 %53 to float
  %55 = fmul float %47, %54
  %56 = fpext float %55 to double
  %57 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 1
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [3 x i16], ptr %57, i64 0, i64 %59
  %61 = load i16, ptr %60, align 2, !tbaa !13
  %62 = zext i16 %61 to i32
  %63 = sitofp i32 %62 to double
  %64 = fmul double %63, 1.000000e+03
  %65 = fdiv double %56, %64
  %66 = fptrunc double %65 to float
  %67 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 4
  %68 = getelementptr inbounds [3 x [3 x float]], ptr %67, i64 0, i64 1
  %69 = load i32, ptr %5, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [3 x float], ptr %68, i64 0, i64 %70
  store float %66, ptr %71, align 4, !tbaa !11
  %72 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 4
  %73 = getelementptr inbounds [3 x [3 x float]], ptr %72, i64 0, i64 2
  %74 = load i32, ptr %5, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [3 x float], ptr %73, i64 0, i64 %75
  %77 = load float, ptr %76, align 4, !tbaa !11
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = load i32, ptr %5, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [3 x i16], ptr %78, i64 0, i64 %80
  %82 = load i16, ptr %81, align 2, !tbaa !13
  %83 = zext i16 %82 to i32
  %84 = sitofp i32 %83 to float
  %85 = fmul float %77, %84
  %86 = fpext float %85 to double
  %87 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 1
  %88 = load i32, ptr %5, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [3 x i16], ptr %87, i64 0, i64 %89
  %91 = load i16, ptr %90, align 2, !tbaa !13
  %92 = zext i16 %91 to i32
  %93 = sitofp i32 %92 to double
  %94 = fmul double %93, 1.000000e+03
  %95 = fdiv double %86, %94
  %96 = fptrunc double %95 to float
  %97 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 4
  %98 = getelementptr inbounds [3 x [3 x float]], ptr %97, i64 0, i64 2
  %99 = load i32, ptr %5, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [3 x float], ptr %98, i64 0, i64 %100
  store float %96, ptr %101, align 4, !tbaa !11
  %102 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 5
  %103 = load i32, ptr %5, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [3 x float], ptr %102, i64 0, i64 %104
  %106 = load float, ptr %105, align 4, !tbaa !11
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = load i32, ptr %5, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [3 x i16], ptr %107, i64 0, i64 %109
  %111 = load i16, ptr %110, align 2, !tbaa !13
  %112 = zext i16 %111 to i32
  %113 = sitofp i32 %112 to float
  %114 = fmul float %106, %113
  %115 = fpext float %114 to double
  %116 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 1
  %117 = load i32, ptr %5, align 4, !tbaa !9
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [3 x i16], ptr %116, i64 0, i64 %118
  %120 = load i16, ptr %119, align 2, !tbaa !13
  %121 = zext i16 %120 to i32
  %122 = sitofp i32 %121 to double
  %123 = fmul double %122, 1.000000e+03
  %124 = fdiv double %115, %123
  %125 = fptrunc double %124 to float
  %126 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 5
  %127 = load i32, ptr %5, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [3 x float], ptr %126, i64 0, i64 %128
  store float %125, ptr %129, align 4, !tbaa !11
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = load i32, ptr %5, align 4, !tbaa !9
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [3 x i16], ptr %130, i64 0, i64 %132
  %134 = load i16, ptr %133, align 2, !tbaa !13
  %135 = getelementptr inbounds %class.MagSensor, ptr %6, i32 0, i32 1
  %136 = load i32, ptr %5, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [3 x i16], ptr %135, i64 0, i64 %137
  store i16 %134, ptr %138, align 2, !tbaa !13
  br label %139

139:                                              ; preds = %11
  %140 = load i32, ptr %5, align 4, !tbaa !9
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %5, align 4, !tbaa !9
  br label %7, !llvm.loop !15

142:                                              ; preds = %10
  ret void
}

; 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

attributes #0 = { 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 #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 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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 @_ZN9MagSensor11SensitivityERA3_t(ptr nocapture noundef nonnull align 8 dereferenceable(160) %0, ptr nocapture noundef nonnull readonly align 2 dereferenceable(6) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 112
  %4 = getelementptr inbounds i8, ptr %0, i64 74
  %5 = load i16, ptr %1, align 2, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 2
  %7 = getelementptr inbounds i8, ptr %0, i64 76
  %8 = load <4 x i16>, ptr %4, align 2
  store i16 %5, ptr %4, align 2, !tbaa !5
  %9 = load i16, ptr %6, align 2, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 128
  store i16 %9, ptr %7, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 4
  %12 = load i16, ptr %11, align 2, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 78
  %14 = load <8 x i16>, ptr %13, align 2
  %15 = shufflevector <8 x i16> %14, <8 x i16> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>
  %16 = load <4 x float>, ptr %3, align 8, !tbaa !9
  %17 = load <4 x float>, ptr %10, align 8, !tbaa !9
  %18 = getelementptr inbounds i8, ptr %0, i64 144
  %19 = insertelement <4 x i16> poison, i16 %12, i64 0
  %20 = insertelement <4 x i16> %19, i16 %5, i64 1
  %21 = insertelement <4 x i16> %20, i16 %9, i64 2
  %22 = shufflevector <4 x i16> %21, <4 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %23 = uitofp <4 x i16> %22 to <4 x float>
  %24 = shufflevector <4 x i16> %15, <4 x i16> %8, <4 x i32> <i32 0, i32 4, i32 5, i32 poison>
  %25 = shufflevector <4 x i16> %24, <4 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %26 = uitofp <4 x i16> %25 to <4 x double>
  %27 = fmul <4 x double> %26, <double 1.000000e+03, double 1.000000e+03, double 1.000000e+03, double 1.000000e+03>
  %28 = shufflevector <4 x float> %23, <4 x float> poison, <4 x i32> <i32 1, i32 2, i32 0, i32 poison>
  %29 = shufflevector <4 x float> %28, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %30 = fmul <4 x float> %16, %29
  %31 = fpext <4 x float> %30 to <4 x double>
  %32 = shufflevector <4 x double> %27, <4 x double> poison, <4 x i32> <i32 1, i32 2, i32 0, i32 poison>
  %33 = shufflevector <4 x double> %32, <4 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %34 = fdiv <4 x double> %31, %33
  %35 = fptrunc <4 x double> %34 to <4 x float>
  store <4 x float> %35, ptr %3, align 8, !tbaa !9
  %36 = shufflevector <4 x float> %23, <4 x float> poison, <4 x i32> <i32 2, i32 0, i32 1, i32 poison>
  %37 = shufflevector <4 x float> %36, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %38 = fmul <4 x float> %17, %37
  %39 = fpext <4 x float> %38 to <4 x double>
  %40 = shufflevector <4 x double> %27, <4 x double> poison, <4 x i32> <i32 2, i32 0, i32 1, i32 poison>
  %41 = shufflevector <4 x double> %40, <4 x double> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %42 = fdiv <4 x double> %39, %41
  %43 = fptrunc <4 x double> %42 to <4 x float>
  store <4 x float> %43, ptr %10, align 8, !tbaa !9
  %44 = load <4 x float>, ptr %18, align 8, !tbaa !9
  %45 = fmul <4 x float> %44, %23
  %46 = fpext <4 x float> %45 to <4 x double>
  %47 = fdiv <4 x double> %46, %27
  %48 = fptrunc <4 x double> %47 to <4 x float>
  store <4 x float> %48, ptr %18, align 8, !tbaa !9
  store i16 %12, ptr %13, align 2, !tbaa !5
  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, !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,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass