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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_mat_cmplx_trans_q15(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 i16, align 2
  %8 = alloca i16, align 2
  %9 = alloca i16, align 2
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = 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
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.arm_matrix_instance_q15, ptr %13, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.arm_matrix_instance_q15, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.arm_matrix_instance_q15, ptr %19, i32 0, i32 0
  %21 = load i16, ptr %20, align 8, !tbaa !12
  store i16 %21, ptr %7, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #2
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.arm_matrix_instance_q15, ptr %22, i32 0, i32 1
  %24 = load i16, ptr %23, align 2, !tbaa !14
  store i16 %24, ptr %8, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #2
  %25 = load i16, ptr %7, align 2, !tbaa !13
  store i16 %25, ptr %10, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #2
  store i16 0, ptr %11, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  br label %26

26:                                               ; preds = %64, %2
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.arm_matrix_instance_q15, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = load i16, ptr %11, align 2, !tbaa !13
  %31 = zext i16 %30 to i32
  %32 = mul nsw i32 2, %31
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i16, ptr %29, i64 %33
  store ptr %34, ptr %6, align 8, !tbaa !5
  %35 = load i16, ptr %8, align 2, !tbaa !13
  store i16 %35, ptr %9, align 2, !tbaa !13
  br label %36

36:                                               ; preds = %40, %26
  %37 = load i16, ptr %9, align 2, !tbaa !13
  %38 = zext i16 %37 to i32
  %39 = icmp ugt i32 %38, 0
  br i1 %39, label %40, label %59

40:                                               ; preds = %36
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds i16, ptr %41, i32 1
  store ptr %42, ptr %5, align 8, !tbaa !5
  %43 = load i16, ptr %41, align 2, !tbaa !13
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds i16, ptr %44, i64 0
  store i16 %43, ptr %45, align 2, !tbaa !13
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds i16, ptr %46, i32 1
  store ptr %47, ptr %5, align 8, !tbaa !5
  %48 = load i16, ptr %46, align 2, !tbaa !13
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds i16, ptr %49, i64 1
  store i16 %48, ptr %50, align 2, !tbaa !13
  %51 = load i16, ptr %7, align 2, !tbaa !13
  %52 = zext i16 %51 to i32
  %53 = mul nsw i32 2, %52
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = sext i32 %53 to i64
  %56 = getelementptr inbounds i16, ptr %54, i64 %55
  store ptr %56, ptr %6, align 8, !tbaa !5
  %57 = load i16, ptr %9, align 2, !tbaa !13
  %58 = add i16 %57, -1
  store i16 %58, ptr %9, align 2, !tbaa !13
  br label %36, !llvm.loop !15

59:                                               ; preds = %36
  %60 = load i16, ptr %11, align 2, !tbaa !13
  %61 = add i16 %60, 1
  store i16 %61, ptr %11, align 2, !tbaa !13
  %62 = load i16, ptr %10, align 2, !tbaa !13
  %63 = add i16 %62, -1
  store i16 %63, ptr %10, align 2, !tbaa !13
  br label %64

64:                                               ; preds = %59
  %65 = load i16, ptr %10, align 2, !tbaa !13
  %66 = zext i16 %65 to i32
  %67 = icmp ugt i32 %66, 0
  br i1 %67, label %26, label %68, !llvm.loop !17

68:                                               ; preds = %64
  store i32 0, ptr %12, align 4, !tbaa !18
  %69 = load i32, ptr %12, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 2, 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 2, 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 %69
}

; 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 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!19, !19, i64 0}
!19 = !{!"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_cmplx_trans_q15(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i16, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 2
  %6 = load i16, ptr %5, align 2, !tbaa !11
  %7 = load ptr, ptr %3, align 8, !tbaa !12
  %.not25 = icmp eq i16 %6, 0
  %8 = zext i16 %4 to i64
  %.idx24 = shl nuw nsw i64 %8, 2
  br i1 %.not25, label %.split30.us, label %.lr.ph.preheader

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %._crit_edge ]
  %.020 = phi i16 [ %4, %.lr.ph.preheader ], [ %45, %._crit_edge ]
  %.0 = phi ptr [ %10, %.lr.ph.preheader ], [ %.lcssa, %._crit_edge ]
  %.idx = shl nuw nsw i64 %indvars.iv, 2
  %12 = getelementptr inbounds i8, ptr %7, i64 %.idx
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %.lr.ph, %.prol.preheader
  %.128.prol = phi ptr [ %15, %.prol.preheader ], [ %.0, %.lr.ph ]
  %.02127.prol = phi i16 [ %19, %.prol.preheader ], [ %6, %.lr.ph ]
  %.02226.prol = phi ptr [ %18, %.prol.preheader ], [ %12, %.lr.ph ]
  %prol.iter = phi i16 [ %prol.iter.next, %.prol.preheader ], [ 0, %.lr.ph ]
  %13 = getelementptr inbounds i8, ptr %.128.prol, i64 2
  %14 = load i16, ptr %.128.prol, align 2, !tbaa !13
  store i16 %14, ptr %.02226.prol, align 2, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %.128.prol, i64 4
  %16 = load i16, ptr %13, align 2, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %.02226.prol, i64 2
  store i16 %16, ptr %17, align 2, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %.02226.prol, i64 %.idx24
  %19 = add i16 %.02127.prol, -1
  %prol.iter.next = add i16 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i16 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %.prol.preheader, !llvm.loop !14

.prol.loopexit:                                   ; preds = %.prol.preheader, %.lr.ph
  %.lcssa.unr = phi ptr [ poison, %.lr.ph ], [ %15, %.prol.preheader ]
  %.128.unr = phi ptr [ %.0, %.lr.ph ], [ %15, %.prol.preheader ]
  %.02127.unr = phi i16 [ %6, %.lr.ph ], [ %19, %.prol.preheader ]
  %.02226.unr = phi ptr [ %12, %.lr.ph ], [ %18, %.prol.preheader ]
  br i1 %11, label %._crit_edge, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.prol.loopexit, %.lr.ph.new
  %.128 = phi ptr [ %40, %.lr.ph.new ], [ %.128.unr, %.prol.loopexit ]
  %.02127 = phi i16 [ %44, %.lr.ph.new ], [ %.02127.unr, %.prol.loopexit ]
  %.02226 = phi ptr [ %43, %.lr.ph.new ], [ %.02226.unr, %.prol.loopexit ]
  %20 = getelementptr inbounds i8, ptr %.128, i64 2
  %21 = load i16, ptr %.128, align 2, !tbaa !13
  store i16 %21, ptr %.02226, align 2, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %.128, i64 4
  %23 = load i16, ptr %20, align 2, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %.02226, i64 2
  store i16 %23, ptr %24, align 2, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %.02226, i64 %.idx24
  %26 = getelementptr inbounds i8, ptr %.128, i64 6
  %27 = load i16, ptr %22, align 2, !tbaa !13
  store i16 %27, ptr %25, align 2, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %.128, i64 8
  %29 = load i16, ptr %26, align 2, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %25, i64 2
  store i16 %29, ptr %30, align 2, !tbaa !13
  %31 = getelementptr inbounds i8, ptr %25, i64 %.idx24
  %32 = getelementptr inbounds i8, ptr %.128, i64 10
  %33 = load i16, ptr %28, align 2, !tbaa !13
  store i16 %33, ptr %31, align 2, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %.128, i64 12
  %35 = load i16, ptr %32, align 2, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %31, i64 2
  store i16 %35, ptr %36, align 2, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %31, i64 %.idx24
  %38 = getelementptr inbounds i8, ptr %.128, i64 14
  %39 = load i16, ptr %34, align 2, !tbaa !13
  store i16 %39, ptr %37, align 2, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %.128, i64 16
  %41 = load i16, ptr %38, align 2, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %37, i64 2
  store i16 %41, ptr %42, align 2, !tbaa !13
  %43 = getelementptr inbounds i8, ptr %37, i64 %.idx24
  %44 = add i16 %.02127, -4
  %.not.3 = icmp eq i16 %44, 0
  br i1 %.not.3, label %._crit_edge, label %.lr.ph.new, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph.new, %.prol.loopexit
  %.lcssa = phi ptr [ %.lcssa.unr, %.prol.loopexit ], [ %40, %.lr.ph.new ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %45 = add i16 %.020, -1
  %.not23 = icmp eq i16 %45, 0
  br i1 %.not23, label %.split30.us, label %.lr.ph, !llvm.loop !18

.split30.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, !7, i64 0}
!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 2}
!12 = !{!6, !10, i64 8}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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