; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/MatrixFunctions (arm_mat_trans_f64)

; 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.arm_matrix_instance_f64 = type { i16, i16, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_mat_trans_f64(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca i16, align 2
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.arm_matrix_instance_f64, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %16, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.arm_matrix_instance_f64, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #2
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.arm_matrix_instance_f64, ptr %20, i32 0, i32 0
  %22 = load i16, ptr %21, align 8, !tbaa !12
  store i16 %22, ptr %8, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #2
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.arm_matrix_instance_f64, ptr %23, i32 0, i32 1
  %25 = load i16, ptr %24, align 2, !tbaa !14
  store i16 %25, ptr %9, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %26 = load i16, ptr %8, align 2, !tbaa !13
  %27 = zext i16 %26 to i64
  store i64 %27, ptr %11, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  store i64 0, ptr %12, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  br label %28

28:                                               ; preds = %54, %2
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i64, ptr %12, align 8, !tbaa !15
  %31 = getelementptr inbounds double, ptr %29, i64 %30
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load i16, ptr %9, align 2, !tbaa !13
  %33 = zext i16 %32 to i64
  store i64 %33, ptr %10, align 8, !tbaa !15
  br label %34

34:                                               ; preds = %37, %28
  %35 = load i64, ptr %10, align 8, !tbaa !15
  %36 = icmp ugt i64 %35, 0
  br i1 %36, label %37, label %49

37:                                               ; preds = %34
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i32 1
  store ptr %39, ptr %5, align 8, !tbaa !5
  %40 = load double, ptr %38, align 8, !tbaa !17
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  store double %40, ptr %41, align 8, !tbaa !17
  %42 = load i16, ptr %8, align 2, !tbaa !13
  %43 = zext i16 %42 to i32
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = sext i32 %43 to i64
  %46 = getelementptr inbounds double, ptr %44, i64 %45
  store ptr %46, ptr %7, align 8, !tbaa !5
  %47 = load i64, ptr %10, align 8, !tbaa !15
  %48 = add i64 %47, -1
  store i64 %48, ptr %10, align 8, !tbaa !15
  br label %34, !llvm.loop !19

49:                                               ; preds = %34
  %50 = load i64, ptr %12, align 8, !tbaa !15
  %51 = add i64 %50, 1
  store i64 %51, ptr %12, align 8, !tbaa !15
  %52 = load i64, ptr %11, align 8, !tbaa !15
  %53 = add i64 %52, -1
  store i64 %53, ptr %11, align 8, !tbaa !15
  br label %54

54:                                               ; preds = %49
  %55 = load i64, ptr %11, align 8, !tbaa !15
  %56 = icmp ugt i64 %55, 0
  br i1 %56, label %28, label %57, !llvm.loop !21

57:                                               ; preds = %54
  store i32 0, ptr %13, align 4, !tbaa !22
  %58 = load i32, ptr %13, align 4, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret i32 %58
}

; 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

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"", !11, i64 0, !11, i64 2, !6, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 2}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = !{!23, !23, i64 0}
!23 = !{!"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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @arm_mat_trans_f64(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load i16, ptr %0, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i16, ptr %6, align 2, !tbaa !12
  %8 = zext i16 %5 to i64
  %9 = zext i16 %7 to i64
  %.not23 = icmp eq i16 %7, 0
  br i1 %.not23, label %.split28.us, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %xtraiter = and i64 %9, 7
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  %12 = icmp ult i16 %7, 8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %.018 = phi i64 [ %44, %._crit_edge ], [ %8, %.lr.ph.preheader ]
  %.017 = phi i64 [ %43, %._crit_edge ], [ 0, %.lr.ph.preheader ]
  %.0 = phi ptr [ %.lcssa, %._crit_edge ], [ %11, %.lr.ph.preheader ]
  %13 = getelementptr inbounds double, ptr %4, i64 %.017
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %.lr.ph, %.prol.preheader
  %.126.prol = phi ptr [ %14, %.prol.preheader ], [ %.0, %.lr.ph ]
  %.01925.prol = phi i64 [ %17, %.prol.preheader ], [ %9, %.lr.ph ]
  %.02024.prol = phi ptr [ %16, %.prol.preheader ], [ %13, %.lr.ph ]
  %prol.iter = phi i64 [ %prol.iter.next, %.prol.preheader ], [ 0, %.lr.ph ]
  %14 = getelementptr inbounds i8, ptr %.126.prol, i64 8
  %15 = load double, ptr %.126.prol, align 8, !tbaa !13
  store double %15, ptr %.02024.prol, align 8, !tbaa !13
  %16 = getelementptr inbounds double, ptr %.02024.prol, i64 %8
  %17 = add nsw i64 %.01925.prol, -1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %.prol.preheader, !llvm.loop !15

.prol.loopexit:                                   ; preds = %.prol.preheader, %.lr.ph
  %.lcssa.unr = phi ptr [ poison, %.lr.ph ], [ %14, %.prol.preheader ]
  %.126.unr = phi ptr [ %.0, %.lr.ph ], [ %14, %.prol.preheader ]
  %.01925.unr = phi i64 [ %9, %.lr.ph ], [ %17, %.prol.preheader ]
  %.02024.unr = phi ptr [ %13, %.lr.ph ], [ %16, %.prol.preheader ]
  br i1 %12, label %._crit_edge, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.prol.loopexit, %.lr.ph.new
  %.126 = phi ptr [ %39, %.lr.ph.new ], [ %.126.unr, %.prol.loopexit ]
  %.01925 = phi i64 [ %42, %.lr.ph.new ], [ %.01925.unr, %.prol.loopexit ]
  %.02024 = phi ptr [ %41, %.lr.ph.new ], [ %.02024.unr, %.prol.loopexit ]
  %18 = getelementptr inbounds i8, ptr %.126, i64 8
  %19 = load double, ptr %.126, align 8, !tbaa !13
  store double %19, ptr %.02024, align 8, !tbaa !13
  %20 = getelementptr inbounds double, ptr %.02024, i64 %8
  %21 = getelementptr inbounds i8, ptr %.126, i64 16
  %22 = load double, ptr %18, align 8, !tbaa !13
  store double %22, ptr %20, align 8, !tbaa !13
  %23 = getelementptr inbounds double, ptr %20, i64 %8
  %24 = getelementptr inbounds i8, ptr %.126, i64 24
  %25 = load double, ptr %21, align 8, !tbaa !13
  store double %25, ptr %23, align 8, !tbaa !13
  %26 = getelementptr inbounds double, ptr %23, i64 %8
  %27 = getelementptr inbounds i8, ptr %.126, i64 32
  %28 = load double, ptr %24, align 8, !tbaa !13
  store double %28, ptr %26, align 8, !tbaa !13
  %29 = getelementptr inbounds double, ptr %26, i64 %8
  %30 = getelementptr inbounds i8, ptr %.126, i64 40
  %31 = load double, ptr %27, align 8, !tbaa !13
  store double %31, ptr %29, align 8, !tbaa !13
  %32 = getelementptr inbounds double, ptr %29, i64 %8
  %33 = getelementptr inbounds i8, ptr %.126, i64 48
  %34 = load double, ptr %30, align 8, !tbaa !13
  store double %34, ptr %32, align 8, !tbaa !13
  %35 = getelementptr inbounds double, ptr %32, i64 %8
  %36 = getelementptr inbounds i8, ptr %.126, i64 56
  %37 = load double, ptr %33, align 8, !tbaa !13
  store double %37, ptr %35, align 8, !tbaa !13
  %38 = getelementptr inbounds double, ptr %35, i64 %8
  %39 = getelementptr inbounds i8, ptr %.126, i64 64
  %40 = load double, ptr %36, align 8, !tbaa !13
  store double %40, ptr %38, align 8, !tbaa !13
  %41 = getelementptr inbounds double, ptr %38, i64 %8
  %42 = add nsw i64 %.01925, -8
  %.not.7 = icmp eq i64 %42, 0
  br i1 %.not.7, label %._crit_edge, label %.lr.ph.new, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph.new, %.prol.loopexit
  %.lcssa = phi ptr [ %.lcssa.unr, %.prol.loopexit ], [ %39, %.lr.ph.new ]
  %43 = add i64 %.017, 1
  %44 = add i64 %.018, -1
  %.not22 = icmp eq i64 %44, 0
  br i1 %.not22, label %.split28.us, label %.lr.ph, !llvm.loop !19

.split28.us:                                      ; preds = %._crit_edge, %2
  ret i32 0
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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)"}
!5 = !{!6, !10, i64 8}
!6 = !{!"", !7, i64 0, !7, i64 2, !10, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 2}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass