; 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.42 = external hidden unnamed_addr constant [42 x i8], align 1
@__func__.array_interpolate_equal = external hidden unnamed_addr constant [24 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [42 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_equal(ptr noundef %0, i32 noundef %1, i32 noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr noundef %6, ptr noundef %7) #3 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !9
  store i32 %2, ptr %12, align 4, !tbaa !9
  store double %3, ptr %13, align 8, !tbaa !11
  store double %4, ptr %14, align 8, !tbaa !11
  store double %5, ptr %15, align 8, !tbaa !11
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %24 = load double, ptr %13, align 8, !tbaa !11
  %25 = load double, ptr %14, align 8, !tbaa !11
  %26 = fcmp olt double %24, %25
  br i1 %26, label %27, label %32

27:                                               ; preds = %8
  %28 = load ptr, ptr %17, align 8, !tbaa !5
  %29 = load double, ptr %13, align 8, !tbaa !11
  %30 = load double, ptr %14, align 8, !tbaa !11
  %31 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %28, ptr noundef @.str.42, ptr noundef @__func__.array_interpolate_equal, i32 noundef 2791, double noundef %29, double noundef %30) #4
  store i32 1, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %103

32:                                               ; preds = %8
  %33 = load double, ptr %13, align 8, !tbaa !11
  %34 = load double, ptr %15, align 8, !tbaa !11
  %35 = fcmp ogt double %33, %34
  br i1 %35, label %36, label %41

36:                                               ; preds = %32
  %37 = load ptr, ptr %17, align 8, !tbaa !5
  %38 = load double, ptr %13, align 8, !tbaa !11
  %39 = load double, ptr %15, align 8, !tbaa !11
  %40 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %37, ptr noundef @.str.43, ptr noundef @__func__.array_interpolate_equal, i32 noundef 2796, double noundef %38, double noundef %39) #4
  store i32 1, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %103

41:                                               ; preds = %32
  %42 = load double, ptr %15, align 8, !tbaa !11
  %43 = load double, ptr %14, align 8, !tbaa !11
  %44 = fsub double %42, %43
  %45 = load i32, ptr %12, align 4, !tbaa !9
  %46 = sub nsw i32 %45, 1
  %47 = sitofp i32 %46 to double
  %48 = fdiv double %44, %47
  store double %48, ptr %20, align 8, !tbaa !11
  %49 = load double, ptr %13, align 8, !tbaa !11
  %50 = load double, ptr %14, align 8, !tbaa !11
  %51 = fsub double %49, %50
  %52 = load double, ptr %20, align 8, !tbaa !11
  %53 = fdiv double %51, %52
  %54 = fptosi double %53 to i32
  store i32 %54, ptr %18, align 4, !tbaa !9
  %55 = load i32, ptr %18, align 4, !tbaa !9
  %56 = sitofp i32 %55 to double
  %57 = load double, ptr %20, align 8, !tbaa !11
  %58 = fmul double %56, %57
  store double %58, ptr %21, align 8, !tbaa !11
  %59 = load double, ptr %13, align 8, !tbaa !11
  %60 = load double, ptr %21, align 8, !tbaa !11
  %61 = fsub double %59, %60
  %62 = load double, ptr %20, align 8, !tbaa !11
  %63 = fdiv double %61, %62
  store double %63, ptr %22, align 8, !tbaa !11
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %99, %41
  %65 = load i32, ptr %19, align 4, !tbaa !9
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %68, label %102

68:                                               ; preds = %64
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = load i32, ptr %18, align 4, !tbaa !9
  %72 = mul nsw i32 %70, %71
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds double, ptr %69, i64 %73
  %75 = load i32, ptr %19, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %74, i64 %76
  %78 = load double, ptr %77, align 8, !tbaa !11
  %79 = load double, ptr %22, align 8, !tbaa !11
  %80 = fsub double 1.000000e+00, %79
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load i32, ptr %11, align 4, !tbaa !9
  %83 = load i32, ptr %18, align 4, !tbaa !9
  %84 = add nsw i32 %83, 1
  %85 = mul nsw i32 %82, %84
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds double, ptr %81, i64 %86
  %88 = load i32, ptr %19, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %87, i64 %89
  %91 = load double, ptr %90, align 8, !tbaa !11
  %92 = load double, ptr %22, align 8, !tbaa !11
  %93 = fmul double %91, %92
  %94 = call double @llvm.fmuladd.f64(double %78, double %80, double %93)
  %95 = load ptr, ptr %16, align 8, !tbaa !5
  %96 = load i32, ptr %19, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds double, ptr %95, i64 %97
  store double %94, ptr %98, align 8, !tbaa !11
  br label %99

99:                                               ; preds = %68
  %100 = load i32, ptr %19, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %19, align 4, !tbaa !9
  br label %64, !llvm.loop !13

102:                                              ; preds = %64
  store i32 0, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %103

103:                                              ; preds = %102, %36, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  %104 = load i32, ptr %9, align 4
  ret i32 %104
}

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


; 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.42 = external hidden unnamed_addr constant [42 x i8], align 1
@__func__.array_interpolate_equal = external hidden unnamed_addr constant [24 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [42 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_equal(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr nocapture noundef writeonly %6, ptr nocapture noundef writeonly %7) local_unnamed_addr #2 {
  %9 = ptrtoint ptr %0 to i64
  %10 = ptrtoint ptr %6 to i64
  %11 = fcmp olt double %3, %4
  br i1 %11, label %12, label %14

12:                                               ; preds = %8
  %13 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str.42, ptr noundef nonnull @__func__.array_interpolate_equal, i32 noundef 2791, double noundef %3, double noundef %4) #4
  br label %.loopexit

14:                                               ; preds = %8
  %15 = fcmp ogt double %3, %5
  br i1 %15, label %16, label %18

16:                                               ; preds = %14
  %17 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str.43, ptr noundef nonnull @__func__.array_interpolate_equal, i32 noundef 2796, double noundef %3, double noundef %5) #4
  br label %.loopexit

18:                                               ; preds = %14
  %19 = fsub double %5, %4
  %20 = add nsw i32 %2, -1
  %21 = sitofp i32 %20 to double
  %22 = fdiv double %19, %21
  %23 = fsub double %3, %4
  %24 = fdiv double %23, %22
  %25 = fptosi double %24 to i32
  %26 = sitofp i32 %25 to double
  %27 = fmul double %22, %26
  %28 = fsub double %3, %27
  %29 = fdiv double %28, %22
  %30 = icmp sgt i32 %1, 0
  br i1 %30, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %18
  %31 = mul nsw i32 %25, %1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds double, ptr %0, i64 %32
  %34 = fsub double 1.000000e+00, %29
  %35 = add nsw i32 %25, 1
  %36 = mul nsw i32 %35, %1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %0, i64 %37
  %wide.trip.count = zext nneg i32 %1 to i64
  %min.iters.check = icmp ult i32 %1, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %39 = sub i64 %10, %9
  %40 = shl nsw i64 %37, 3
  %41 = sub i64 %39, %40
  %diff.check = icmp ult i64 %41, 32
  %42 = shl nsw i64 %32, 3
  %43 = sub i64 %39, %42
  %diff.check45 = icmp ult i64 %43, 32
  %conflict.rdx = or i1 %diff.check, %diff.check45
  br i1 %conflict.rdx, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483644
  %broadcast.splatinsert = insertelement <2 x double> poison, double %29, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert49 = insertelement <2 x double> poison, double %34, i64 0
  %broadcast.splat50 = shufflevector <2 x double> %broadcast.splatinsert49, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %44 = getelementptr inbounds double, ptr %33, i64 %index
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %wide.load = load <2 x double>, ptr %44, align 8, !tbaa !5
  %wide.load46 = load <2 x double>, ptr %45, align 8, !tbaa !5
  %46 = getelementptr inbounds double, ptr %38, i64 %index
  %47 = getelementptr inbounds i8, ptr %46, i64 16
  %wide.load47 = load <2 x double>, ptr %46, align 8, !tbaa !5
  %wide.load48 = load <2 x double>, ptr %47, align 8, !tbaa !5
  %48 = fmul <2 x double> %broadcast.splat, %wide.load47
  %49 = fmul <2 x double> %broadcast.splat, %wide.load48
  %50 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %wide.load, <2 x double> %broadcast.splat50, <2 x double> %48)
  %51 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %wide.load46, <2 x double> %broadcast.splat50, <2 x double> %49)
  %52 = getelementptr inbounds double, ptr %6, i64 %index
  %53 = getelementptr inbounds i8, ptr %52, i64 16
  store <2 x double> %50, ptr %52, align 8, !tbaa !5
  store <2 x double> %51, ptr %53, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %54 = icmp eq i64 %index.next, %n.vec
  br i1 %54, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %55 = getelementptr inbounds double, ptr %33, i64 %indvars.iv.ph
  %56 = load double, ptr %55, align 8, !tbaa !5
  %57 = getelementptr inbounds double, ptr %38, i64 %indvars.iv.ph
  %58 = load double, ptr %57, align 8, !tbaa !5
  %59 = fmul double %29, %58
  %60 = tail call double @llvm.fmuladd.f64(double %56, double %34, double %59)
  %61 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.ph
  store double %60, ptr %61, align 8, !tbaa !5
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %62 = add nsw i64 %wide.trip.count, -1
  %63 = icmp eq i64 %indvars.iv.ph, %62
  br i1 %63, label %.loopexit, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %64 = getelementptr inbounds double, ptr %33, i64 %indvars.iv
  %65 = load double, ptr %64, align 8, !tbaa !5
  %66 = getelementptr inbounds double, ptr %38, i64 %indvars.iv
  %67 = load double, ptr %66, align 8, !tbaa !5
  %68 = fmul double %29, %67
  %69 = tail call double @llvm.fmuladd.f64(double %65, double %34, double %68)
  %70 = getelementptr inbounds double, ptr %6, i64 %indvars.iv
  store double %69, ptr %70, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %71 = getelementptr inbounds double, ptr %33, i64 %indvars.iv.next
  %72 = load double, ptr %71, align 8, !tbaa !5
  %73 = getelementptr inbounds double, ptr %38, i64 %indvars.iv.next
  %74 = load double, ptr %73, align 8, !tbaa !5
  %75 = fmul double %29, %74
  %76 = tail call double @llvm.fmuladd.f64(double %72, double %34, double %75)
  %77 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.next
  store double %76, ptr %77, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %.loopexit, label %scalar.ph, !llvm.loop !13

.loopexit:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %18, %16, %12
  %.0 = phi i32 [ 1, %12 ], [ 1, %16 ], [ 0, %18 ], [ 0, %middle.block ], [ 0, %scalar.ph ], [ 0, %scalar.ph.prol.loopexit ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass