; LLVM IR from MRPT/mrpt :: 3rdparty/xspublic/xstypes (xsmatrix3x3)

; 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.XsMatrix3x3 = type { %struct.XsMatrix, [9 x double] }
%struct.XsMatrix = type { ptr, i64, i64, i64, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @XsMatrix3x3_assign(ptr noundef %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %58

11:                                               ; preds = %3
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %17, label %14

14:                                               ; preds = %11
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = icmp eq i64 %15, 3
  br i1 %16, label %17, label %23

17:                                               ; preds = %14, %11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.XsMatrix3x3, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %struct.XsMatrix, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %22, i64 72, i1 false)
  br label %57

23:                                               ; preds = %14
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %53, %23
  %25 = load i64, ptr %7, align 8, !tbaa !9
  %26 = icmp ult i64 %25, 3
  br i1 %26, label %27, label %56

27:                                               ; preds = %24
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %49, %27
  %29 = load i64, ptr %8, align 8, !tbaa !9
  %30 = icmp ult i64 %29, 3
  br i1 %30, label %31, label %52

31:                                               ; preds = %28
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i64, ptr %7, align 8, !tbaa !9
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = mul i64 %33, %34
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = add i64 %35, %36
  %38 = getelementptr inbounds double, ptr %32, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !14
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.XsMatrix3x3, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.XsMatrix, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = mul i64 %44, 3
  %46 = load i64, ptr %8, align 8, !tbaa !9
  %47 = add i64 %45, %46
  %48 = getelementptr inbounds double, ptr %43, i64 %47
  store double %39, ptr %48, align 8, !tbaa !14
  br label %49

49:                                               ; preds = %31
  %50 = load i64, ptr %8, align 8, !tbaa !9
  %51 = add i64 %50, 1
  store i64 %51, ptr %8, align 8, !tbaa !9
  br label %28, !llvm.loop !16

52:                                               ; preds = %28
  br label %53

53:                                               ; preds = %52
  %54 = load i64, ptr %7, align 8, !tbaa !9
  %55 = add i64 %54, 1
  store i64 %55, ptr %7, align 8, !tbaa !9
  br label %24, !llvm.loop !18

56:                                               ; preds = %24
  br label %57

57:                                               ; preds = %56, %17
  br label %58

58:                                               ; preds = %57, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"XsMatrix3x3", !13, i64 0, !7, i64 40}
!13 = !{!"XsMatrix", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @XsMatrix3x3_assign(ptr nocapture noundef readonly %0, ptr noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.loopexit, label %4

4:                                                ; preds = %3
  switch i64 %2, label %.preheader19 [
    i64 3, label %31
    i64 0, label %31
  ]

.preheader19:                                     ; preds = %4
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = load double, ptr %1, align 8, !tbaa !12
  store double %6, ptr %5, align 8, !tbaa !12
  %7 = getelementptr i8, ptr %1, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  store double %8, ptr %9, align 8, !tbaa !12
  %10 = getelementptr i8, ptr %1, i64 16
  %11 = load double, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %5, i64 16
  store double %11, ptr %12, align 8, !tbaa !12
  %13 = getelementptr double, ptr %1, i64 %2
  %14 = getelementptr inbounds i8, ptr %5, i64 24
  %15 = load double, ptr %13, align 8, !tbaa !12
  store double %15, ptr %14, align 8, !tbaa !12
  %16 = getelementptr i8, ptr %13, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %5, i64 32
  store double %17, ptr %18, align 8, !tbaa !12
  %19 = getelementptr i8, ptr %13, i64 16
  %20 = load double, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %5, i64 40
  store double %20, ptr %21, align 8, !tbaa !12
  %.idx = shl i64 %2, 4
  %22 = getelementptr i8, ptr %1, i64 %.idx
  %23 = getelementptr inbounds i8, ptr %5, i64 48
  %24 = load double, ptr %22, align 8, !tbaa !12
  store double %24, ptr %23, align 8, !tbaa !12
  %25 = getelementptr i8, ptr %22, i64 8
  %26 = load double, ptr %25, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %5, i64 56
  store double %26, ptr %27, align 8, !tbaa !12
  %28 = getelementptr i8, ptr %22, i64 16
  %29 = load double, ptr %28, align 8, !tbaa !12
  %30 = getelementptr inbounds i8, ptr %5, i64 64
  store double %29, ptr %30, align 8, !tbaa !12
  br label %.loopexit

31:                                               ; preds = %4, %4
  %32 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %32, ptr noundef nonnull align 8 dereferenceable(72) %1, i64 72, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader19, %31, %3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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, !8, i64 0}
!6 = !{!"XsMatrix3x3", !7, i64 0, !9, i64 40}
!7 = !{!"XsMatrix", !8, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass