; 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.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [4 x i8], align 1

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

; 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

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_printComment(ptr noundef %0, ptr noundef %1) #2 {
  %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) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %13

9:                                                ; preds = %2
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef @.str.15, ptr noundef %11) #3
  br label %13

13:                                               ; preds = %9, %2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %49, %13
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._MatNd, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp ult i32 %15, %18
  br i1 %19, label %20, label %52

20:                                               ; preds = %14
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %43, %20
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._MatNd, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !14
  %26 = icmp ult i32 %22, %25
  br i1 %26, label %27, label %46

27:                                               ; preds = %21
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._MatNd, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._MatNd, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = mul i32 %34, %35
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = add i32 %36, %37
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds double, ptr %31, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !16
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.10, double noundef %41) #3
  br label %43

43:                                               ; preds = %27
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = add i32 %44, 1
  store i32 %45, ptr %6, align 4, !tbaa !9
  br label %21, !llvm.loop !18

46:                                               ; preds = %21
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.4) #3
  br label %49

49:                                               ; preds = %46
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %5, align 4, !tbaa !9
  br label %14, !llvm.loop !20

52:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !6, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @MatNd_printComment(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %6, label %3

3:                                                ; preds = %2
  %4 = load ptr, ptr @stderr, align 8, !tbaa !5
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str.15, ptr noundef nonnull %0) #2
  br label %6

6:                                                ; preds = %3, %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %.not17 = icmp eq i32 %8, 0
  br i1 %.not17, label %._crit_edge16, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %6
  %9 = getelementptr inbounds i8, ptr %1, i64 12
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %.01115 = phi i32 [ 0, %.preheader.lr.ph ], [ %25, %._crit_edge ]
  %10 = load i32, ptr %9, align 4, !tbaa !13
  %.not18 = icmp eq i32 %10, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %11 = phi i32 [ %21, %.lr.ph ], [ %10, %.preheader ]
  %.014 = phi i32 [ %20, %.lr.ph ], [ 0, %.preheader ]
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = load ptr, ptr %1, align 8, !tbaa !14
  %14 = mul i32 %11, %.01115
  %15 = add i32 %14, %.014
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds double, ptr %13, i64 %16
  %18 = load double, ptr %17, align 8, !tbaa !15
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.10, double noundef %18) #2
  %20 = add nuw i32 %.014, 1
  %21 = load i32, ptr %9, align 4, !tbaa !13
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.4) #2
  %25 = add nuw i32 %.01115, 1
  %26 = load i32, ptr %7, align 8, !tbaa !9
  %27 = icmp ult i32 %25, %26
  br i1 %27, label %.preheader, label %._crit_edge16, !llvm.loop !19

._crit_edge16:                                    ; preds = %._crit_edge, %6
  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 = { nofree 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 = { cold 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, !6, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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