; 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
@.str.25 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.MatNd_appendToFile = external hidden unnamed_addr constant [19 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [3 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
declare dso_local double @MatNd_get(ptr noundef, i32 noundef, i32 noundef) #4

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare i32 @fclose(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_appendToFile(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = 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 8, ptr %5) #5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call noalias ptr @fopen(ptr noundef %9, ptr noundef @.str.29)
  store ptr %10, ptr %5, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %22, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_appendToFile, i32 noundef 523, ptr noundef @.str.30) #5
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.25, ptr noundef %18) #5
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.4) #5
  call void @print_trace()
  call void @exit(i32 noundef 1) #6
  unreachable

22:                                               ; preds = %11
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._MatNd, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !9
  %28 = icmp ugt i32 %27, 0
  br i1 %28, label %29, label %75

29:                                               ; preds = %24
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._MatNd, ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !13
  %33 = icmp ugt i32 %32, 0
  br i1 %33, label %34, label %75

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !14
  br label %35

35:                                               ; preds = %71, %34
  %36 = load i32, ptr %6, align 4, !tbaa !14
  %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 = icmp ult i32 %36, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %35
  store i32 4, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %74

42:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !14
  br label %43

43:                                               ; preds = %58, %42
  %44 = load i32, ptr %8, align 4, !tbaa !14
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._MatNd, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !13
  %48 = sub i32 %47, 1
  %49 = icmp ult i32 %44, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %43
  store i32 7, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %61

51:                                               ; preds = %43
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !14
  %55 = load i32, ptr %8, align 4, !tbaa !14
  %56 = call double @MatNd_get(ptr noundef %53, i32 noundef %54, i32 noundef %55)
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str.27, double noundef %56) #5
  br label %58

58:                                               ; preds = %51
  %59 = load i32, ptr %8, align 4, !tbaa !14
  %60 = add i32 %59, 1
  store i32 %60, ptr %8, align 4, !tbaa !14
  br label %43, !llvm.loop !15

61:                                               ; preds = %50
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !14
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._MatNd, ptr %65, i32 0, i32 2
  %67 = load i32, ptr %66, align 4, !tbaa !13
  %68 = sub i32 %67, 1
  %69 = call double @MatNd_get(ptr noundef %63, i32 noundef %64, i32 noundef %68)
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.28, double noundef %69) #5
  br label %71

71:                                               ; preds = %61
  %72 = load i32, ptr %6, align 4, !tbaa !14
  %73 = add i32 %72, 1
  store i32 %73, ptr %6, align 4, !tbaa !14
  br label %35, !llvm.loop !17

74:                                               ; preds = %41
  br label %75

75:                                               ; preds = %74, %29, %24
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = call i32 @fclose(ptr noundef %76)
  call void @llvm.lifetime.end.p0(i64 8, 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 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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
@.str.25 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.MatNd_appendToFile = external hidden unnamed_addr constant [19 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [3 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
declare dso_local double @MatNd_get(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_appendToFile(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.29)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %11

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_appendToFile, i32 noundef 523, ptr noundef nonnull @.str.30) #4
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.25, ptr noundef %1) #4
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.4) #4
  tail call void @print_trace() #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %.not22 = icmp eq i32 %13, 0
  br i1 %.not22, label %.loopexit, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 12
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %.not23 = icmp eq i32 %16, 0
  br i1 %.not23, label %.loopexit, label %.preheader

.preheaderthread-pre-split:                       ; preds = %._crit_edge
  %.pr = load i32, ptr %15, align 4, !tbaa !13
  br label %.preheader

.preheader:                                       ; preds = %14, %.preheaderthread-pre-split
  %17 = phi i32 [ %.pr, %.preheaderthread-pre-split ], [ %16, %14 ]
  %.01926 = phi i32 [ %20, %.preheaderthread-pre-split ], [ 0, %14 ]
  %.not28 = icmp eq i32 %17, 1
  br i1 %.not28, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.lcssa = phi i32 [ 0, %.preheader ], [ %27, %.lr.ph ]
  %18 = tail call double @MatNd_get(ptr noundef nonnull %0, i32 noundef %.01926, i32 noundef %.lcssa)
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.28, double noundef %18) #5
  %20 = add nuw i32 %.01926, 1
  %21 = load i32, ptr %12, align 8, !tbaa !9
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %.preheaderthread-pre-split, label %.loopexit, !llvm.loop !14

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.025 = phi i32 [ %25, %.lr.ph ], [ 0, %.preheader ]
  %23 = tail call double @MatNd_get(ptr noundef nonnull %0, i32 noundef %.01926, i32 noundef %.025)
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.27, double noundef %23) #5
  %25 = add nuw i32 %.025, 1
  %26 = load i32, ptr %15, align 4, !tbaa !13
  %27 = add i32 %26, -1
  %28 = icmp ult i32 %25, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !16

.loopexit:                                        ; preds = %._crit_edge, %14, %11
  %29 = tail call i32 @fclose(ptr noundef nonnull %3)
  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, !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 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass