; 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.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [59 x i8], align 1
@__func__.MatNd_filterFirstOrderLag = external hidden unnamed_addr constant [26 x i8], align 1
@.str.255 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.256 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.257 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.258 = external hidden unnamed_addr constant [7 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 ptr @MatNd_create(i32 noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local ptr @MatNd_getRowPtr(ptr noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_constMulSelf(ptr noundef, double noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_setRow(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #4

declare void @VecNd_copy(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_filterFirstOrderLag(ptr noundef %0, ptr noundef %1, double noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  br label %9

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

17:                                               ; preds = %9
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._MatNd, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = uitofp i32 %21 to double
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._MatNd, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = uitofp i32 %25 to double
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.155, ptr noundef @.str.1, ptr noundef @__func__.MatNd_filterFirstOrderLag, i32 noundef 4920, ptr noundef @.str.255, double noundef %22, ptr noundef @.str.256, double noundef %26) #5
  call void @print_trace()
  call void @exit(i32 noundef 1) #6
  unreachable

28:                                               ; preds = %9
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._MatNd, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !15
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._MatNd, ptr %34, i32 0, i32 2
  %36 = load i32, ptr %35, align 4, !tbaa !15
  %37 = icmp ne i32 %33, %36
  br i1 %37, label %38, label %49

38:                                               ; preds = %30
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._MatNd, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !15
  %43 = uitofp i32 %42 to double
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._MatNd, ptr %44, i32 0, i32 2
  %46 = load i32, ptr %45, align 4, !tbaa !15
  %47 = uitofp i32 %46 to double
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str.155, ptr noundef @.str.1, ptr noundef @__func__.MatNd_filterFirstOrderLag, i32 noundef 4921, ptr noundef @.str.257, double noundef %43, ptr noundef @.str.258, double noundef %47) #5
  call void @print_trace()
  call void @exit(i32 noundef 1) #6
  unreachable

49:                                               ; preds = %30
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._MatNd, ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !15
  %54 = call ptr @MatNd_create(i32 noundef %53, i32 noundef 1)
  store ptr %54, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !16
  br label %55

55:                                               ; preds = %98, %50
  %56 = load i32, ptr %8, align 4, !tbaa !16
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._MatNd, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = icmp ult i32 %56, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %101

62:                                               ; preds = %55
  %63 = load i32, ptr %8, align 4, !tbaa !16
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %75

65:                                               ; preds = %62
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._MatNd, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !17
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load i32, ptr %8, align 4, !tbaa !16
  %71 = call ptr @MatNd_getRowPtr(ptr noundef %69, i32 noundef %70)
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._MatNd, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 4, !tbaa !15
  call void @VecNd_copy(ptr noundef %68, ptr noundef %71, i32 noundef %74)
  br label %89

75:                                               ; preds = %62
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load double, ptr %6, align 8, !tbaa !9
  %78 = fsub double 1.000000e+00, %77
  call void @MatNd_constMulSelf(ptr noundef %76, double noundef %78)
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._MatNd, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !17
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load i32, ptr %8, align 4, !tbaa !16
  %84 = call ptr @MatNd_getRowPtr(ptr noundef %82, i32 noundef %83)
  %85 = load double, ptr %6, align 8, !tbaa !9
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._MatNd, ptr %86, i32 0, i32 2
  %88 = load i32, ptr %87, align 4, !tbaa !15
  call void @VecNd_constMulAndAddSelf(ptr noundef %81, ptr noundef %84, double noundef %85, i32 noundef %88)
  br label %89

89:                                               ; preds = %75, %65
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = load i32, ptr %8, align 4, !tbaa !16
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._MatNd, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !17
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct._MatNd, ptr %95, i32 0, i32 2
  %97 = load i32, ptr %96, align 4, !tbaa !15
  call void @MatNd_setRow(ptr noundef %90, i32 noundef %91, ptr noundef %94, i32 noundef %97)
  br label %98

98:                                               ; preds = %89
  %99 = load i32, ptr %8, align 4, !tbaa !16
  %100 = add i32 %99, 1
  store i32 %100, ptr %8, align 4, !tbaa !16
  br label %55, !llvm.loop !18

101:                                              ; preds = %61
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  call void @MatNd_destroy(ptr noundef %102)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

declare void @VecNd_constMulAndAddSelf(ptr noundef, ptr noundef, double noundef, i32 noundef) #1

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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"_MatNd", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !14, i64 20}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !13, i64 12}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !6, 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.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [59 x i8], align 1
@__func__.MatNd_filterFirstOrderLag = external hidden unnamed_addr constant [26 x i8], align 1
@.str.255 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.256 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.257 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.258 = external hidden unnamed_addr constant [7 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 ptr @MatNd_create(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @MatNd_getRowPtr(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_constMulSelf(ptr noundef, double noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_setRow(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @VecNd_copy(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_filterFirstOrderLag(ptr noundef %0, ptr noundef %1, double noundef %2) local_unnamed_addr #3 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %5, %7
  br i1 %.not, label %13, label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr @stderr, align 8, !tbaa !12
  %10 = uitofp i32 %5 to double
  %11 = uitofp i32 %7 to double
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.155, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_filterFirstOrderLag, i32 noundef 4920, ptr noundef nonnull @.str.255, double noundef %10, ptr noundef nonnull @.str.256, double noundef %11) #4
  tail call void @print_trace() #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %1, i64 12
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %.not32 = icmp eq i32 %15, %17
  br i1 %.not32, label %23, label %18

18:                                               ; preds = %13
  %19 = load ptr, ptr @stderr, align 8, !tbaa !12
  %20 = uitofp i32 %15 to double
  %21 = uitofp i32 %17 to double
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.155, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_filterFirstOrderLag, i32 noundef 4921, ptr noundef nonnull @.str.257, double noundef %20, ptr noundef nonnull @.str.258, double noundef %21) #4
  tail call void @print_trace() #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

23:                                               ; preds = %13
  %24 = tail call ptr @MatNd_create(i32 noundef %15, i32 noundef 1)
  %25 = load i32, ptr %6, align 8, !tbaa !5
  %.not34 = icmp eq i32 %25, 0
  br i1 %.not34, label %._crit_edge, label %26

26:                                               ; preds = %23
  %27 = fsub double 1.000000e+00, %2
  %28 = load ptr, ptr %24, align 8, !tbaa !14
  %29 = tail call ptr @MatNd_getRowPtr(ptr noundef nonnull %1, i32 noundef 0)
  %30 = load i32, ptr %16, align 4, !tbaa !13
  tail call void @VecNd_copy(ptr noundef %28, ptr noundef %29, i32 noundef %30) #5
  %.pre36 = load i32, ptr %14, align 4, !tbaa !13
  %.pre = load ptr, ptr %24, align 8, !tbaa !14
  tail call void @MatNd_setRow(ptr noundef nonnull %0, i32 noundef 0, ptr noundef %.pre, i32 noundef %.pre36)
  %31 = load i32, ptr %6, align 8, !tbaa !5
  %32 = icmp ugt i32 %31, 1
  br i1 %32, label %.peel.next, label %._crit_edge

._crit_edge:                                      ; preds = %.peel.next, %26, %23
  tail call void @MatNd_destroy(ptr noundef %24)
  ret void

.peel.next:                                       ; preds = %26, %.peel.next
  %.033 = phi i32 [ %36, %.peel.next ], [ 1, %26 ]
  tail call void @MatNd_constMulSelf(ptr noundef nonnull %24, double noundef %27)
  %33 = load ptr, ptr %24, align 8, !tbaa !14
  %34 = tail call ptr @MatNd_getRowPtr(ptr noundef nonnull %1, i32 noundef %.033)
  %35 = load i32, ptr %16, align 4, !tbaa !13
  tail call void @VecNd_constMulAndAddSelf(ptr noundef %33, ptr noundef %34, double noundef %2, i32 noundef %35) #5
  %.pre38 = load i32, ptr %14, align 4, !tbaa !13
  %.pre37 = load ptr, ptr %24, align 8, !tbaa !14
  tail call void @MatNd_setRow(ptr noundef nonnull %0, i32 noundef %.033, ptr noundef %.pre37, i32 noundef %.pre38)
  %36 = add nuw i32 %.033, 1
  %37 = load i32, ptr %6, align 8, !tbaa !5
  %38 = icmp ult i32 %36, %37
  br i1 %38, label %.peel.next, label %._crit_edge, !llvm.loop !15
}

declare void @VecNd_constMulAndAddSelf(ptr noundef, ptr noundef, double noundef, i32 noundef) local_unnamed_addr #1

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 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 12}
!14 = !{!6, !7, i64 0}
!15 = distinct !{!15, !16, !17}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass