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

; 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 @arm_quaternion_conjugate_f32(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %69, %3
  %9 = load i32, ptr %7, align 4, !tbaa !9
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = icmp ult i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %72

13:                                               ; preds = %8
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = mul i32 4, %15
  %17 = add i32 %16, 0
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds float, ptr %14, i64 %18
  %20 = load float, ptr %19, align 4, !tbaa !11
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = mul i32 4, %22
  %24 = add i32 %23, 0
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds float, ptr %21, i64 %25
  store float %20, ptr %26, align 4, !tbaa !11
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = mul i32 4, %28
  %30 = add i32 %29, 1
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %27, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !11
  %34 = fneg float %33
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = mul i32 4, %36
  %38 = add i32 %37, 1
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %35, i64 %39
  store float %34, ptr %40, align 4, !tbaa !11
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = mul i32 4, %42
  %44 = add i32 %43, 2
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %41, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !11
  %48 = fneg float %47
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = mul i32 4, %50
  %52 = add i32 %51, 2
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %49, i64 %53
  store float %48, ptr %54, align 4, !tbaa !11
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = mul i32 4, %56
  %58 = add i32 %57, 3
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds float, ptr %55, i64 %59
  %61 = load float, ptr %60, align 4, !tbaa !11
  %62 = fneg float %61
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !9
  %65 = mul i32 4, %64
  %66 = add i32 %65, 3
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %63, i64 %67
  store float %62, ptr %68, align 4, !tbaa !11
  br label %69

69:                                               ; preds = %13
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %7, align 4, !tbaa !9
  br label %8, !llvm.loop !13

72:                                               ; preds = %12
  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

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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(argmem: readwrite) uwtable
define dso_local void @arm_quaternion_conjugate_f32(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %wide.trip.count = zext i32 %2 to i64
  %min.iters.check = icmp ult i32 %2, 20
  br i1 %min.iters.check, label %.lr.ph.preheader36, label %vector.scevcheck

.lr.ph.preheader36:                               ; preds = %middle.block, %vector.memcheck, %vector.scevcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %vector.scevcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.scevcheck:                                 ; preds = %.lr.ph.preheader
  %4 = add nsw i64 %wide.trip.count, -1
  %5 = icmp ugt i64 %4, 4294967295
  %scevgep = getelementptr i8, ptr %1, i64 8
  %mul.result = shl nsw i64 %4, 4
  %6 = getelementptr i8, ptr %scevgep, i64 %mul.result
  %7 = icmp ult ptr %6, %scevgep
  %scevgep20 = getelementptr i8, ptr %1, i64 12
  %mul.result22 = shl nsw i64 %4, 4
  %8 = getelementptr i8, ptr %scevgep20, i64 %mul.result22
  %9 = icmp ult ptr %8, %scevgep20
  %scevgep24 = getelementptr i8, ptr %1, i64 4
  %mul.result26 = shl nsw i64 %4, 4
  %10 = getelementptr i8, ptr %scevgep24, i64 %mul.result26
  %11 = icmp ult ptr %10, %scevgep24
  %mul.result29 = shl nsw i64 %4, 4
  %12 = getelementptr i8, ptr %1, i64 %mul.result29
  %13 = icmp ult ptr %12, %1
  %14 = or i1 %7, %5
  %15 = or i1 %9, %14
  %16 = or i1 %11, %15
  %17 = or i1 %13, %16
  br i1 %17, label %.lr.ph.preheader36, label %vector.memcheck

vector.memcheck:                                  ; preds = %vector.scevcheck
  %18 = shl nuw nsw i64 %wide.trip.count, 4
  %scevgep31 = getelementptr i8, ptr %1, i64 %18
  %scevgep32 = getelementptr i8, ptr %0, i64 %18
  %bound0 = icmp ugt ptr %scevgep32, %1
  %bound1 = icmp ugt ptr %scevgep31, %0
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader36, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 4294967294
  %invariant.gep = getelementptr i8, ptr %1, i64 -12
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %19 = trunc i64 %index to i32
  %20 = shl i32 %19, 2
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds float, ptr %0, i64 %21
  %wide.vec = load <8 x float>, ptr %22, align 4, !tbaa !5
  %strided.vec = shufflevector <8 x float> %wide.vec, <8 x float> poison, <2 x i32> <i32 0, i32 4>
  %strided.vec33 = shufflevector <8 x float> %wide.vec, <8 x float> poison, <2 x i32> <i32 1, i32 5>
  %strided.vec34 = shufflevector <8 x float> %wide.vec, <8 x float> poison, <2 x i32> <i32 2, i32 6>
  %strided.vec35 = shufflevector <8 x float> %wide.vec, <8 x float> poison, <2 x i32> <i32 3, i32 7>
  %23 = fneg <2 x float> %strided.vec33
  %24 = or disjoint i32 %20, 3
  %25 = zext i32 %24 to i64
  %gep = getelementptr float, ptr %invariant.gep, i64 %25
  %26 = shufflevector <2 x float> %strided.vec, <2 x float> %23, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %27 = shufflevector <2 x float> %strided.vec34, <2 x float> %strided.vec35, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %28 = fneg <4 x float> %27
  %interleaved.vec = shufflevector <4 x float> %26, <4 x float> %28, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 1, i32 3, i32 5, i32 7>
  store <8 x float> %interleaved.vec, ptr %gep, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 2
  %29 = icmp eq i64 %index.next, %n.vec
  br i1 %29, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader36

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %3
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader36, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader36 ]
  %30 = trunc nuw i64 %indvars.iv to i32
  %31 = shl i32 %30, 2
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds float, ptr %0, i64 %32
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = getelementptr inbounds float, ptr %1, i64 %32
  store float %34, ptr %35, align 4, !tbaa !5
  %36 = or disjoint i32 %31, 1
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds float, ptr %0, i64 %37
  %39 = load float, ptr %38, align 4, !tbaa !5
  %40 = fneg float %39
  %41 = getelementptr inbounds float, ptr %1, i64 %37
  store float %40, ptr %41, align 4, !tbaa !5
  %42 = or disjoint i32 %31, 2
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %0, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !5
  %46 = fneg float %45
  %47 = getelementptr inbounds float, ptr %1, i64 %43
  store float %46, ptr %47, align 4, !tbaa !5
  %48 = or disjoint i32 %31, 3
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %0, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !5
  %52 = fneg float %51
  %53 = getelementptr inbounds float, ptr %1, i64 %49
  store float %52, ptr %53, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass