; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_MatNd)

; 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._MatNd = type { ptr, i32, i32, i32, i8 }

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @MatNd_create(i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @MatNd_rwPinv2(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._MatNd, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !9
  store i32 %16, ptr %9, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._MatNd, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !14
  store i32 %19, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  %20 = load i32, ptr %9, align 4, !tbaa !13
  %21 = load i32, ptr %10, align 4, !tbaa !13
  %22 = mul nsw i32 %20, %21
  %23 = load i32, ptr %10, align 4, !tbaa !13
  %24 = load i32, ptr %10, align 4, !tbaa !13
  %25 = mul nsw i32 %23, %24
  %26 = add nsw i32 %22, %25
  %27 = mul nsw i32 %26, 1
  %28 = icmp sgt i32 %27, 1296
  br i1 %28, label %29, label %38

29:                                               ; preds = %4
  %30 = load i32, ptr %9, align 4, !tbaa !13
  %31 = load i32, ptr %10, align 4, !tbaa !13
  %32 = mul nsw i32 %30, %31
  %33 = load i32, ptr %10, align 4, !tbaa !13
  %34 = load i32, ptr %10, align 4, !tbaa !13
  %35 = mul nsw i32 %33, %34
  %36 = add nsw i32 %32, %35
  %37 = call ptr @MatNd_create(i32 noundef %36, i32 noundef 1)
  store ptr %37, ptr %11, align 8, !tbaa !5
  br label %91

38:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %39 = load i32, ptr %9, align 4, !tbaa !13
  %40 = load i32, ptr %10, align 4, !tbaa !13
  %41 = mul nsw i32 %39, %40
  %42 = load i32, ptr %10, align 4, !tbaa !13
  %43 = load i32, ptr %10, align 4, !tbaa !13
  %44 = mul nsw i32 %42, %43
  %45 = add nsw i32 %41, %44
  %46 = mul nsw i32 %45, 1
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %38
  br label %58

49:                                               ; preds = %38
  %50 = load i32, ptr %9, align 4, !tbaa !13
  %51 = load i32, ptr %10, align 4, !tbaa !13
  %52 = mul nsw i32 %50, %51
  %53 = load i32, ptr %10, align 4, !tbaa !13
  %54 = load i32, ptr %10, align 4, !tbaa !13
  %55 = mul nsw i32 %53, %54
  %56 = add nsw i32 %52, %55
  %57 = mul nsw i32 %56, 1
  br label %58

58:                                               ; preds = %49, %48
  %59 = phi i32 [ 1, %48 ], [ %57, %49 ]
  store i32 %59, ptr %12, align 4, !tbaa !13
  %60 = load i32, ptr %12, align 4, !tbaa !13
  %61 = zext i32 %60 to i64
  %62 = mul i64 %61, 8
  %63 = add i64 24, %62
  %64 = alloca i8, i64 %63, align 16
  store ptr %64, ptr %11, align 8, !tbaa !5
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._MatNd, ptr %65, i64 1
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._MatNd, ptr %67, i32 0, i32 0
  store ptr %66, ptr %68, align 8, !tbaa !15
  %69 = load i32, ptr %9, align 4, !tbaa !13
  %70 = load i32, ptr %10, align 4, !tbaa !13
  %71 = mul nsw i32 %69, %70
  %72 = load i32, ptr %10, align 4, !tbaa !13
  %73 = load i32, ptr %10, align 4, !tbaa !13
  %74 = mul nsw i32 %72, %73
  %75 = add nsw i32 %71, %74
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._MatNd, ptr %76, i32 0, i32 1
  store i32 %75, ptr %77, align 8, !tbaa !9
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._MatNd, ptr %78, i32 0, i32 2
  store i32 1, ptr %79, align 4, !tbaa !14
  %80 = load i32, ptr %12, align 4, !tbaa !13
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._MatNd, ptr %81, i32 0, i32 3
  store i32 %80, ptr %82, align 8, !tbaa !16
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._MatNd, ptr %83, i32 0, i32 4
  store i8 1, ptr %84, align 4, !tbaa !17
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._MatNd, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = load i32, ptr %12, align 4, !tbaa !13
  %89 = zext i32 %88 to i64
  %90 = mul i64 %89, 8
  call void @llvm.memset.p0.i64(ptr align 8 %87, i8 0, i64 %90, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %91

91:                                               ; preds = %58, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = call double @MatNd_rwPinv2_(ptr noundef %92, ptr noundef %93, ptr noundef %94, ptr noundef %95, ptr noundef %96)
  store double %97, ptr %13, align 8, !tbaa !18
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %98)
  %99 = load double, ptr %13, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret double %99
}

; Function Attrs: nounwind uwtable
declare dso_local double @MatNd_rwPinv2_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !11, i64 8}
!10 = !{!"_MatNd", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 12}
!15 = !{!10, !6, i64 0}
!16 = !{!10, !11, i64 16}
!17 = !{!10, !12, i64 20}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !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: nounwind uwtable
declare dso_local ptr @MatNd_create(i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @MatNd_rwPinv2(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 12
  %8 = load i32, ptr %7, align 4, !tbaa !12
  %9 = add i32 %8, %6
  %10 = mul i32 %9, %8
  %11 = icmp sgt i32 %10, 1296
  br i1 %11, label %12, label %14

12:                                               ; preds = %4
  %13 = tail call ptr @MatNd_create(i32 noundef %10, i32 noundef 1)
  br label %24

14:                                               ; preds = %4
  %spec.select = tail call i32 @llvm.umax.i32(i32 %10, i32 1)
  %15 = zext i32 %spec.select to i64
  %16 = shl nuw nsw i64 %15, 3
  %17 = add nuw nsw i64 %16, 24
  %18 = alloca i8, i64 %17, align 16
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  store ptr %19, ptr %18, align 16, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %18, i64 8
  store i32 %10, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %18, i64 12
  store i32 1, ptr %21, align 4, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %18, i64 16
  store i32 %spec.select, ptr %22, align 16, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %18, i64 20
  store i8 1, ptr %23, align 4, !tbaa !15
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %19, i8 0, i64 %16, i1 false)
  br label %24

24:                                               ; preds = %14, %12
  %.0 = phi ptr [ %13, %12 ], [ %18, %14 ]
  %25 = call double @MatNd_rwPinv2_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3, ptr noundef %.0)
  call void @MatNd_destroy(ptr noundef %.0)
  ret double %25
}

; Function Attrs: nounwind uwtable
declare dso_local double @MatNd_rwPinv2_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #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 nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"_MatNd", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 12}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !11, i64 20}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass