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

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

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @r8poly_value_2d(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = mul i64 %18, 8
  %20 = call noalias ptr @malloc(i64 noundef %19) #6
  store ptr %20, ptr %15, align 8, !tbaa !9
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %30, %5
  %22 = load i32, ptr %13, align 4, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %25, label %33

25:                                               ; preds = %21
  %26 = load ptr, ptr %15, align 8, !tbaa !9
  %27 = load i32, ptr %13, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds double, ptr %26, i64 %28
  store double 0.000000e+00, ptr %29, align 8, !tbaa !11
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %13, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %13, align 4, !tbaa !5
  br label %21, !llvm.loop !13

33:                                               ; preds = %21
  store i32 0, ptr %14, align 4, !tbaa !5
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %94, %33
  %35 = load i32, ptr %16, align 4, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = icmp sle i32 %35, %36
  br i1 %37, label %38, label %97

38:                                               ; preds = %34
  %39 = load i32, ptr %16, align 4, !tbaa !5
  store i32 %39, ptr %11, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %90, %38
  %41 = load i32, ptr %11, align 4, !tbaa !5
  %42 = icmp sle i32 0, %41
  br i1 %42, label %43, label %93

43:                                               ; preds = %40
  %44 = load i32, ptr %16, align 4, !tbaa !5
  %45 = load i32, ptr %11, align 4, !tbaa !5
  %46 = sub nsw i32 %44, %45
  store i32 %46, ptr %12, align 4, !tbaa !5
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %84, %43
  %48 = load i32, ptr %13, align 4, !tbaa !5
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %51, label %87

51:                                               ; preds = %47
  %52 = load ptr, ptr %15, align 8, !tbaa !9
  %53 = load i32, ptr %13, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %52, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = load ptr, ptr %7, align 8, !tbaa !9
  %58 = load i32, ptr %14, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = load ptr, ptr %9, align 8, !tbaa !9
  %63 = load i32, ptr %13, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %62, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = load i32, ptr %11, align 4, !tbaa !5
  %68 = sitofp i32 %67 to double
  %69 = call double @pow(double noundef %66, double noundef %68) #5
  %70 = fmul double %61, %69
  %71 = load ptr, ptr %10, align 8, !tbaa !9
  %72 = load i32, ptr %13, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds double, ptr %71, i64 %73
  %75 = load double, ptr %74, align 8, !tbaa !11
  %76 = load i32, ptr %12, align 4, !tbaa !5
  %77 = sitofp i32 %76 to double
  %78 = call double @pow(double noundef %75, double noundef %77) #5
  %79 = call double @llvm.fmuladd.f64(double %70, double %78, double %56)
  %80 = load ptr, ptr %15, align 8, !tbaa !9
  %81 = load i32, ptr %13, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds double, ptr %80, i64 %82
  store double %79, ptr %83, align 8, !tbaa !11
  br label %84

84:                                               ; preds = %51
  %85 = load i32, ptr %13, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %13, align 4, !tbaa !5
  br label %47, !llvm.loop !15

87:                                               ; preds = %47
  %88 = load i32, ptr %14, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %14, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %87
  %91 = load i32, ptr %11, align 4, !tbaa !5
  %92 = add nsw i32 %91, -1
  store i32 %92, ptr %11, align 4, !tbaa !5
  br label %40, !llvm.loop !16

93:                                               ; preds = %40
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %16, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %16, align 4, !tbaa !5
  br label %34, !llvm.loop !17

97:                                               ; preds = %34
  %98 = load ptr, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret ptr %98
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind allocsize(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 "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 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 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !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}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !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"

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind uwtable
define dso_local noalias noundef ptr @r8poly_value_2d(i32 noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4) local_unnamed_addr #3 {
  %6 = sext i32 %2 to i64
  %7 = shl nsw i64 %6, 3
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #5
  %9 = icmp sgt i32 %2, 0
  br i1 %9, label %.preheader35, label %._crit_edge

.preheader35:                                     ; preds = %5
  %10 = zext nneg i32 %2 to i64
  %11 = shl nuw nsw i64 %10, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 %11, i1 false), !tbaa !5
  %.not43 = icmp slt i32 %0, 0
  br i1 %.not43, label %._crit_edge, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %.preheader35
  %wide.trip.count = zext nneg i32 %2 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %12 = icmp eq i32 %2, 1
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph38.us.us.preheader

.lr.ph38.us.us.preheader:                         ; preds = %._crit_edge42.split.us.us, %.preheader.us.preheader
  %.045.us = phi i32 [ %14, %._crit_edge42.split.us.us ], [ 0, %.preheader.us.preheader ]
  %.03144.us = phi i64 [ %indvars.iv.next52, %._crit_edge42.split.us.us ], [ 0, %.preheader.us.preheader ]
  %sext = shl i64 %.03144.us, 32
  %13 = ashr exact i64 %sext, 32
  br label %.lr.ph38.us.us

._crit_edge42.split.us.us:                        ; preds = %._crit_edge.us.us
  %14 = add nuw i32 %.045.us, 1
  %exitcond54.not = icmp eq i32 %.045.us, %0
  br i1 %exitcond54.not, label %._crit_edge, label %.lr.ph38.us.us.preheader, !llvm.loop !9

.lr.ph38.us.us:                                   ; preds = %.lr.ph38.us.us.preheader, %._crit_edge.us.us
  %indvars.iv51 = phi i64 [ %13, %.lr.ph38.us.us.preheader ], [ %indvars.iv.next52, %._crit_edge.us.us ]
  %.03040.us.us = phi i32 [ %.045.us, %.lr.ph38.us.us.preheader ], [ %52, %._crit_edge.us.us ]
  %15 = sub nuw nsw i32 %.045.us, %.03040.us.us
  %16 = getelementptr inbounds double, ptr %1, i64 %indvars.iv51
  %17 = uitofp nneg i32 %.03040.us.us to double
  %18 = sitofp i32 %15 to double
  br i1 %12, label %._crit_edge.us.us.unr-lcssa, label %.lr.ph38.us.us.new

.lr.ph38.us.us.new:                               ; preds = %.lr.ph38.us.us, %.lr.ph38.us.us.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph38.us.us.new ], [ 0, %.lr.ph38.us.us ]
  %niter = phi i64 [ %niter.next.1, %.lr.ph38.us.us.new ], [ 0, %.lr.ph38.us.us ]
  %19 = getelementptr inbounds double, ptr %8, i64 %indvars.iv
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = load double, ptr %16, align 8, !tbaa !5
  %22 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = tail call double @pow(double noundef %23, double noundef %17) #6
  %25 = fmul double %21, %24
  %26 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = tail call double @pow(double noundef %27, double noundef %18) #6
  %29 = tail call double @llvm.fmuladd.f64(double %25, double %28, double %20)
  store double %29, ptr %19, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %30 = getelementptr inbounds double, ptr %8, i64 %indvars.iv.next
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = load double, ptr %16, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = tail call double @pow(double noundef %34, double noundef %17) #6
  %36 = fmul double %32, %35
  %37 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.next
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = tail call double @pow(double noundef %38, double noundef %18) #6
  %40 = tail call double @llvm.fmuladd.f64(double %36, double %39, double %31)
  store double %40, ptr %30, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.us.unr-lcssa, label %.lr.ph38.us.us.new, !llvm.loop !11

._crit_edge.us.us.unr-lcssa:                      ; preds = %.lr.ph38.us.us.new, %.lr.ph38.us.us
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph38.us.us ], [ %indvars.iv.next.1, %.lr.ph38.us.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us.us, label %._crit_edge.us.us.epilog-lcssa

._crit_edge.us.us.epilog-lcssa:                   ; preds = %._crit_edge.us.us.unr-lcssa
  %41 = getelementptr inbounds double, ptr %8, i64 %indvars.iv.unr
  %42 = load double, ptr %41, align 8, !tbaa !5
  %43 = load double, ptr %16, align 8, !tbaa !5
  %44 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.unr
  %45 = load double, ptr %44, align 8, !tbaa !5
  %46 = tail call double @pow(double noundef %45, double noundef %17) #6
  %47 = fmul double %43, %46
  %48 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.unr
  %49 = load double, ptr %48, align 8, !tbaa !5
  %50 = tail call double @pow(double noundef %49, double noundef %18) #6
  %51 = tail call double @llvm.fmuladd.f64(double %47, double %50, double %42)
  store double %51, ptr %41, align 8, !tbaa !5
  br label %._crit_edge.us.us

._crit_edge.us.us:                                ; preds = %._crit_edge.us.us.unr-lcssa, %._crit_edge.us.us.epilog-lcssa
  %indvars.iv.next52 = add nsw i64 %indvars.iv51, 1
  %52 = add nsw i32 %.03040.us.us, -1
  %53 = icmp sgt i32 %.03040.us.us, 0
  br i1 %53, label %.lr.ph38.us.us, label %._crit_edge42.split.us.us, !llvm.loop !12

._crit_edge:                                      ; preds = %._crit_edge42.split.us.us, %5, %.preheader35
  ret ptr %8
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind allocsize(0) }
attributes #6 = { 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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: ADCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass