; 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
@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@RcsLogLevel = external global i32, align 4
@.str.31 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [1 x i8], align 1
@__func__.MatNd_gnuplotPipes = external hidden unnamed_addr constant [19 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [3 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: 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 zeroext i1 @MatNd_toFile(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_gnuplotPipes(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca [256 x i8], align 16
  %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
  store ptr null, ptr %5, align 8, !tbaa !5
  %9 = call noalias ptr @popen(ptr noundef @.str.31, ptr noundef @.str.32)
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %31

12:                                               ; preds = %2
  br label %13

13:                                               ; preds = %12
  %14 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %17(i32 noundef 1, ptr noundef @.str.33, ptr noundef @__func__.MatNd_gnuplotPipes, i32 noundef 557, ptr noundef @.str.34)
  br label %18

18:                                               ; preds = %16, %13
  %19 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %20 = icmp sle i32 1, %19
  br i1 %20, label %21, label %28

21:                                               ; preds = %18
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.35, ptr noundef @__func__.MatNd_gnuplotPipes, i32 noundef 557) #5
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.34) #5
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.4) #5
  br label %28

28:                                               ; preds = %21, %18
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  store i32 1, ptr %6, align 4
  br label %79

31:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 256, ptr %7) #5
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 0, i64 256, i1 false)
  %32 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %33 = call ptr @File_createUniqueName(ptr noundef %32, ptr noundef @.str.36, ptr noundef @.str.37)
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %36 = call zeroext i1 @MatNd_toFile(ptr noundef %34, ptr noundef %35)
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %43

39:                                               ; preds = %31
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.38, ptr noundef %41) #5
  br label %46

43:                                               ; preds = %31
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str.39) #5
  br label %46

46:                                               ; preds = %43, %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %69, %46
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._MatNd, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = icmp ule i32 %48, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %47
  store i32 4, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %72

54:                                               ; preds = %47
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.40, ptr noundef %56, i32 noundef %57, i32 noundef %58) #5
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._MatNd, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !11
  %64 = icmp ne i32 %60, %63
  br i1 %64, label %65, label %68

65:                                               ; preds = %54
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.41) #5
  br label %68

68:                                               ; preds = %65, %54
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %47, !llvm.loop !14

72:                                               ; preds = %53
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.4) #5
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = call i32 @fflush(ptr noundef %75)
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = call i32 @pclose(ptr noundef %77)
  call void @llvm.lifetime.end.p0(i64 256, ptr %7) #5
  store i32 0, ptr %6, align 4
  br label %79

79:                                               ; preds = %72, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %80 = load i32, ptr %6, align 4
  switch i32 %80, label %82 [
    i32 0, label %81
    i32 1, label %81
  ]

81:                                               ; preds = %79, %79
  ret void

82:                                               ; preds = %79
  unreachable
}

declare noalias ptr @popen(ptr noundef, ptr noundef) #4

declare ptr @File_createUniqueName(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @fflush(ptr noundef) #4

declare i32 @pclose(ptr noundef) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 }

!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 12}
!12 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20}
!13 = !{!"_Bool", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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.4 = external hidden unnamed_addr constant [2 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@.str.31 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [1 x i8], align 1
@__func__.MatNd_gnuplotPipes = external hidden unnamed_addr constant [19 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.41 = 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

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

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

; Function Attrs: mustprogress 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 zeroext i1 @MatNd_toFile(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_gnuplotPipes(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca [256 x i8], align 16
  %4 = tail call noalias ptr @popen(ptr noundef nonnull @.str.31, ptr noundef nonnull @.str.32)
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %19

6:                                                ; preds = %2
  %7 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %.not22 = icmp eq ptr %7, null
  br i1 %.not22, label %9, label %8

8:                                                ; preds = %6
  tail call void (i32, ptr, ptr, i32, ptr, ...) %7(i32 noundef 1, ptr noundef nonnull @.str.33, ptr noundef nonnull @__func__.MatNd_gnuplotPipes, i32 noundef 557, ptr noundef nonnull @.str.34) #5
  br label %9

9:                                                ; preds = %8, %6
  %10 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %39

12:                                               ; preds = %9
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.35, ptr noundef nonnull @__func__.MatNd_gnuplotPipes, i32 noundef 557) #6
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.34) #6
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.4) #6
  br label %39

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %3, i8 0, i64 256, i1 false)
  %20 = call ptr @File_createUniqueName(ptr noundef nonnull %3, ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.37) #5
  %21 = call zeroext i1 @MatNd_toFile(ptr noundef %1, ptr noundef nonnull %3)
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %24, label %22

22:                                               ; preds = %19
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.38, ptr noundef nonnull %0) #5
  br label %26

24:                                               ; preds = %19
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.39) #5
  br label %26

26:                                               ; preds = %24, %22
  %27 = getelementptr inbounds i8, ptr %1, i64 12
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %.not2023 = icmp eq i32 %28, 0
  br i1 %.not2023, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %36, %26
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.4) #5
  %30 = call i32 @fflush(ptr noundef nonnull %4)
  %31 = call i32 @pclose(ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #5
  br label %39

.lr.ph:                                           ; preds = %26, %36
  %.024 = phi i32 [ %38, %36 ], [ 1, %26 ]
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.40, ptr noundef nonnull %3, i32 noundef %.024, i32 noundef %.024) #5
  %33 = load i32, ptr %27, align 4, !tbaa !11
  %.not21 = icmp eq i32 %.024, %33
  br i1 %.not21, label %36, label %34

34:                                               ; preds = %.lr.ph
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %4, ptr noundef nonnull @.str.41) #5
  %.pre = load i32, ptr %27, align 4, !tbaa !11
  br label %36

36:                                               ; preds = %.lr.ph, %34
  %37 = phi i32 [ %.024, %.lr.ph ], [ %.pre, %34 ]
  %38 = add i32 %.024, 1
  %.not20 = icmp ugt i32 %38, %37
  br i1 %.not20, label %._crit_edge, label %.lr.ph, !llvm.loop !14

39:                                               ; preds = %9, %12, %._crit_edge
  ret void
}

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

declare ptr @File_createUniqueName(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_MatNd", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20}
!13 = !{!"_Bool", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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