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

; Function Attrs: nounwind uwtable
define dso_local i32 @cs43l22_SetVolume(i16 noundef zeroext %0, i8 noundef zeroext %1) #0 {
  %3 = alloca i16, align 2
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  store i16 %0, ptr %3, align 2, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #2
  %7 = load i8, ptr %4, align 1, !tbaa !9
  %8 = zext i8 %7 to i32
  %9 = icmp sgt i32 %8, 100
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %18

11:                                               ; preds = %2
  %12 = load i8, ptr %4, align 1, !tbaa !9
  %13 = zext i8 %12 to i32
  %14 = mul nsw i32 %13, 255
  %15 = sdiv i32 %14, 100
  %16 = trunc i32 %15 to i8
  %17 = zext i8 %16 to i32
  br label %18

18:                                               ; preds = %11, %10
  %19 = phi i32 [ 255, %10 ], [ %17, %11 ]
  %20 = trunc i32 %19 to i8
  store i8 %20, ptr %6, align 1, !tbaa !9
  %21 = load i8, ptr %6, align 1, !tbaa !9
  %22 = zext i8 %21 to i32
  %23 = icmp sgt i32 %22, 230
  br i1 %23, label %24, label %45

24:                                               ; preds = %18
  %25 = load i16, ptr %3, align 2, !tbaa !5
  %26 = trunc i16 %25 to i8
  %27 = load i8, ptr %6, align 1, !tbaa !9
  %28 = zext i8 %27 to i32
  %29 = sub nsw i32 %28, 231
  %30 = trunc i32 %29 to i8
  %31 = call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %26, i8 noundef zeroext 32, i8 noundef zeroext %30)
  %32 = zext i8 %31 to i32
  %33 = load i32, ptr %5, align 4, !tbaa !10
  %34 = add i32 %33, %32
  store i32 %34, ptr %5, align 4, !tbaa !10
  %35 = load i16, ptr %3, align 2, !tbaa !5
  %36 = trunc i16 %35 to i8
  %37 = load i8, ptr %6, align 1, !tbaa !9
  %38 = zext i8 %37 to i32
  %39 = sub nsw i32 %38, 231
  %40 = trunc i32 %39 to i8
  %41 = call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %36, i8 noundef zeroext 33, i8 noundef zeroext %40)
  %42 = zext i8 %41 to i32
  %43 = load i32, ptr %5, align 4, !tbaa !10
  %44 = add i32 %43, %42
  store i32 %44, ptr %5, align 4, !tbaa !10
  br label %66

45:                                               ; preds = %18
  %46 = load i16, ptr %3, align 2, !tbaa !5
  %47 = trunc i16 %46 to i8
  %48 = load i8, ptr %6, align 1, !tbaa !9
  %49 = zext i8 %48 to i32
  %50 = add nsw i32 %49, 25
  %51 = trunc i32 %50 to i8
  %52 = call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %47, i8 noundef zeroext 32, i8 noundef zeroext %51)
  %53 = zext i8 %52 to i32
  %54 = load i32, ptr %5, align 4, !tbaa !10
  %55 = add i32 %54, %53
  store i32 %55, ptr %5, align 4, !tbaa !10
  %56 = load i16, ptr %3, align 2, !tbaa !5
  %57 = trunc i16 %56 to i8
  %58 = load i8, ptr %6, align 1, !tbaa !9
  %59 = zext i8 %58 to i32
  %60 = add nsw i32 %59, 25
  %61 = trunc i32 %60 to i8
  %62 = call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %57, i8 noundef zeroext 33, i8 noundef zeroext %61)
  %63 = zext i8 %62 to i32
  %64 = load i32, ptr %5, align 4, !tbaa !10
  %65 = add i32 %64, %63
  store i32 %65, ptr %5, align 4, !tbaa !10
  br label %66

66:                                               ; preds = %45, %24
  %67 = load i32, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %67
}

; 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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: nounwind uwtable
define dso_local range(i32 0, 511) i32 @cs43l22_SetVolume(i16 noundef zeroext %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = icmp ugt i8 %1, 100
  br i1 %3, label %.thread, label %4

4:                                                ; preds = %2
  %5 = zext nneg i8 %1 to i16
  %6 = mul nuw nsw i16 %5, 255
  %7 = udiv i16 %6, 100
  %8 = trunc i16 %7 to i8
  %9 = add i8 %8, 25
  br label %.thread

.thread:                                          ; preds = %4, %2
  %.sink24 = phi i8 [ 24, %2 ], [ %9, %4 ]
  %10 = trunc i16 %0 to i8
  %11 = tail call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %10, i8 noundef zeroext 32, i8 noundef zeroext %.sink24)
  %12 = zext i8 %11 to i32
  %13 = tail call zeroext i8 @CODEC_IO_Write(i8 noundef zeroext %10, i8 noundef zeroext 33, i8 noundef zeroext %.sink24)
  %14 = zext i8 %13 to i32
  %15 = add nuw nsw i32 %14, %12
  ret i32 %15
}

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

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

!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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass