; LLVM IR from IOsonata/IOsonata :: ARM/Nordic/exemples/BlueIOThingy (BlueIOTms)

; 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"

%struct.__GyroSensor_Data = type <{ i64, %union.anon.0 }>
%union.anon.0 = type { [3 x float] }
%struct.ble_tms_raw_t = type { %struct.ble_tms_raw_accel_t, %struct.ble_tms_raw_gyro_t, %struct.ble_tms_raw_compass_t }
%struct.ble_tms_raw_accel_t = type { i16, i16, i16 }
%struct.ble_tms_raw_gyro_t = type { i16, i16, i16 }
%struct.ble_tms_raw_compass_t = type { i16, i16, i16 }
%struct.__AccelSensor_Data = type <{ i64, %union.anon.1 }>
%union.anon.1 = type { [3 x float] }
%struct.anon.2 = type { float, float, float }
%struct.anon = type { float, float, float }
%struct.__MagSensor_Data = type <{ i64, %union.anon.3 }>
%union.anon.3 = type { [3 x float] }
%struct.anon.4 = type { float, float, float }
%struct.__Bt_Service = type <{ i32, ptr, i16, %struct.__Bt_Uuid, i8, ptr, i32, ptr, ptr, ptr, ptr }>
%struct.__Bt_Uuid = type <{ i8, %union.anon }>
%union.anon = type { i32 }
%struct.__Bt_Characteristic = type { i16, i16, i32, ptr, ptr, ptr, ptr, ptr, ptr, i16, i8, i8, i8, i16, i16, i16, i16, i16, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z18GetImuSrvcInstancev() #0

declare zeroext i1 @isConnected() #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare zeroext i1 @BtAppNotify(ptr noundef, ptr noundef, i16 noundef zeroext) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14ImuRawDataSendR18__AccelSensor_Data17__GyroSensor_DataR16__MagSensor_Data(ptr noundef nonnull align 1 dereferenceable(20) %0, ptr noundef byval(%struct.__GyroSensor_Data) align 8 %1, ptr noundef nonnull align 1 dereferenceable(20) %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.ble_tms_raw_t, align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  %8 = call zeroext i1 @isConnected()
  %9 = zext i1 %8 to i32
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  br label %92

12:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 18, ptr %6) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.__AccelSensor_Data, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds %struct.anon.2, ptr %14, i32 0, i32 0
  %16 = load float, ptr %15, align 1, !tbaa !9
  %17 = fdiv float %16, 2.560000e+02
  %18 = fptosi float %17 to i16
  %19 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 0
  %20 = getelementptr inbounds %struct.ble_tms_raw_accel_t, ptr %19, i32 0, i32 0
  store i16 %18, ptr %20, align 1, !tbaa !10
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.__AccelSensor_Data, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.anon.2, ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 1, !tbaa !9
  %25 = fdiv float %24, 2.560000e+02
  %26 = fptosi float %25 to i16
  %27 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 0
  %28 = getelementptr inbounds %struct.ble_tms_raw_accel_t, ptr %27, i32 0, i32 1
  store i16 %26, ptr %28, align 1, !tbaa !16
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.__AccelSensor_Data, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds %struct.anon.2, ptr %30, i32 0, i32 2
  %32 = load float, ptr %31, align 1, !tbaa !9
  %33 = fdiv float %32, 2.560000e+02
  %34 = fptosi float %33 to i16
  %35 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 0
  %36 = getelementptr inbounds %struct.ble_tms_raw_accel_t, ptr %35, i32 0, i32 2
  store i16 %34, ptr %36, align 1, !tbaa !17
  %37 = getelementptr inbounds %struct.__GyroSensor_Data, ptr %1, i32 0, i32 1
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 0
  %39 = load float, ptr %38, align 8, !tbaa !9
  %40 = fdiv float %39, 2.560000e+02
  %41 = fptosi float %40 to i16
  %42 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 1
  %43 = getelementptr inbounds %struct.ble_tms_raw_gyro_t, ptr %42, i32 0, i32 0
  store i16 %41, ptr %43, align 1, !tbaa !18
  %44 = getelementptr inbounds %struct.__GyroSensor_Data, ptr %1, i32 0, i32 1
  %45 = getelementptr inbounds %struct.anon, ptr %44, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = fdiv float %46, 2.560000e+02
  %48 = fptosi float %47 to i16
  %49 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 1
  %50 = getelementptr inbounds %struct.ble_tms_raw_gyro_t, ptr %49, i32 0, i32 1
  store i16 %48, ptr %50, align 1, !tbaa !19
  %51 = getelementptr inbounds %struct.__GyroSensor_Data, ptr %1, i32 0, i32 1
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 2
  %53 = load float, ptr %52, align 8, !tbaa !9
  %54 = fdiv float %53, 2.560000e+02
  %55 = fptosi float %54 to i16
  %56 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 1
  %57 = getelementptr inbounds %struct.ble_tms_raw_gyro_t, ptr %56, i32 0, i32 2
  store i16 %55, ptr %57, align 1, !tbaa !20
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.__MagSensor_Data, ptr %58, i32 0, i32 1
  %60 = getelementptr inbounds %struct.anon.4, ptr %59, i32 0, i32 0
  %61 = load float, ptr %60, align 1, !tbaa !9
  %62 = fdiv float %61, 2.560000e+02
  %63 = fptosi float %62 to i16
  %64 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 2
  %65 = getelementptr inbounds %struct.ble_tms_raw_compass_t, ptr %64, i32 0, i32 0
  store i16 %63, ptr %65, align 1, !tbaa !21
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.__MagSensor_Data, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds %struct.anon.4, ptr %67, i32 0, i32 1
  %69 = load float, ptr %68, align 1, !tbaa !9
  %70 = fdiv float %69, 2.560000e+02
  %71 = fptosi float %70 to i16
  %72 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 2
  %73 = getelementptr inbounds %struct.ble_tms_raw_compass_t, ptr %72, i32 0, i32 1
  store i16 %71, ptr %73, align 1, !tbaa !22
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.__MagSensor_Data, ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds %struct.anon.4, ptr %75, i32 0, i32 2
  %77 = load float, ptr %76, align 1, !tbaa !9
  %78 = fdiv float %77, 2.560000e+02
  %79 = fptosi float %78 to i16
  %80 = getelementptr inbounds %struct.ble_tms_raw_t, ptr %6, i32 0, i32 2
  %81 = getelementptr inbounds %struct.ble_tms_raw_compass_t, ptr %80, i32 0, i32 2
  store i16 %79, ptr %81, align 1, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %82 = call noundef ptr @_Z18GetImuSrvcInstancev()
  %83 = getelementptr inbounds %struct.__Bt_Service, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 4, !tbaa !24
  %85 = getelementptr inbounds %struct.__Bt_Characteristic, ptr %84, i64 5
  %86 = call zeroext i1 @BtAppNotify(ptr noundef %85, ptr noundef %6, i16 noundef zeroext 18)
  %87 = zext i1 %86 to i32
  store i32 %87, ptr %7, align 4, !tbaa !29
  %88 = load i32, ptr %7, align 4, !tbaa !29
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %91

90:                                               ; preds = %12
  br label %91

91:                                               ; preds = %90, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 18, ptr %6) #4
  br label %92

92:                                               ; preds = %91, %11
  ret void
}

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !13, i64 0}
!11 = !{!"_ZTS13ble_tms_raw_t", !12, i64 0, !14, i64 6, !15, i64 12}
!12 = !{!"_ZTS19ble_tms_raw_accel_t", !13, i64 0, !13, i64 2, !13, i64 4}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_ZTS18ble_tms_raw_gyro_t", !13, i64 0, !13, i64 2, !13, i64 4}
!15 = !{!"_ZTS21ble_tms_raw_compass_t", !13, i64 0, !13, i64 2, !13, i64 4}
!16 = !{!11, !13, i64 2}
!17 = !{!11, !13, i64 4}
!18 = !{!11, !13, i64 6}
!19 = !{!11, !13, i64 8}
!20 = !{!11, !13, i64 10}
!21 = !{!11, !13, i64 12}
!22 = !{!11, !13, i64 14}
!23 = !{!11, !13, i64 16}
!24 = !{!25, !6, i64 4}
!25 = !{!"_ZTS12__Bt_Service", !26, i64 0, !6, i64 4, !13, i64 12, !27, i64 14, !6, i64 20, !26, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!26 = !{!"int", !7, i64 0}
!27 = !{!"_ZTS9__Bt_Uuid", !7, i64 0, !28, i64 0, !7, i64 1}
!28 = !{!"_ZTS14__Bt_Uuid_Type", !7, i64 0}
!29 = !{!26, !26, 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"

%struct.__GyroSensor_Data = type <{ i64, %union.anon.0 }>
%union.anon.0 = type { [3 x float] }
%struct.ble_tms_raw_t = type { %struct.ble_tms_raw_accel_t, %struct.ble_tms_raw_gyro_t, %struct.ble_tms_raw_compass_t }
%struct.ble_tms_raw_accel_t = type { i16, i16, i16 }
%struct.ble_tms_raw_gyro_t = type { i16, i16, i16 }
%struct.ble_tms_raw_compass_t = type { i16, i16, i16 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z18GetImuSrvcInstancev() local_unnamed_addr #0

declare zeroext i1 @isConnected() local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare zeroext i1 @BtAppNotify(ptr noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14ImuRawDataSendR18__AccelSensor_Data17__GyroSensor_DataR16__MagSensor_Data(ptr nocapture noundef nonnull readonly align 1 dereferenceable(20) %0, ptr nocapture noundef readonly byval(%struct.__GyroSensor_Data) align 8 %1, ptr nocapture noundef nonnull readonly align 1 dereferenceable(20) %2) local_unnamed_addr #3 {
  %4 = alloca %struct.ble_tms_raw_t, align 16
  %5 = tail call zeroext i1 @isConnected()
  br i1 %5, label %6, label %36

6:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 18, ptr nonnull %4) #4
  %7 = load <4 x float>, ptr %0, align 1
  %8 = shufflevector <4 x float> %7, <4 x float> poison, <8 x i32> <i32 2, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load <2 x float>, ptr %9, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load float, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 12
  %14 = load <2 x float>, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %2, i64 8
  %16 = load <2 x float>, ptr %15, align 1, !tbaa !5
  %17 = shufflevector <2 x float> %10, <2 x float> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
  %18 = shufflevector <8 x float> %8, <8 x float> %17, <8 x i32> <i32 0, i32 8, i32 9, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
  %19 = insertelement <8 x float> %18, float %12, i64 3
  %20 = shufflevector <2 x float> %14, <2 x float> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
  %21 = shufflevector <8 x float> %19, <8 x float> %20, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 poison, i32 poison>
  %22 = shufflevector <2 x float> %16, <2 x float> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
  %23 = shufflevector <8 x float> %21, <8 x float> %22, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 8, i32 9>
  %24 = fmul <8 x float> %23, <float 3.906250e-03, float 3.906250e-03, float 3.906250e-03, float 3.906250e-03, float 3.906250e-03, float 3.906250e-03, float 3.906250e-03, float 3.906250e-03>
  %25 = fptosi <8 x float> %24 to <8 x i16>
  store <8 x i16> %25, ptr %4, align 16, !tbaa !8
  %26 = getelementptr inbounds i8, ptr %2, i64 16
  %27 = load float, ptr %26, align 1, !tbaa !5
  %28 = fmul float %27, 3.906250e-03
  %29 = fptosi float %28 to i16
  %30 = getelementptr inbounds i8, ptr %4, i64 16
  store i16 %29, ptr %30, align 16, !tbaa !10
  %31 = tail call noundef ptr @_Z18GetImuSrvcInstancev()
  %32 = getelementptr inbounds i8, ptr %31, i64 4
  %33 = load ptr, ptr %32, align 4, !tbaa !15
  %34 = getelementptr inbounds i8, ptr %33, i64 400
  %35 = call zeroext i1 @BtAppNotify(ptr noundef nonnull %34, ptr noundef nonnull %4, i16 noundef zeroext 18)
  call void @llvm.lifetime.end.p0(i64 18, ptr nonnull %4) #4
  br label %36

36:                                               ; preds = %3, %6
  ret void
}

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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress 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 #4 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}
!10 = !{!11, !9, i64 16}
!11 = !{!"_ZTS13ble_tms_raw_t", !12, i64 0, !13, i64 6, !14, i64 12}
!12 = !{!"_ZTS19ble_tms_raw_accel_t", !9, i64 0, !9, i64 2, !9, i64 4}
!13 = !{!"_ZTS18ble_tms_raw_gyro_t", !9, i64 0, !9, i64 2, !9, i64 4}
!14 = !{!"_ZTS21ble_tms_raw_compass_t", !9, i64 0, !9, i64 2, !9, i64 4}
!15 = !{!16, !18, i64 4}
!16 = !{!"_ZTS12__Bt_Service", !17, i64 0, !18, i64 4, !9, i64 12, !19, i64 14, !18, i64 20, !17, i64 28, !18, i64 32, !18, i64 40, !18, i64 48, !18, i64 56}
!17 = !{!"int", !6, i64 0}
!18 = !{!"any pointer", !6, i64 0}
!19 = !{!"_ZTS9__Bt_Uuid", !6, i64 0, !20, i64 0, !6, i64 1}
!20 = !{!"_ZTS14__Bt_Uuid_Type", !6, i64 0}


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