; 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_rowLerp = external hidden unnamed_addr constant [14 x i8], align 1
@.str.250 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.251 = external hidden unnamed_addr constant [43 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: nounwind uwtable
declare dso_local void @MatNd_reshape(ptr noundef, i32 noundef, i32 noundef) #4

; 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 void @MatNd_copy(ptr noundef, 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_sub(ptr noundef, ptr noundef, ptr noundef) #4

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

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_getRowView(ptr dead_on_unwind noalias writable sret(%struct._MatNd) align 8, 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_fromArray(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @MatNd_rowLerp(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 i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca %struct._MatNd, align 8
  %15 = alloca %struct._MatNd, align 8
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._MatNd, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 4, !tbaa !11
  store i32 %18, ptr %7, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._MatNd, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !16
  store i32 %21, ptr %8, align 4, !tbaa !15
  br label %22

22:                                               ; preds = %3
  %23 = load i32, ptr %8, align 4, !tbaa !15
  %24 = icmp ugt i32 %23, 0
  br i1 %24, label %32, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.MatNd_rowLerp, i32 noundef 4614, ptr noundef @.str.250) #6
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.251) #6
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.4) #6
  call void @print_trace()
  call void @exit(i32 noundef 1) #7
  unreachable

32:                                               ; preds = %22
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !15
  call void @MatNd_reshape(ptr noundef %35, i32 noundef 1, i32 noundef %36)
  %37 = load i32, ptr %8, align 4, !tbaa !15
  %38 = icmp eq i32 %37, 1
  br i1 %38, label %39, label %42

39:                                               ; preds = %34
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  call void @MatNd_copy(ptr noundef %40, ptr noundef %41)
  store i32 1, ptr %9, align 4
  br label %89

42:                                               ; preds = %34
  %43 = load i32, ptr %7, align 4, !tbaa !15
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %42
  store i32 1, ptr %9, align 4
  br label %89

46:                                               ; preds = %42
  %47 = load double, ptr %6, align 8, !tbaa !9
  %48 = fcmp ole double %47, 0.000000e+00
  br i1 %48, label %49, label %54

49:                                               ; preds = %46
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call ptr @MatNd_getRowPtr(ptr noundef %51, i32 noundef 0)
  %53 = load i32, ptr %7, align 4, !tbaa !15
  call void @MatNd_fromArray(ptr noundef %50, ptr noundef %52, i32 noundef %53)
  store i32 1, ptr %9, align 4
  br label %89

54:                                               ; preds = %46
  %55 = load double, ptr %6, align 8, !tbaa !9
  %56 = fcmp oge double %55, 1.000000e+00
  br i1 %56, label %57, label %64

57:                                               ; preds = %54
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !15
  %61 = sub i32 %60, 1
  %62 = call ptr @MatNd_getRowPtr(ptr noundef %59, i32 noundef %61)
  %63 = load i32, ptr %7, align 4, !tbaa !15
  call void @MatNd_fromArray(ptr noundef %58, ptr noundef %62, i32 noundef %63)
  store i32 1, ptr %9, align 4
  br label %89

64:                                               ; preds = %54
  br label %65

65:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %66 = load double, ptr %6, align 8, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !15
  %68 = uitofp i32 %67 to double
  %69 = fsub double %68, 1.000000e+00
  %70 = fmul double %66, %69
  store double %70, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %71 = load double, ptr %10, align 8, !tbaa !9
  %72 = call double @llvm.floor.f64(double %71)
  %73 = fptoui double %72 to i32
  store i32 %73, ptr %11, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %74 = load double, ptr %10, align 8, !tbaa !9
  %75 = call double @llvm.ceil.f64(double %74)
  %76 = fptoui double %75 to i32
  store i32 %76, ptr %12, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %77 = load double, ptr %10, align 8, !tbaa !9
  %78 = load i32, ptr %11, align 4, !tbaa !15
  %79 = uitofp i32 %78 to double
  %80 = fsub double %77, %79
  store double %80, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #6
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load i32, ptr %11, align 4, !tbaa !15
  call void @MatNd_getRowView(ptr dead_on_unwind writable sret(%struct._MatNd) align 8 %14, ptr noundef %81, i32 noundef %82)
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #6
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load i32, ptr %12, align 4, !tbaa !15
  call void @MatNd_getRowView(ptr dead_on_unwind writable sret(%struct._MatNd) align 8 %15, ptr noundef %83, i32 noundef %84)
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatNd_sub(ptr noundef %85, ptr noundef %15, ptr noundef %14)
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = load double, ptr %13, align 8, !tbaa !9
  call void @MatNd_constMulSelf(ptr noundef %86, double noundef %87)
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  call void @MatNd_addSelf(ptr noundef %88, ptr noundef %14)
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  store i32 0, ptr %9, align 4
  br label %89

89:                                               ; preds = %65, %57, %49, %45, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  %90 = load i32, ptr %9, align 4
  switch i32 %90, label %92 [
    i32 0, label %91
    i32 1, label %91
  ]

91:                                               ; preds = %89, %89
  ret void

92:                                               ; preds = %89
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #5

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { 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 12}
!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 = !{!13, !13, i64 0}
!16 = !{!12, !13, i64 8}


; 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"

%struct._MatNd = type { ptr, i32, i32, i32, i8 }

@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_rowLerp = external hidden unnamed_addr constant [14 x i8], align 1
@.str.250 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.251 = external hidden unnamed_addr constant [43 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

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

; Function Attrs: mustprogress 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 void @MatNd_copy(ptr noundef, ptr noundef) local_unnamed_addr #4

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @MatNd_getRowView(ptr dead_on_unwind noalias writable sret(%struct._MatNd) align 8, ptr noundef, i32 noundef) local_unnamed_addr #4

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

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

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

10:                                               ; preds = %3
  %11 = load ptr, ptr @stderr, align 8, !tbaa !13
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.MatNd_rowLerp, i32 noundef 4614, ptr noundef nonnull @.str.250) #6
  %13 = load ptr, ptr @stderr, align 8, !tbaa !13
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.251) #6
  %15 = load ptr, ptr @stderr, align 8, !tbaa !13
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.4) #6
  tail call void @print_trace() #7
  tail call void @exit(i32 noundef 1) #8
  unreachable

17:                                               ; preds = %3
  tail call void @MatNd_reshape(ptr noundef %0, i32 noundef 1, i32 noundef %7)
  %18 = icmp eq i32 %9, 1
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  tail call void @MatNd_copy(ptr noundef %0, ptr noundef nonnull %1)
  br label %41

20:                                               ; preds = %17
  %21 = icmp eq i32 %7, 0
  br i1 %21, label %41, label %22

22:                                               ; preds = %20
  %23 = fcmp ugt double %2, 0.000000e+00
  br i1 %23, label %26, label %24

24:                                               ; preds = %22
  %25 = tail call ptr @MatNd_getRowPtr(ptr noundef nonnull %1, i32 noundef 0)
  tail call void @MatNd_fromArray(ptr noundef %0, ptr noundef %25, i32 noundef %7)
  br label %41

26:                                               ; preds = %22
  %27 = fcmp ult double %2, 1.000000e+00
  br i1 %27, label %31, label %28

28:                                               ; preds = %26
  %29 = add i32 %9, -1
  %30 = tail call ptr @MatNd_getRowPtr(ptr noundef nonnull %1, i32 noundef %29)
  tail call void @MatNd_fromArray(ptr noundef %0, ptr noundef %30, i32 noundef %7)
  br label %41

31:                                               ; preds = %26
  %32 = uitofp i32 %9 to double
  %33 = fadd double %32, -1.000000e+00
  %34 = fmul double %33, %2
  %35 = tail call double @llvm.floor.f64(double %34)
  %36 = fptoui double %35 to i32
  %37 = tail call double @llvm.ceil.f64(double %34)
  %38 = fptoui double %37 to i32
  %39 = uitofp i32 %36 to double
  %40 = fsub double %34, %39
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #7
  call void @MatNd_getRowView(ptr dead_on_unwind nonnull writable sret(%struct._MatNd) align 8 %4, ptr noundef nonnull %1, i32 noundef %36)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #7
  call void @MatNd_getRowView(ptr dead_on_unwind nonnull writable sret(%struct._MatNd) align 8 %5, ptr noundef nonnull %1, i32 noundef %38)
  call void @MatNd_sub(ptr noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %4)
  call void @MatNd_constMulSelf(ptr noundef %0, double noundef %40)
  call void @MatNd_addSelf(ptr noundef %0, ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #7
  br label %41

41:                                               ; preds = %20, %31, %28, %24, %19
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #5

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 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { cold nounwind }
attributes #7 = { nounwind }
attributes #8 = { 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 12}
!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 8}
!13 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass