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

; 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 }
%struct.__MagSensor_Data = type <{ i64, %union.anon.0 }>
%union.anon.0 = type { [3 x float] }
%struct.anon = type { i32, i32, i32 }
%struct.anon.1 = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN9MagSensor4ReadER16__MagSensor_Data(ptr noundef nonnull align 8 dereferenceable(160) %0, ptr noundef nonnull align 1 dereferenceable(20) %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %7 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %6, i32 0, i32 0
  %8 = load i64, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.__MagSensor_Data, ptr %9, i32 0, i32 0
  store i64 %8, ptr %10, align 1, !tbaa !21
  %11 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %12 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %11, i32 0, i32 2
  %13 = getelementptr inbounds %struct.anon, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 2, !tbaa !23
  %15 = sitofp i32 %14 to float
  %16 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %17 = getelementptr inbounds [3 x [3 x float]], ptr %16, i64 0, i64 0
  %18 = getelementptr inbounds [3 x float], ptr %17, i64 0, i64 0
  %19 = load float, ptr %18, align 8, !tbaa !24
  %20 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %21 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %20, i32 0, i32 2
  %22 = getelementptr inbounds %struct.anon, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 2, !tbaa !23
  %24 = sitofp i32 %23 to float
  %25 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %26 = getelementptr inbounds [3 x [3 x float]], ptr %25, i64 0, i64 1
  %27 = getelementptr inbounds [3 x float], ptr %26, i64 0, i64 0
  %28 = load float, ptr %27, align 4, !tbaa !24
  %29 = fmul float %24, %28
  %30 = call float @llvm.fmuladd.f32(float %15, float %19, float %29)
  %31 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %32 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %31, i32 0, i32 2
  %33 = getelementptr inbounds %struct.anon, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 2, !tbaa !23
  %35 = sitofp i32 %34 to float
  %36 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %37 = getelementptr inbounds [3 x [3 x float]], ptr %36, i64 0, i64 2
  %38 = getelementptr inbounds [3 x float], ptr %37, i64 0, i64 0
  %39 = load float, ptr %38, align 8, !tbaa !24
  %40 = call float @llvm.fmuladd.f32(float %35, float %39, float %30)
  %41 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 5
  %42 = getelementptr inbounds [3 x float], ptr %41, i64 0, i64 0
  %43 = load float, ptr %42, align 4, !tbaa !24
  %44 = fadd float %40, %43
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__MagSensor_Data, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.anon.1, ptr %46, i32 0, i32 0
  store float %44, ptr %47, align 1, !tbaa !23
  %48 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %49 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %48, i32 0, i32 2
  %50 = getelementptr inbounds %struct.anon, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 2, !tbaa !23
  %52 = sitofp i32 %51 to float
  %53 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %54 = getelementptr inbounds [3 x [3 x float]], ptr %53, i64 0, i64 0
  %55 = getelementptr inbounds [3 x float], ptr %54, i64 0, i64 1
  %56 = load float, ptr %55, align 4, !tbaa !24
  %57 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %58 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds %struct.anon, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 2, !tbaa !23
  %61 = sitofp i32 %60 to float
  %62 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %63 = getelementptr inbounds [3 x [3 x float]], ptr %62, i64 0, i64 1
  %64 = getelementptr inbounds [3 x float], ptr %63, i64 0, i64 1
  %65 = load float, ptr %64, align 4, !tbaa !24
  %66 = fmul float %61, %65
  %67 = call float @llvm.fmuladd.f32(float %52, float %56, float %66)
  %68 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %69 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %68, i32 0, i32 2
  %70 = getelementptr inbounds %struct.anon, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 2, !tbaa !23
  %72 = sitofp i32 %71 to float
  %73 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %74 = getelementptr inbounds [3 x [3 x float]], ptr %73, i64 0, i64 2
  %75 = getelementptr inbounds [3 x float], ptr %74, i64 0, i64 1
  %76 = load float, ptr %75, align 4, !tbaa !24
  %77 = call float @llvm.fmuladd.f32(float %72, float %76, float %67)
  %78 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 5
  %79 = getelementptr inbounds [3 x float], ptr %78, i64 0, i64 1
  %80 = load float, ptr %79, align 4, !tbaa !24
  %81 = fadd float %77, %80
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.__MagSensor_Data, ptr %82, i32 0, i32 1
  %84 = getelementptr inbounds %struct.anon.1, ptr %83, i32 0, i32 1
  store float %81, ptr %84, align 1, !tbaa !23
  %85 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %86 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %85, i32 0, i32 2
  %87 = getelementptr inbounds %struct.anon, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 2, !tbaa !23
  %89 = sitofp i32 %88 to float
  %90 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %91 = getelementptr inbounds [3 x [3 x float]], ptr %90, i64 0, i64 0
  %92 = getelementptr inbounds [3 x float], ptr %91, i64 0, i64 2
  %93 = load float, ptr %92, align 8, !tbaa !24
  %94 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %95 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %94, i32 0, i32 2
  %96 = getelementptr inbounds %struct.anon, ptr %95, i32 0, i32 1
  %97 = load i32, ptr %96, align 2, !tbaa !23
  %98 = sitofp i32 %97 to float
  %99 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %100 = getelementptr inbounds [3 x [3 x float]], ptr %99, i64 0, i64 1
  %101 = getelementptr inbounds [3 x float], ptr %100, i64 0, i64 2
  %102 = load float, ptr %101, align 4, !tbaa !24
  %103 = fmul float %98, %102
  %104 = call float @llvm.fmuladd.f32(float %89, float %93, float %103)
  %105 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 3
  %106 = getelementptr inbounds %struct.__MagSensor_Raw_Data, ptr %105, i32 0, i32 2
  %107 = getelementptr inbounds %struct.anon, ptr %106, i32 0, i32 2
  %108 = load i32, ptr %107, align 2, !tbaa !23
  %109 = sitofp i32 %108 to float
  %110 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 4
  %111 = getelementptr inbounds [3 x [3 x float]], ptr %110, i64 0, i64 2
  %112 = getelementptr inbounds [3 x float], ptr %111, i64 0, i64 2
  %113 = load float, ptr %112, align 8, !tbaa !24
  %114 = call float @llvm.fmuladd.f32(float %109, float %113, float %104)
  %115 = getelementptr inbounds %class.MagSensor, ptr %5, i32 0, i32 5
  %116 = getelementptr inbounds [3 x float], ptr %115, i64 0, i64 2
  %117 = load float, ptr %116, align 4, !tbaa !24
  %118 = fadd float %114, %117
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.__MagSensor_Data, ptr %119, i32 0, i32 1
  %121 = getelementptr inbounds %struct.anon.1, ptr %120, i32 0, i32 2
  store float %118, ptr %121, align 1, !tbaa !23
  ret i1 true
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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 speculatable willreturn memory(none) }

!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, !15, i64 84}
!10 = !{!"_ZTS9MagSensor", !11, i64 0, !7, i64 74, !19, i64 80, !20, i64 84, !7, i64 112, !7, i64 148}
!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 = !{!"_ZTS21__MagSensor_Precision", !7, i64 0}
!20 = !{!"_ZTS20__MagSensor_Raw_Data", !15, i64 0, !7, i64 8, !7, i64 14}
!21 = !{!22, !15, i64 0}
!22 = !{!"_ZTS16__MagSensor_Data", !15, i64 0, !7, i64 8}
!23 = !{!7, !7, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"float", !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef zeroext i1 @_ZN9MagSensor4ReadER16__MagSensor_Data(ptr nocapture noundef nonnull readonly align 8 dereferenceable(160) %0, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(20) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 84
  %4 = load i64, ptr %3, align 4, !tbaa !5
  store i64 %4, ptr %1, align 1, !tbaa !19
  %5 = getelementptr inbounds i8, ptr %0, i64 98
  %6 = load i32, ptr %5, align 2, !tbaa !21
  %7 = sitofp i32 %6 to float
  %8 = getelementptr inbounds i8, ptr %0, i64 112
  %9 = load float, ptr %8, align 8, !tbaa !22
  %10 = getelementptr inbounds i8, ptr %0, i64 102
  %11 = load i32, ptr %10, align 2, !tbaa !21
  %12 = sitofp i32 %11 to float
  %13 = getelementptr inbounds i8, ptr %0, i64 124
  %14 = load float, ptr %13, align 4, !tbaa !22
  %15 = fmul float %14, %12
  %16 = tail call float @llvm.fmuladd.f32(float %7, float %9, float %15)
  %17 = getelementptr inbounds i8, ptr %0, i64 106
  %18 = load i32, ptr %17, align 2, !tbaa !21
  %19 = sitofp i32 %18 to float
  %20 = getelementptr inbounds i8, ptr %0, i64 136
  %21 = load float, ptr %20, align 8, !tbaa !22
  %22 = tail call float @llvm.fmuladd.f32(float %19, float %21, float %16)
  %23 = getelementptr inbounds i8, ptr %0, i64 148
  %24 = load float, ptr %23, align 4, !tbaa !22
  %25 = fadd float %22, %24
  %26 = getelementptr inbounds i8, ptr %1, i64 8
  store float %25, ptr %26, align 1, !tbaa !21
  %27 = load i32, ptr %5, align 2, !tbaa !21
  %28 = sitofp i32 %27 to float
  %29 = getelementptr inbounds i8, ptr %0, i64 116
  %30 = load float, ptr %29, align 4, !tbaa !22
  %31 = load i32, ptr %10, align 2, !tbaa !21
  %32 = sitofp i32 %31 to float
  %33 = getelementptr inbounds i8, ptr %0, i64 128
  %34 = load float, ptr %33, align 8, !tbaa !22
  %35 = fmul float %34, %32
  %36 = tail call float @llvm.fmuladd.f32(float %28, float %30, float %35)
  %37 = load i32, ptr %17, align 2, !tbaa !21
  %38 = sitofp i32 %37 to float
  %39 = getelementptr inbounds i8, ptr %0, i64 140
  %40 = load float, ptr %39, align 4, !tbaa !22
  %41 = tail call float @llvm.fmuladd.f32(float %38, float %40, float %36)
  %42 = getelementptr inbounds i8, ptr %0, i64 152
  %43 = load float, ptr %42, align 8, !tbaa !22
  %44 = fadd float %41, %43
  %45 = getelementptr inbounds i8, ptr %1, i64 12
  store float %44, ptr %45, align 1, !tbaa !21
  %46 = load i32, ptr %5, align 2, !tbaa !21
  %47 = sitofp i32 %46 to float
  %48 = getelementptr inbounds i8, ptr %0, i64 120
  %49 = load float, ptr %48, align 8, !tbaa !22
  %50 = load i32, ptr %10, align 2, !tbaa !21
  %51 = sitofp i32 %50 to float
  %52 = getelementptr inbounds i8, ptr %0, i64 132
  %53 = load float, ptr %52, align 4, !tbaa !22
  %54 = fmul float %53, %51
  %55 = tail call float @llvm.fmuladd.f32(float %47, float %49, float %54)
  %56 = load i32, ptr %17, align 2, !tbaa !21
  %57 = sitofp i32 %56 to float
  %58 = getelementptr inbounds i8, ptr %0, i64 144
  %59 = load float, ptr %58, align 8, !tbaa !22
  %60 = tail call float @llvm.fmuladd.f32(float %57, float %59, float %55)
  %61 = getelementptr inbounds i8, ptr %0, i64 156
  %62 = load float, ptr %61, align 4, !tbaa !22
  %63 = fadd float %60, %62
  %64 = getelementptr inbounds i8, ptr %1, i64 16
  store float %63, ptr %64, align 1, !tbaa !21
  ret i1 true
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

!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, !13, i64 84}
!6 = !{!"_ZTS9MagSensor", !7, i64 0, !9, i64 74, !17, i64 80, !18, i64 84, !9, i64 112, !9, i64 148}
!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 = !{!"_ZTS21__MagSensor_Precision", !9, i64 0}
!18 = !{!"_ZTS20__MagSensor_Raw_Data", !13, i64 0, !9, i64 8, !9, i64 14}
!19 = !{!20, !13, i64 0}
!20 = !{!"_ZTS16__MagSensor_Data", !13, i64 0, !9, i64 8}
!21 = !{!9, !9, i64 0}
!22 = !{!23, !23, i64 0}
!23 = !{!"float", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass