; LLVM IR from IOsonata/IOsonata :: ARM/Nordic/exemples/BlueIOThingy/BlueIOTes.ll (Z20EnvSrvcNotifPressuref)

; 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.ble_tes_pressure_t = type <{ i32, i8 }>
%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 @_Z18GetEnvSrvcInstancev() #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z20EnvSrvcNotifPressuref(float noundef %0) #3 {
  %2 = alloca float, align 4
  %3 = alloca %struct.ble_tes_pressure_t, align 1
  %4 = alloca ptr, align 8
  store float %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 5, ptr %3) #4
  %5 = load float, ptr %2, align 4, !tbaa !5
  %6 = fptosi float %5 to i32
  %7 = getelementptr inbounds %struct.ble_tes_pressure_t, ptr %3, i32 0, i32 0
  store i32 %6, ptr %7, align 1, !tbaa !9
  %8 = load float, ptr %2, align 4, !tbaa !5
  %9 = getelementptr inbounds %struct.ble_tes_pressure_t, ptr %3, i32 0, i32 0
  %10 = load i32, ptr %9, align 1, !tbaa !9
  %11 = sitofp i32 %10 to float
  %12 = fsub float %8, %11
  %13 = fpext float %12 to double
  %14 = fmul double %13, 1.000000e+02
  %15 = fptoui double %14 to i8
  %16 = getelementptr inbounds %struct.ble_tes_pressure_t, ptr %3, i32 0, i32 1
  store i8 %15, ptr %16, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %17 = call noundef ptr @_Z18GetEnvSrvcInstancev()
  store ptr %17, ptr %4, align 8, !tbaa !13
  %18 = load ptr, ptr %4, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.__Bt_Service, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 4, !tbaa !15
  %21 = getelementptr inbounds %struct.__Bt_Characteristic, ptr %20, i64 1
  %22 = call zeroext i1 @BtAppNotify(ptr noundef %21, ptr noundef %3, i16 noundef zeroext 5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 5, ptr %3) #4
  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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 #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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS18ble_tes_pressure_t", !11, i64 0, !7, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !7, i64 4}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !14, i64 4}
!16 = !{!"_ZTS12__Bt_Service", !11, i64 0, !14, i64 4, !17, i64 12, !18, i64 14, !14, i64 20, !11, i64 28, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56}
!17 = !{!"short", !7, i64 0}
!18 = !{!"_ZTS9__Bt_Uuid", !7, i64 0, !19, i64 0, !7, i64 1}
!19 = !{!"_ZTS14__Bt_Uuid_Type", !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"

%struct.ble_tes_pressure_t = type <{ i32, i8 }>

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z20EnvSrvcNotifPressuref(float noundef %0) local_unnamed_addr #3 {
  %2 = alloca %struct.ble_tes_pressure_t, align 4
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #4
  %3 = fptosi float %0 to i32
  store i32 %3, ptr %2, align 4, !tbaa !5
  %4 = sitofp i32 %3 to float
  %5 = fsub float %0, %4
  %6 = fpext float %5 to double
  %7 = fmul double %6, 1.000000e+02
  %8 = fptoui double %7 to i8
  %9 = getelementptr inbounds i8, ptr %2, i64 4
  store i8 %8, ptr %9, align 4, !tbaa !10
  %10 = tail call noundef ptr @_Z18GetEnvSrvcInstancev()
  %11 = getelementptr inbounds i8, ptr %10, i64 4
  %12 = load ptr, ptr %11, align 4, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %12, i64 80
  %14 = call zeroext i1 @BtAppNotify(ptr noundef nonnull %13, ptr noundef nonnull %2, i16 noundef zeroext 5)
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #4
  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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 #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, !7, i64 0}
!6 = !{!"_ZTS18ble_tes_pressure_t", !7, i64 0, !8, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !8, i64 4}
!11 = !{!12, !13, i64 4}
!12 = !{!"_ZTS12__Bt_Service", !7, i64 0, !13, i64 4, !14, i64 12, !15, i64 14, !13, i64 20, !7, i64 28, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!"_ZTS9__Bt_Uuid", !8, i64 0, !16, i64 0, !8, i64 1}
!16 = !{!"_ZTS14__Bt_Uuid_Type", !8, i64 0}


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