; 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 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.MatNd_subSelf = external hidden unnamed_addr constant [14 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

declare void @print_trace() #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_subSelf(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = 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 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._MatNd, ptr %7, i32 0, i32 1
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._MatNd, ptr %10, i32 0, i32 2
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = mul i32 %9, %12
  store i32 %13, ptr %6, align 4, !tbaa !14
  br label %14

14:                                               ; preds = %2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._MatNd, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._MatNd, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = icmp eq i32 %17, %20
  br i1 %21, label %22, label %30

22:                                               ; preds = %14
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._MatNd, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._MatNd, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = icmp eq i32 %25, %28
  br i1 %29, label %49, label %30

30:                                               ; preds = %22, %14
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_subSelf, i32 noundef 1411, ptr noundef @.str.113) #5
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._MatNd, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._MatNd, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !9
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._MatNd, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !9
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._MatNd, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %44, align 4, !tbaa !13
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.114, i32 noundef %36, i32 noundef %39, i32 noundef %42, i32 noundef %45) #5
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.4) #5
  call void @print_trace()
  call void @exit(i32 noundef 1) #6
  unreachable

49:                                               ; preds = %22
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %52

52:                                               ; preds = %72, %51
  %53 = load i32, ptr %5, align 4, !tbaa !14
  %54 = load i32, ptr %6, align 4, !tbaa !14
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %56, label %75

56:                                               ; preds = %52
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._MatNd, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  %60 = load i32, ptr %5, align 4, !tbaa !14
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds double, ptr %59, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !16
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._MatNd, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !15
  %67 = load i32, ptr %5, align 4, !tbaa !14
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %66, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !16
  %71 = fsub double %70, %63
  store double %71, ptr %69, align 8, !tbaa !16
  br label %72

72:                                               ; preds = %56
  %73 = load i32, ptr %5, align 4, !tbaa !14
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %5, align 4, !tbaa !14
  br label %52, !llvm.loop !18

75:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

attributes #0 = { nounwind "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 = { "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 = { noreturn nounwind "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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!10, !11, i64 12}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [39 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.MatNd_subSelf = external hidden unnamed_addr constant [14 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare void @print_trace() local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_subSelf(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %7 = mul i32 %6, %4
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp eq i32 %4, %9
  br i1 %10, label %11, label %33

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %1, i64 12
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %14 = icmp eq i32 %6, %13
  br i1 %14, label %.preheader, label %33

.preheader:                                       ; preds = %11
  %15 = icmp sgt i32 %7, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %16 = load ptr, ptr %1, align 8, !tbaa !13
  %17 = load ptr, ptr %0, align 8, !tbaa !13
  %wide.trip.count = zext nneg i32 %7 to i64
  %min.iters.check = icmp ult i32 %7, 6
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %scalar.ph.prol ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %18 = getelementptr inbounds double, ptr %16, i64 %indvars.iv.prol
  %19 = load double, ptr %18, align 8, !tbaa !14
  %20 = getelementptr inbounds double, ptr %17, i64 %indvars.iv.prol
  %21 = load double, ptr %20, align 8, !tbaa !14
  %22 = fsub double %21, %19
  store double %22, ptr %20, align 8, !tbaa !14
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.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 %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !16

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %23 = sub nsw i64 %indvars.iv.ph, %wide.trip.count
  %24 = icmp ugt i64 %23, -4
  br i1 %24, label %._crit_edge, label %scalar.ph

vector.memcheck:                                  ; preds = %.lr.ph
  %25 = shl nuw nsw i64 %wide.trip.count, 3
  %scevgep = getelementptr i8, ptr %17, i64 %25
  %scevgep18 = getelementptr i8, ptr %16, i64 %25
  %bound0 = icmp ult ptr %17, %scevgep18
  %bound1 = icmp ult ptr %16, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483644
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %26 = getelementptr inbounds double, ptr %16, i64 %index
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  %wide.load = load <2 x double>, ptr %26, align 8, !tbaa !14, !alias.scope !18
  %wide.load19 = load <2 x double>, ptr %27, align 8, !tbaa !14, !alias.scope !18
  %28 = getelementptr inbounds double, ptr %17, i64 %index
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %wide.load20 = load <2 x double>, ptr %28, align 8, !tbaa !14, !alias.scope !21, !noalias !18
  %wide.load21 = load <2 x double>, ptr %29, align 8, !tbaa !14, !alias.scope !21, !noalias !18
  %30 = fsub <2 x double> %wide.load20, %wide.load
  %31 = fsub <2 x double> %wide.load21, %wide.load19
  store <2 x double> %30, ptr %28, align 8, !tbaa !14, !alias.scope !21, !noalias !18
  store <2 x double> %31, ptr %29, align 8, !tbaa !14, !alias.scope !21, !noalias !18
  %index.next = add nuw i64 %index, 4
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !23

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

33:                                               ; preds = %11, %2
  %34 = load ptr, ptr @stderr, align 8, !tbaa !27
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_subSelf, i32 noundef 1411, ptr noundef nonnull @.str.113) #4
  %36 = load ptr, ptr @stderr, align 8, !tbaa !27
  %37 = load i32, ptr %3, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %1, i64 12
  %40 = load i32, ptr %39, align 4, !tbaa !12
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.114, i32 noundef %37, i32 noundef %37, i32 noundef %38, i32 noundef %40) #4
  %42 = load ptr, ptr @stderr, align 8, !tbaa !27
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.4) #4
  tail call void @print_trace() #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %44 = getelementptr inbounds double, ptr %16, i64 %indvars.iv
  %45 = load double, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds double, ptr %17, i64 %indvars.iv
  %47 = load double, ptr %46, align 8, !tbaa !14
  %48 = fsub double %47, %45
  store double %48, ptr %46, align 8, !tbaa !14
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %49 = getelementptr inbounds double, ptr %16, i64 %indvars.iv.next
  %50 = load double, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds double, ptr %17, i64 %indvars.iv.next
  %52 = load double, ptr %51, align 8, !tbaa !14
  %53 = fsub double %52, %50
  store double %53, ptr %51, align 8, !tbaa !14
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %54 = getelementptr inbounds double, ptr %16, i64 %indvars.iv.next.1
  %55 = load double, ptr %54, align 8, !tbaa !14
  %56 = getelementptr inbounds double, ptr %17, i64 %indvars.iv.next.1
  %57 = load double, ptr %56, align 8, !tbaa !14
  %58 = fsub double %57, %55
  store double %58, ptr %56, align 8, !tbaa !14
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %59 = getelementptr inbounds double, ptr %16, i64 %indvars.iv.next.2
  %60 = load double, ptr %59, align 8, !tbaa !14
  %61 = getelementptr inbounds double, ptr %17, i64 %indvars.iv.next.2
  %62 = load double, ptr %61, align 8, !tbaa !14
  %63 = fsub double %62, %60
  store double %63, ptr %61, align 8, !tbaa !14
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !28

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %.preheader
  ret void
}

attributes #0 = { nofree nounwind "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 = { "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 = { noreturn nounwind "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 #3 = { 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 #4 = { cold nounwind }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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, !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 = !{!15, !15, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = !{!19}
!19 = distinct !{!19, !20}
!20 = distinct !{!20, !"LVerDomain"}
!21 = !{!22}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !24, !25, !26}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!"llvm.loop.isvectorized", i32 1}
!26 = !{!"llvm.loop.unroll.runtime.disable"}
!27 = !{!7, !7, i64 0}
!28 = distinct !{!28, !24, !25}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass