; 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_getSubset = external hidden unnamed_addr constant [16 x i8], align 1
@.str.285 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.286 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.287 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.288 = external hidden unnamed_addr constant [38 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_getSubset(ptr noundef %0, ptr noundef %1, ptr noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._MatNd, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._MatNd, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = mul i32 %11, %14
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._MatNd, ptr %16, i32 0, i32 3
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = icmp ule i32 %15, %18
  br i1 %19, label %36, label %20

20:                                               ; preds = %8
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_getSubset, i32 noundef 5294, ptr noundef @.str.285) #5
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._MatNd, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 8, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._MatNd, ptr %27, i32 0, i32 2
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._MatNd, ptr %30, i32 0, i32 3
  %32 = load i32, ptr %31, align 8, !tbaa !14
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.286, i32 noundef %26, i32 noundef %29, i32 noundef %32) #5
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str.4) #5
  call void @print_trace()
  call void @exit(i32 noundef 1) #6
  unreachable

36:                                               ; preds = %8
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._MatNd, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._MatNd, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !9
  %45 = icmp eq i32 %41, %44
  br i1 %45, label %46, label %54

46:                                               ; preds = %38
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._MatNd, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !13
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._MatNd, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !13
  %53 = icmp eq i32 %49, %52
  br i1 %53, label %73, label %54

54:                                               ; preds = %46, %38
  %55 = load ptr, ptr @stderr, align 8, !tbaa !5
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_getSubset, i32 noundef 5297, ptr noundef @.str.287) #5
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._MatNd, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 8, !tbaa !9
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._MatNd, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !13
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._MatNd, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 8, !tbaa !9
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._MatNd, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 4, !tbaa !13
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef @.str.288, i32 noundef %60, i32 noundef %63, i32 noundef %66, i32 noundef %69) #5
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.4) #5
  call void @print_trace()
  call void @exit(i32 noundef 1) #6
  unreachable

73:                                               ; preds = %46
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._MatNd, ptr %75, i32 0, i32 1
  store i32 0, ptr %76, align 8, !tbaa !9
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._MatNd, ptr %77, i32 0, i32 2
  store i32 1, ptr %78, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !15
  br label %79

79:                                               ; preds = %120, %74
  %80 = load i32, ptr %7, align 4, !tbaa !15
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._MatNd, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 8, !tbaa !9
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._MatNd, ptr %84, i32 0, i32 2
  %86 = load i32, ptr %85, align 4, !tbaa !13
  %87 = mul i32 %83, %86
  %88 = icmp ult i32 %80, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %123

90:                                               ; preds = %79
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._MatNd, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !16
  %94 = load i32, ptr %7, align 4, !tbaa !15
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds double, ptr %93, i64 %95
  %97 = load double, ptr %96, align 8, !tbaa !17
  %98 = fcmp oge double %97, 5.000000e-01
  br i1 %98, label %99, label %119

99:                                               ; preds = %90
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct._MatNd, ptr %100, i32 0, i32 0
  %102 = load ptr, ptr %101, align 8, !tbaa !16
  %103 = load i32, ptr %7, align 4, !tbaa !15
  %104 = zext i32 %103 to i64
  %105 = getelementptr inbounds double, ptr %102, i64 %104
  %106 = load double, ptr %105, align 8, !tbaa !17
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._MatNd, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !16
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct._MatNd, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 8, !tbaa !9
  %113 = zext i32 %112 to i64
  %114 = getelementptr inbounds double, ptr %109, i64 %113
  store double %106, ptr %114, align 8, !tbaa !17
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._MatNd, ptr %115, i32 0, i32 1
  %117 = load i32, ptr %116, align 8, !tbaa !9
  %118 = add i32 %117, 1
  store i32 %118, ptr %116, align 8, !tbaa !9
  br label %119

119:                                              ; preds = %99, %90
  br label %120

120:                                              ; preds = %119
  %121 = load i32, ptr %7, align 4, !tbaa !15
  %122 = add i32 %121, 1
  store i32 %122, ptr %7, align 4, !tbaa !15
  br label %79, !llvm.loop !19

123:                                              ; preds = %89
  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 = !{!10, !11, i64 16}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !6, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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_getSubset = external hidden unnamed_addr constant [16 x i8], align 1
@.str.285 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.286 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.287 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.288 = external hidden unnamed_addr constant [38 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_getSubset(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #3 {
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !12
  %8 = mul i32 %7, %5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load i32, ptr %9, align 8, !tbaa !13
  %.not = icmp ugt i32 %8, %10
  br i1 %.not, label %11, label %21

11:                                               ; preds = %3
  %12 = load ptr, ptr @stderr, align 8, !tbaa !14
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_getSubset, i32 noundef 5294, ptr noundef nonnull @.str.285) #4
  %14 = load ptr, ptr @stderr, align 8, !tbaa !14
  %15 = load i32, ptr %4, align 8, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !12
  %17 = load i32, ptr %9, align 8, !tbaa !13
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.286, i32 noundef %15, i32 noundef %16, i32 noundef %17) #4
  %19 = load ptr, ptr @stderr, align 8, !tbaa !14
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.4) #4
  tail call void @print_trace() #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

21:                                               ; preds = %3
  %22 = getelementptr inbounds i8, ptr %2, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !5
  %24 = icmp eq i32 %23, %5
  br i1 %24, label %25, label %29

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %2, i64 12
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = icmp eq i32 %27, %7
  br i1 %28, label %41, label %29

29:                                               ; preds = %25, %21
  %30 = load ptr, ptr @stderr, align 8, !tbaa !14
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_getSubset, i32 noundef 5297, ptr noundef nonnull @.str.287) #4
  %32 = load ptr, ptr @stderr, align 8, !tbaa !14
  %33 = load i32, ptr %22, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %2, i64 12
  %35 = load i32, ptr %34, align 4, !tbaa !12
  %36 = load i32, ptr %4, align 8, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !12
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.288, i32 noundef %33, i32 noundef %35, i32 noundef %36, i32 noundef %37) #4
  %39 = load ptr, ptr @stderr, align 8, !tbaa !14
  %40 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.4) #4
  tail call void @print_trace() #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

41:                                               ; preds = %25
  %42 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %42, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 1, ptr %43, align 4, !tbaa !12
  %44 = load i32, ptr %26, align 4, !tbaa !12
  %45 = load i32, ptr %22, align 8, !tbaa !5
  %46 = mul i32 %44, %45
  %.not27 = icmp eq i32 %46, 0
  br i1 %.not27, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %41
  %47 = load ptr, ptr %2, align 8, !tbaa !15
  br label %48

._crit_edge:                                      ; preds = %62, %41
  ret void

48:                                               ; preds = %.lr.ph, %62
  %49 = phi i32 [ %45, %.lr.ph ], [ %63, %62 ]
  %50 = phi i32 [ 0, %.lr.ph ], [ %64, %62 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %62 ]
  %51 = getelementptr inbounds double, ptr %47, i64 %indvars.iv
  %52 = load double, ptr %51, align 8, !tbaa !16
  %53 = fcmp ult double %52, 5.000000e-01
  br i1 %53, label %62, label %54

54:                                               ; preds = %48
  %55 = load ptr, ptr %1, align 8, !tbaa !15
  %56 = getelementptr inbounds double, ptr %55, i64 %indvars.iv
  %57 = load double, ptr %56, align 8, !tbaa !16
  %58 = load ptr, ptr %0, align 8, !tbaa !15
  %59 = zext i32 %50 to i64
  %60 = getelementptr inbounds double, ptr %58, i64 %59
  store double %57, ptr %60, align 8, !tbaa !16
  %61 = add i32 %50, 1
  store i32 %61, ptr %42, align 8, !tbaa !5
  %.pre = load i32, ptr %22, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %48, %54
  %63 = phi i32 [ %49, %48 ], [ %.pre, %54 ]
  %64 = phi i32 [ %50, %48 ], [ %61, %54 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %65 = mul i32 %44, %63
  %66 = zext i32 %65 to i64
  %67 = icmp ult i64 %indvars.iv.next, %66
  br i1 %67, label %48, label %._crit_edge, !llvm.loop !18
}

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, !10, i64 16}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass