; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (arrays)

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

@.str.30 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.array_interpolate_one_growing_closeby = external hidden unnamed_addr constant [38 x i8], align 1

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

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

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @array_interpolate_one_growing_closeby(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, ptr noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef %8) #3 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca double, align 8
  %23 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i32 %1, ptr %12, align 4, !tbaa !9
  store i32 %2, ptr %13, align 4, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !9
  store double %4, ptr %15, align 8, !tbaa !11
  store ptr %5, ptr %16, align 8, !tbaa !5
  store i32 %6, ptr %17, align 4, !tbaa !9
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %24 = load ptr, ptr %16, align 8, !tbaa !5
  %25 = load i32, ptr %24, align 4, !tbaa !9
  store i32 %25, ptr %20, align 4, !tbaa !9
  %26 = load ptr, ptr %16, align 8, !tbaa !5
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %21, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %56, %9
  %30 = load double, ptr %15, align 8, !tbaa !11
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = load i32, ptr %20, align 4, !tbaa !9
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = mul nsw i32 %32, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %31, i64 %35
  %37 = load i32, ptr %14, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %36, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = fcmp olt double %30, %40
  br i1 %41, label %42, label %57

42:                                               ; preds = %29
  %43 = load i32, ptr %20, align 4, !tbaa !9
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr %20, align 4, !tbaa !9
  %45 = load i32, ptr %20, align 4, !tbaa !9
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %56

47:                                               ; preds = %42
  %48 = load ptr, ptr %19, align 8, !tbaa !5
  %49 = load double, ptr %15, align 8, !tbaa !11
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = load i32, ptr %14, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %50, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %48, ptr noundef @.str.30, ptr noundef @__func__.array_interpolate_one_growing_closeby, i32 noundef 2363, double noundef %49, double noundef %54) #4
  store i32 1, ptr %10, align 4
  store i32 1, ptr %23, align 4
  br label %160

56:                                               ; preds = %42
  br label %29, !llvm.loop !13

57:                                               ; preds = %29
  %58 = load i32, ptr %20, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %21, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %94, %57
  %61 = load double, ptr %15, align 8, !tbaa !11
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = load i32, ptr %21, align 4, !tbaa !9
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = mul nsw i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds double, ptr %62, i64 %66
  %68 = load i32, ptr %14, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %67, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = fcmp ogt double %61, %71
  br i1 %72, label %73, label %95

73:                                               ; preds = %60
  %74 = load i32, ptr %21, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %21, align 4, !tbaa !9
  %76 = load i32, ptr %21, align 4, !tbaa !9
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = sub nsw i32 %77, 1
  %79 = icmp sgt i32 %76, %78
  br i1 %79, label %80, label %94

80:                                               ; preds = %73
  %81 = load ptr, ptr %19, align 8, !tbaa !5
  %82 = load double, ptr %15, align 8, !tbaa !11
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = load i32, ptr %13, align 4, !tbaa !9
  %85 = sub nsw i32 %84, 1
  %86 = load i32, ptr %12, align 4, !tbaa !9
  %87 = mul nsw i32 %85, %86
  %88 = load i32, ptr %14, align 4, !tbaa !9
  %89 = add nsw i32 %87, %88
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds double, ptr %83, i64 %90
  %92 = load double, ptr %91, align 8, !tbaa !11
  %93 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %81, ptr noundef @.str.31, ptr noundef @__func__.array_interpolate_one_growing_closeby, i32 noundef 2372, double noundef %82, double noundef %92) #4
  store i32 1, ptr %10, align 4
  store i32 1, ptr %23, align 4
  br label %160

94:                                               ; preds = %73
  br label %60, !llvm.loop !15

95:                                               ; preds = %60
  %96 = load i32, ptr %21, align 4, !tbaa !9
  %97 = sub nsw i32 %96, 1
  store i32 %97, ptr %20, align 4, !tbaa !9
  %98 = load i32, ptr %20, align 4, !tbaa !9
  %99 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 %98, ptr %99, align 4, !tbaa !9
  %100 = load double, ptr %15, align 8, !tbaa !11
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = load i32, ptr %20, align 4, !tbaa !9
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = mul nsw i32 %102, %103
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds double, ptr %101, i64 %105
  %107 = load i32, ptr %14, align 4, !tbaa !9
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds double, ptr %106, i64 %108
  %110 = load double, ptr %109, align 8, !tbaa !11
  %111 = fsub double %100, %110
  %112 = load ptr, ptr %11, align 8, !tbaa !5
  %113 = load i32, ptr %21, align 4, !tbaa !9
  %114 = load i32, ptr %12, align 4, !tbaa !9
  %115 = mul nsw i32 %113, %114
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds double, ptr %112, i64 %116
  %118 = load i32, ptr %14, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds double, ptr %117, i64 %119
  %121 = load double, ptr %120, align 8, !tbaa !11
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = load i32, ptr %20, align 4, !tbaa !9
  %124 = load i32, ptr %12, align 4, !tbaa !9
  %125 = mul nsw i32 %123, %124
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds double, ptr %122, i64 %126
  %128 = load i32, ptr %14, align 4, !tbaa !9
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds double, ptr %127, i64 %129
  %131 = load double, ptr %130, align 8, !tbaa !11
  %132 = fsub double %121, %131
  %133 = fdiv double %111, %132
  store double %133, ptr %22, align 8, !tbaa !11
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = load i32, ptr %20, align 4, !tbaa !9
  %136 = load i32, ptr %12, align 4, !tbaa !9
  %137 = mul nsw i32 %135, %136
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds double, ptr %134, i64 %138
  %140 = load i32, ptr %17, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds double, ptr %139, i64 %141
  %143 = load double, ptr %142, align 8, !tbaa !11
  %144 = load double, ptr %22, align 8, !tbaa !11
  %145 = fsub double 1.000000e+00, %144
  %146 = load ptr, ptr %11, align 8, !tbaa !5
  %147 = load i32, ptr %21, align 4, !tbaa !9
  %148 = load i32, ptr %12, align 4, !tbaa !9
  %149 = mul nsw i32 %147, %148
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds double, ptr %146, i64 %150
  %152 = load i32, ptr %17, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds double, ptr %151, i64 %153
  %155 = load double, ptr %154, align 8, !tbaa !11
  %156 = load double, ptr %22, align 8, !tbaa !11
  %157 = fmul double %155, %156
  %158 = call double @llvm.fmuladd.f64(double %143, double %145, double %157)
  %159 = load ptr, ptr %18, align 8, !tbaa !5
  store double %158, ptr %159, align 8, !tbaa !11
  store i32 0, ptr %10, align 4
  store i32 1, ptr %23, align 4
  br label %160

160:                                              ; preds = %95, %80, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  %161 = load i32, ptr %10, align 4
  ret i32 %161
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@.str.30 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.array_interpolate_one_growing_closeby = external hidden unnamed_addr constant [38 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @array_interpolate_one_growing_closeby(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, ptr nocapture noundef %5, i32 noundef %6, ptr nocapture noundef writeonly %7, ptr nocapture noundef writeonly %8) local_unnamed_addr #2 {
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = sext i32 %3 to i64
  %invariant.gep = getelementptr double, ptr %0, i64 %11
  %12 = sext i32 %10 to i64
  %13 = sext i32 %1 to i64
  br label %14

14:                                               ; preds = %20, %9
  %indvars.iv = phi i64 [ %indvars.iv.next, %20 ], [ %12, %9 ]
  %15 = mul nsw i64 %indvars.iv, %13
  %gep = getelementptr double, ptr %invariant.gep, i64 %15
  %16 = load double, ptr %gep, align 8, !tbaa !9
  %17 = fcmp ogt double %16, %4
  br i1 %17, label %20, label %.preheader

.preheader:                                       ; preds = %14
  %18 = add nsw i32 %2, -1
  %19 = sext i32 %18 to i64
  br label %25

20:                                               ; preds = %14
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %21 = icmp slt i64 %indvars.iv, 1
  br i1 %21, label %22, label %14, !llvm.loop !11

22:                                               ; preds = %20
  %23 = load double, ptr %invariant.gep, align 8, !tbaa !9
  %24 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.30, ptr noundef nonnull @__func__.array_interpolate_one_growing_closeby, i32 noundef 2363, double noundef %4, double noundef %23) #3
  br label %57

25:                                               ; preds = %.preheader, %31
  %indvars.iv76 = phi i64 [ %indvars.iv, %.preheader ], [ %indvars.iv.next77, %31 ]
  %indvars.iv.next77 = add nsw i64 %indvars.iv76, 1
  %26 = mul nsw i64 %indvars.iv.next77, %13
  %27 = getelementptr inbounds double, ptr %0, i64 %26
  %28 = getelementptr inbounds double, ptr %27, i64 %11
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = fcmp olt double %29, %4
  br i1 %30, label %31, label %39

31:                                               ; preds = %25
  %.not = icmp slt i64 %indvars.iv.next77, %19
  br i1 %.not, label %25, label %32, !llvm.loop !13

32:                                               ; preds = %31
  %33 = mul nsw i32 %18, %1
  %34 = add nsw i32 %33, %3
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.31, ptr noundef nonnull @__func__.array_interpolate_one_growing_closeby, i32 noundef 2372, double noundef %4, double noundef %37) #3
  br label %57

39:                                               ; preds = %25
  %40 = trunc nsw i64 %indvars.iv76 to i32
  store i32 %40, ptr %5, align 4, !tbaa !5
  %41 = mul nsw i32 %40, %1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds double, ptr %0, i64 %42
  %44 = getelementptr inbounds double, ptr %43, i64 %11
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = fsub double %4, %45
  %47 = fsub double %29, %45
  %48 = fdiv double %46, %47
  %49 = sext i32 %6 to i64
  %50 = getelementptr inbounds double, ptr %43, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = fsub double 1.000000e+00, %48
  %53 = getelementptr inbounds double, ptr %27, i64 %49
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = fmul double %54, %48
  %56 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %55)
  store double %56, ptr %7, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %39, %32, %22
  %.0 = phi i32 [ 1, %22 ], [ 1, %32 ], [ 0, %39 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"int", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass