; LLVM IR from IOsonata/IOsonata :: src/sensors/accel_sensor.ll/ZN11AccelSensor4ReadER18 (AccelSensor_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.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 }
%struct.__AccelSensor_Data = type <{ i64, %union.anon.0 }>
%union.anon.0 = type { [3 x float] }
%struct.anon = type { i16, i16, i16 }
%struct.anon.1 = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN11AccelSensor4ReadER18__AccelSensor_Data(ptr noundef nonnull align 8 dereferenceable(156) %0, ptr noundef nonnull align 1 dereferenceable(20) %1) unnamed_addr #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = getelementptr inbounds %class.AccelSensor, ptr %6, i32 0, i32 1
  %8 = getelementptr inbounds %struct.__AccelSensor_Raw_Data, ptr %7, i32 0, i32 2
  %9 = load i16, ptr %8, align 1, !tbaa !9
  %10 = zext i16 %9 to i32
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %136

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

136:                                              ; preds = %13, %12
  %137 = load i1, ptr %3, align 1
  ret i1 %137
}

; 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, !20, i64 83}
!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 = !{!10, !15, i64 73}
!22 = !{!23, !15, i64 0}
!23 = !{!"_ZTS18__AccelSensor_Data", !15, i64 0, !7, i64 8}
!24 = !{!7, !7, i64 0}
!25 = !{!26, !26, i64 0}
!26 = !{!"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 @_ZN11AccelSensor4ReadER18__AccelSensor_Data(ptr nocapture noundef nonnull readonly align 8 dereferenceable(156) %0, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(20) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 83
  %4 = load i16, ptr %3, align 1, !tbaa !5
  %5 = icmp ne i16 %4, 0
  br i1 %5, label %6, label %69

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 73
  %8 = load i64, ptr %7, align 1, !tbaa !20
  store i64 %8, ptr %1, align 1, !tbaa !21
  %9 = getelementptr inbounds i8, ptr %0, i64 85
  %10 = load i16, ptr %9, align 1, !tbaa !23
  %11 = sitofp i16 %10 to float
  %12 = getelementptr inbounds i8, ptr %0, i64 108
  %13 = load float, ptr %12, align 4, !tbaa !24
  %14 = getelementptr inbounds i8, ptr %0, i64 87
  %15 = load i16, ptr %14, align 1, !tbaa !23
  %16 = sitofp i16 %15 to float
  %17 = getelementptr inbounds i8, ptr %0, i64 120
  %18 = load float, ptr %17, align 8, !tbaa !24
  %19 = fmul float %18, %16
  %20 = tail call float @llvm.fmuladd.f32(float %11, float %13, float %19)
  %21 = getelementptr inbounds i8, ptr %0, i64 89
  %22 = load i16, ptr %21, align 1, !tbaa !23
  %23 = sitofp i16 %22 to float
  %24 = getelementptr inbounds i8, ptr %0, i64 132
  %25 = load float, ptr %24, align 4, !tbaa !24
  %26 = tail call float @llvm.fmuladd.f32(float %23, float %25, float %20)
  %27 = getelementptr inbounds i8, ptr %0, i64 144
  %28 = load float, ptr %27, align 8, !tbaa !24
  %29 = fadd float %26, %28
  %30 = getelementptr inbounds i8, ptr %1, i64 8
  store float %29, ptr %30, align 1, !tbaa !23
  %31 = load i16, ptr %9, align 1, !tbaa !23
  %32 = sitofp i16 %31 to float
  %33 = getelementptr inbounds i8, ptr %0, i64 112
  %34 = load float, ptr %33, align 8, !tbaa !24
  %35 = load i16, ptr %14, align 1, !tbaa !23
  %36 = sitofp i16 %35 to float
  %37 = getelementptr inbounds i8, ptr %0, i64 124
  %38 = load float, ptr %37, align 4, !tbaa !24
  %39 = fmul float %38, %36
  %40 = tail call float @llvm.fmuladd.f32(float %32, float %34, float %39)
  %41 = load i16, ptr %21, align 1, !tbaa !23
  %42 = sitofp i16 %41 to float
  %43 = getelementptr inbounds i8, ptr %0, i64 136
  %44 = load float, ptr %43, align 8, !tbaa !24
  %45 = tail call float @llvm.fmuladd.f32(float %42, float %44, float %40)
  %46 = getelementptr inbounds i8, ptr %0, i64 148
  %47 = load float, ptr %46, align 4, !tbaa !24
  %48 = fadd float %45, %47
  %49 = getelementptr inbounds i8, ptr %1, i64 12
  store float %48, ptr %49, align 1, !tbaa !23
  %50 = load i16, ptr %9, align 1, !tbaa !23
  %51 = sitofp i16 %50 to float
  %52 = getelementptr inbounds i8, ptr %0, i64 116
  %53 = load float, ptr %52, align 4, !tbaa !24
  %54 = load i16, ptr %14, align 1, !tbaa !23
  %55 = sitofp i16 %54 to float
  %56 = getelementptr inbounds i8, ptr %0, i64 128
  %57 = load float, ptr %56, align 8, !tbaa !24
  %58 = fmul float %57, %55
  %59 = tail call float @llvm.fmuladd.f32(float %51, float %53, float %58)
  %60 = load i16, ptr %21, align 1, !tbaa !23
  %61 = sitofp i16 %60 to float
  %62 = getelementptr inbounds i8, ptr %0, i64 140
  %63 = load float, ptr %62, align 4, !tbaa !24
  %64 = tail call float @llvm.fmuladd.f32(float %61, float %63, float %59)
  %65 = getelementptr inbounds i8, ptr %0, i64 152
  %66 = load float, ptr %65, align 8, !tbaa !24
  %67 = fadd float %64, %66
  %68 = getelementptr inbounds i8, ptr %1, i64 16
  store float %67, ptr %68, align 1, !tbaa !23
  br label %69

69:                                               ; preds = %2, %6
  ret i1 %5
}

; 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, !18, i64 83}
!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 = !{!6, !13, i64 73}
!21 = !{!22, !13, i64 0}
!22 = !{!"_ZTS18__AccelSensor_Data", !13, i64 0, !9, i64 8}
!23 = !{!9, !9, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"float", !9, i64 0}


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