; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/BSP/Components/cs43l22 (cs43l22)

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

@OutputDev = external dso_local global i8, align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @cs43l22_Resume(i16 noundef zeroext %0) #0 {
  %2 = alloca i16, align 2
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i16 %0, ptr %2, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store volatile i32 0, ptr %4, align 4, !tbaa !9
  %5 = load i16, ptr %2, align 2, !tbaa !5
  %6 = call i32 @cs43l22_SetMute(i16 noundef zeroext %5, i32 noundef 0)
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = add i32 %7, %6
  store i32 %8, ptr %3, align 4, !tbaa !9
  store volatile i32 0, ptr %4, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %13, %1
  %10 = load volatile i32, ptr %4, align 4, !tbaa !9
  %11 = icmp ult i32 %10, 255
  br i1 %11, label %12, label %16

12:                                               ; preds = %9
  br label %13

13:                                               ; preds = %12
  %14 = load volatile i32, ptr %4, align 4, !tbaa !9
  %15 = add i32 %14, 1
  store volatile i32 %15, ptr %4, align 4, !tbaa !9
  br label %9, !llvm.loop !11

16:                                               ; preds = %9
  %17 = load i16, ptr %2, align 2, !tbaa !5
  %18 = trunc i16 %17 to i8
  %19 = load volatile i8, ptr @OutputDev, align 1, !tbaa !13
  %20 = call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %18, i8 noundef zeroext 4, i8 noundef zeroext %19)
  %21 = zext i8 %20 to i32
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = add i32 %22, %21
  store i32 %23, ptr %3, align 4, !tbaa !9
  %24 = load i16, ptr %2, align 2, !tbaa !5
  %25 = trunc i16 %24 to i8
  %26 = call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %25, i8 noundef zeroext 2, i8 noundef zeroext -98)
  %27 = zext i8 %26 to i32
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = add i32 %28, %27
  store i32 %29, ptr %3, align 4, !tbaa !9
  %30 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %30
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @cs43l22_SetMute(i16 noundef zeroext, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @CODEC_IO_Write(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #0

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

attributes #0 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !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"

@OutputDev = external dso_local global i8, align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @cs43l22_Resume(i16 noundef zeroext %0) local_unnamed_addr #0 {
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2)
  store volatile i32 0, ptr %2, align 4, !tbaa !5
  %3 = tail call i32 @cs43l22_SetMute(i16 noundef zeroext %0, i32 noundef 0)
  store volatile i32 0, ptr %2, align 4, !tbaa !5
  %.0..0..0..0.8 = load volatile i32, ptr %2, align 4, !tbaa !5
  %4 = icmp ult i32 %.0..0..0..0.8, 255
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.0..0..0..0.1 = load volatile i32, ptr %2, align 4, !tbaa !5
  %5 = add i32 %.0..0..0..0.1, 1
  store volatile i32 %5, ptr %2, align 4, !tbaa !5
  %.0..0..0..0. = load volatile i32, ptr %2, align 4, !tbaa !5
  %6 = icmp ult i32 %.0..0..0..0., 255
  br i1 %6, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %1
  %7 = trunc i16 %0 to i8
  %8 = load volatile i8, ptr @OutputDev, align 1, !tbaa !11
  %9 = tail call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %7, i8 noundef zeroext 4, i8 noundef zeroext %8)
  %10 = zext i8 %9 to i32
  %11 = add i32 %3, %10
  %12 = tail call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %7, i8 noundef zeroext 2, i8 noundef zeroext -98)
  %13 = zext i8 %12 to i32
  %14 = add i32 %11, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2)
  ret i32 %14
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @cs43l22_SetMute(i16 noundef zeroext, i32 noundef) 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

; Function Attrs: nounwind uwtable
declare hidden zeroext i8 @CODEC_IO_Write(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

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

attributes #0 = { 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) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass