; LLVM IR from PymZoR/S-curve-Planner :: lib (bbpr)

; 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 speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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

; Function Attrs: nounwind uwtable
define dso_local void @recurse(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca [2 x double], align 16
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds double, ptr %22, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !11
  %27 = call double @llvm.fabs.f64(double %26)
  %28 = fcmp olt double %27, 0x3C9CD2B297D889BC
  br i1 %28, label %29, label %32

29:                                               ; preds = %7
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr %11, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %29, %7
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %48

35:                                               ; preds = %32
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds double, ptr %36, i64 2
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %39, i64 0
  store double %38, ptr %40, align 8, !tbaa !11
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = getelementptr inbounds double, ptr %41, i64 1
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %44, i64 1
  store double %43, ptr %45, align 8, !tbaa !11
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  store double 0.000000e+00, ptr %46, align 8, !tbaa !11
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %47, align 4, !tbaa !9
  store i32 1, ptr %21, align 4
  br label %142

48:                                               ; preds = %32
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = mul i64 %51, 8
  %53 = call noalias ptr @malloc(i64 noundef %52) #6
  store ptr %53, ptr %15, align 8, !tbaa !5
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = mul i64 %56, 8
  %58 = call noalias ptr @malloc(i64 noundef %57) #6
  store ptr %58, ptr %16, align 8, !tbaa !5
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %59, i64 0
  store double 1.000000e+00, ptr %60, align 8, !tbaa !11
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %61, i64 0
  store double 1.000000e+00, ptr %62, align 8, !tbaa !11
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds double, ptr %63, i64 0
  %65 = load double, ptr %64, align 8, !tbaa !11
  %66 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 0
  store double %65, ptr %66, align 16, !tbaa !11
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = getelementptr inbounds double, ptr %67, i64 1
  %69 = load double, ptr %68, align 8, !tbaa !11
  %70 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 1
  store double %69, ptr %70, align 8, !tbaa !11
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %71, align 4, !tbaa !9
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = load ptr, ptr %15, align 8, !tbaa !5
  %75 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 0
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  call void @find_quad(ptr noundef %72, i32 noundef %73, ptr noundef %74, ptr noundef %75, ptr noundef %76, ptr noundef %77)
  %78 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 0
  %79 = load double, ptr %78, align 16, !tbaa !11
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds double, ptr %80, i64 0
  %82 = load double, ptr %81, align 8, !tbaa !11
  %83 = fsub double %79, %82
  %84 = call double @llvm.fabs.f64(double %83)
  %85 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 1
  %86 = load double, ptr %85, align 8, !tbaa !11
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = getelementptr inbounds double, ptr %87, i64 1
  %89 = load double, ptr %88, align 8, !tbaa !11
  %90 = fsub double %86, %89
  %91 = call double @llvm.fabs.f64(double %90)
  %92 = fadd double %84, %91
  store double %92, ptr %18, align 8, !tbaa !11
  %93 = load ptr, ptr %13, align 8, !tbaa !5
  %94 = load double, ptr %93, align 8, !tbaa !11
  %95 = fcmp olt double %94, 0x3D719799812DEA11
  br i1 %95, label %96, label %105

96:                                               ; preds = %48
  %97 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 0
  %98 = load double, ptr %97, align 16, !tbaa !11
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = getelementptr inbounds double, ptr %99, i64 0
  store double %98, ptr %100, align 8, !tbaa !11
  %101 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 1
  %102 = load double, ptr %101, align 8, !tbaa !11
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds double, ptr %103, i64 1
  store double %102, ptr %104, align 8, !tbaa !11
  br label %105

105:                                              ; preds = %96, %48
  %106 = load ptr, ptr %14, align 8, !tbaa !5
  %107 = load i32, ptr %106, align 4, !tbaa !9
  %108 = icmp sgt i32 %107, 5
  br i1 %108, label %109, label %112

109:                                              ; preds = %105
  %110 = load double, ptr %18, align 8, !tbaa !11
  %111 = fcmp olt double %110, 1.000000e-04
  br i1 %111, label %119, label %112

112:                                              ; preds = %109, %105
  %113 = load ptr, ptr %14, align 8, !tbaa !5
  %114 = load i32, ptr %113, align 4, !tbaa !9
  %115 = icmp sgt i32 %114, 20
  br i1 %115, label %116, label %139

116:                                              ; preds = %112
  %117 = load double, ptr %18, align 8, !tbaa !11
  %118 = fcmp olt double %117, 1.000000e-01
  br i1 %118, label %119, label %139

119:                                              ; preds = %116, %109
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = load i32, ptr %11, align 4, !tbaa !9
  %122 = load ptr, ptr %15, align 8, !tbaa !5
  call void @diff_poly(ptr noundef %120, i32 noundef %121, ptr noundef %122)
  %123 = load ptr, ptr %8, align 8, !tbaa !5
  %124 = load i32, ptr %9, align 4, !tbaa !9
  %125 = load ptr, ptr %15, align 8, !tbaa !5
  %126 = load i32, ptr %11, align 4, !tbaa !9
  %127 = sub nsw i32 %126, 1
  %128 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 0
  %129 = load ptr, ptr %13, align 8, !tbaa !5
  %130 = load ptr, ptr %14, align 8, !tbaa !5
  call void @recurse(ptr noundef %123, i32 noundef %124, ptr noundef %125, i32 noundef %127, ptr noundef %128, ptr noundef %129, ptr noundef %130)
  %131 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 0
  %132 = load double, ptr %131, align 16, !tbaa !11
  %133 = load ptr, ptr %12, align 8, !tbaa !5
  %134 = getelementptr inbounds double, ptr %133, i64 0
  store double %132, ptr %134, align 8, !tbaa !11
  %135 = getelementptr inbounds [2 x double], ptr %17, i64 0, i64 1
  %136 = load double, ptr %135, align 8, !tbaa !11
  %137 = load ptr, ptr %12, align 8, !tbaa !5
  %138 = getelementptr inbounds double, ptr %137, i64 1
  store double %136, ptr %138, align 8, !tbaa !11
  br label %139

139:                                              ; preds = %119, %116, %112
  %140 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %140) #5
  %141 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %141) #5
  store i32 0, ptr %21, align 4
  br label %142

142:                                              ; preds = %139, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  %143 = load i32, ptr %21, align 4
  switch i32 %143, label %145 [
    i32 0, label %144
    i32 1, label %144
  ]

144:                                              ; preds = %142, %142
  ret void

145:                                              ; preds = %142
  unreachable
}

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


; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local void @recurse(ptr nocapture noundef readnone %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr nocapture noundef %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #2 {
  %8 = alloca [2 x double], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #5
  %9 = sext i32 %3 to i64
  %10 = getelementptr inbounds double, ptr %2, i64 %9
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = tail call double @llvm.fabs.f64(double %11)
  %13 = fcmp olt double %12, 0x3C9CD2B297D889BC
  %14 = sext i1 %13 to i32
  %.0 = add nsw i32 %14, %3
  %15 = icmp eq i32 %.0, 2
  br i1 %15, label %16, label %22

16:                                               ; preds = %7
  %17 = getelementptr inbounds i8, ptr %2, i64 16
  %18 = load double, ptr %17, align 8, !tbaa !5
  store double %18, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %2, i64 8
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %4, i64 8
  store double %20, ptr %21, align 8, !tbaa !5
  store double 0.000000e+00, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %53

22:                                               ; preds = %7
  %23 = add nsw i32 %.0, 1
  %24 = sext i32 %23 to i64
  %25 = shl nsw i64 %24, 3
  %26 = tail call noalias ptr @malloc(i64 noundef %25) #6
  store double 1.000000e+00, ptr %26, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %4, i64 8
  %28 = load <2 x double>, ptr %4, align 8, !tbaa !5
  store <2 x double> %28, ptr %8, align 16, !tbaa !5
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @find_quad(ptr noundef nonnull %2, i32 noundef %.0, ptr noundef nonnull %26, ptr noundef nonnull %8, ptr noundef %5, ptr noundef nonnull %6)
  %29 = load double, ptr %4, align 8, !tbaa !5
  %30 = load <2 x double>, ptr %8, align 16, !tbaa !5
  %31 = extractelement <2 x double> %30, i64 0
  %32 = fsub double %31, %29
  %33 = call double @llvm.fabs.f64(double %32)
  %34 = load double, ptr %27, align 8, !tbaa !5
  %35 = extractelement <2 x double> %30, i64 1
  %36 = fsub double %35, %34
  %37 = call double @llvm.fabs.f64(double %36)
  %38 = fadd double %33, %37
  %39 = load double, ptr %5, align 8, !tbaa !5
  %40 = fcmp olt double %39, 0x3D719799812DEA11
  br i1 %40, label %41, label %42

41:                                               ; preds = %22
  store <2 x double> %30, ptr %4, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %41, %22
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = icmp sgt i32 %43, 5
  %45 = fcmp olt double %38, 1.000000e-04
  %or.cond = select i1 %44, i1 %45, i1 false
  br i1 %or.cond, label %49, label %46

46:                                               ; preds = %42
  %47 = icmp sgt i32 %43, 20
  %48 = fcmp olt double %38, 1.000000e-01
  %or.cond3 = select i1 %47, i1 %48, i1 false
  br i1 %or.cond3, label %49, label %52

49:                                               ; preds = %46, %42
  call void @diff_poly(ptr noundef nonnull %2, i32 noundef %.0, ptr noundef nonnull %26)
  %50 = add nsw i32 %.0, -1
  call void @recurse(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %26, i32 noundef %50, ptr noundef nonnull %8, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %51 = load <2 x double>, ptr %8, align 16, !tbaa !5
  store <2 x double> %51, ptr %4, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %49, %46
  call void @free(ptr noundef nonnull %26) #5
  br label %53

53:                                               ; preds = %52, %16
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass