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

; 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 void @LIS302DL_ReadACC(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca [6 x i8], align 1
  %4 = alloca [3 x i16], align 2
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 6, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 6, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 18, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !9
  call void @ACCELERO_IO_Read(ptr noundef %6, i8 noundef zeroext 32, i16 noundef zeroext 1)
  %8 = getelementptr inbounds [6 x i8], ptr %3, i64 0, i64 0
  call void @ACCELERO_IO_Read(ptr noundef %8, i8 noundef zeroext 41, i16 noundef zeroext 6)
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %9

9:                                                ; preds = %24, %1
  %10 = load i8, ptr %7, align 1, !tbaa !9
  %11 = zext i8 %10 to i32
  %12 = icmp slt i32 %11, 3
  br i1 %12, label %13, label %27

13:                                               ; preds = %9
  %14 = load i8, ptr %7, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = mul nsw i32 2, %15
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [6 x i8], ptr %3, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = sext i8 %19 to i16
  %21 = load i8, ptr %7, align 1, !tbaa !9
  %22 = zext i8 %21 to i64
  %23 = getelementptr inbounds [3 x i16], ptr %4, i64 0, i64 %22
  store i16 %20, ptr %23, align 2, !tbaa !10
  br label %24

24:                                               ; preds = %13
  %25 = load i8, ptr %7, align 1, !tbaa !9
  %26 = add i8 %25, 1
  store i8 %26, ptr %7, align 1, !tbaa !9
  br label %9, !llvm.loop !12

27:                                               ; preds = %9
  %28 = load i8, ptr %6, align 1, !tbaa !9
  %29 = zext i8 %28 to i32
  %30 = and i32 %29, 32
  switch i32 %30, label %33 [
    i32 0, label %31
    i32 32, label %32
  ]

31:                                               ; preds = %27
  store i8 18, ptr %5, align 1, !tbaa !9
  br label %34

32:                                               ; preds = %27
  store i8 72, ptr %5, align 1, !tbaa !9
  br label %34

33:                                               ; preds = %27
  br label %34

34:                                               ; preds = %33, %32, %31
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %35

35:                                               ; preds = %53, %34
  %36 = load i8, ptr %7, align 1, !tbaa !9
  %37 = zext i8 %36 to i32
  %38 = icmp slt i32 %37, 3
  br i1 %38, label %39, label %56

39:                                               ; preds = %35
  %40 = load i8, ptr %7, align 1, !tbaa !9
  %41 = zext i8 %40 to i64
  %42 = getelementptr inbounds [3 x i16], ptr %4, i64 0, i64 %41
  %43 = load i16, ptr %42, align 2, !tbaa !10
  %44 = sext i16 %43 to i32
  %45 = load i8, ptr %5, align 1, !tbaa !9
  %46 = zext i8 %45 to i32
  %47 = mul nsw i32 %44, %46
  %48 = trunc i32 %47 to i16
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = load i8, ptr %7, align 1, !tbaa !9
  %51 = zext i8 %50 to i64
  %52 = getelementptr inbounds i16, ptr %49, i64 %51
  store i16 %48, ptr %52, align 2, !tbaa !10
  br label %53

53:                                               ; preds = %39
  %54 = load i8, ptr %7, align 1, !tbaa !9
  %55 = add i8 %54, 1
  store i8 %55, ptr %7, align 1, !tbaa !9
  br label %35, !llvm.loop !14

56:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 6, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 6, ptr %3) #3
  ret void
}

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

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

declare void @ACCELERO_IO_Read(ptr noundef, i8 noundef zeroext, i16 noundef zeroext) #2

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 = { "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 = { 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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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 void @LIS302DL_ReadACC(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  %2 = alloca [6 x i8], align 1
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 6, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #3
  call void @ACCELERO_IO_Read(ptr noundef nonnull %3, i8 noundef zeroext 32, i16 noundef zeroext 1) #3
  call void @ACCELERO_IO_Read(ptr noundef nonnull %2, i8 noundef zeroext 41, i16 noundef zeroext 6) #3
  %4 = load i8, ptr %2, align 1, !tbaa !5
  %5 = sext i8 %4 to i16
  %6 = getelementptr inbounds i8, ptr %2, i64 2
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = sext i8 %7 to i16
  %9 = getelementptr inbounds i8, ptr %2, i64 4
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = sext i8 %10 to i16
  %12 = load i8, ptr %3, align 1, !tbaa !5
  %13 = and i8 %12, 32
  %switch = icmp eq i8 %13, 0
  %. = select i1 %switch, i16 18, i16 72
  %14 = mul nsw i16 %., %5
  store i16 %14, ptr %0, align 2, !tbaa !8
  %15 = mul nsw i16 %., %8
  %16 = getelementptr inbounds i8, ptr %0, i64 2
  store i16 %15, ptr %16, align 2, !tbaa !8
  %17 = mul nsw i16 %., %11
  %18 = getelementptr inbounds i8, ptr %0, i64 4
  store i16 %17, ptr %18, align 2, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %2) #3
  ret void
}

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

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

declare void @ACCELERO_IO_Read(ptr noundef, i8 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

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) }
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 = { 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/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass