; LLVM IR from Kashery/fabrik-solver :: src (points)

; 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.point3D = type { double, double, double, ptr, ptr, i8, i8, i8 }

; 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: nounwind uwtable
declare dso_local double @find_dist3d(ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @find_bet3d(ptr noundef %0, ptr noundef %1, double noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, 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 8, ptr %7) #3
  %9 = call noalias ptr @malloc(i64 noundef 48) #4
  store ptr %9, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call double @find_dist3d(ptr noundef %10, ptr noundef %11)
  store double %12, ptr %8, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.point3D, ptr %13, i32 0, i32 0
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.point3D, ptr %16, i32 0, i32 0
  store double %15, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.point3D, ptr %18, i32 0, i32 1
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.point3D, ptr %21, i32 0, i32 1
  store double %20, ptr %22, align 8, !tbaa !14
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.point3D, ptr %23, i32 0, i32 2
  %25 = load double, ptr %24, align 8, !tbaa !15
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.point3D, ptr %26, i32 0, i32 2
  store double %25, ptr %27, align 8, !tbaa !15
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.point3D, ptr %28, i32 0, i32 5
  %30 = load i8, ptr %29, align 8, !tbaa !16, !range !17, !noundef !18
  %31 = trunc i8 %30 to i1
  br i1 %31, label %37, label %32

32:                                               ; preds = %3
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.point3D, ptr %33, i32 0, i32 5
  %35 = load i8, ptr %34, align 8, !tbaa !16, !range !17, !noundef !18
  %36 = trunc i8 %35 to i1
  br i1 %36, label %37, label %55

37:                                               ; preds = %32, %3
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.point3D, ptr %38, i32 0, i32 0
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load double, ptr %6, align 8, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.point3D, ptr %42, i32 0, i32 0
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.point3D, ptr %45, i32 0, i32 0
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = fsub double %44, %47
  %49 = fmul double %41, %48
  %50 = load double, ptr %8, align 8, !tbaa !9
  %51 = fdiv double %49, %50
  %52 = fadd double %40, %51
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.point3D, ptr %53, i32 0, i32 0
  store double %52, ptr %54, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %37, %32
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.point3D, ptr %56, i32 0, i32 6
  %58 = load i8, ptr %57, align 1, !tbaa !19, !range !17, !noundef !18
  %59 = trunc i8 %58 to i1
  br i1 %59, label %65, label %60

60:                                               ; preds = %55
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.point3D, ptr %61, i32 0, i32 6
  %63 = load i8, ptr %62, align 1, !tbaa !19, !range !17, !noundef !18
  %64 = trunc i8 %63 to i1
  br i1 %64, label %65, label %83

65:                                               ; preds = %60, %55
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.point3D, ptr %66, i32 0, i32 1
  %68 = load double, ptr %67, align 8, !tbaa !14
  %69 = load double, ptr %6, align 8, !tbaa !9
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.point3D, ptr %70, i32 0, i32 1
  %72 = load double, ptr %71, align 8, !tbaa !14
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.point3D, ptr %73, i32 0, i32 1
  %75 = load double, ptr %74, align 8, !tbaa !14
  %76 = fsub double %72, %75
  %77 = fmul double %69, %76
  %78 = load double, ptr %8, align 8, !tbaa !9
  %79 = fdiv double %77, %78
  %80 = fadd double %68, %79
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.point3D, ptr %81, i32 0, i32 1
  store double %80, ptr %82, align 8, !tbaa !14
  br label %83

83:                                               ; preds = %65, %60
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.point3D, ptr %84, i32 0, i32 7
  %86 = load i8, ptr %85, align 2, !tbaa !20, !range !17, !noundef !18
  %87 = trunc i8 %86 to i1
  br i1 %87, label %93, label %88

88:                                               ; preds = %83
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.point3D, ptr %89, i32 0, i32 7
  %91 = load i8, ptr %90, align 2, !tbaa !20, !range !17, !noundef !18
  %92 = trunc i8 %91 to i1
  br i1 %92, label %93, label %111

93:                                               ; preds = %88, %83
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.point3D, ptr %94, i32 0, i32 2
  %96 = load double, ptr %95, align 8, !tbaa !15
  %97 = load double, ptr %6, align 8, !tbaa !9
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.point3D, ptr %98, i32 0, i32 2
  %100 = load double, ptr %99, align 8, !tbaa !15
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.point3D, ptr %101, i32 0, i32 2
  %103 = load double, ptr %102, align 8, !tbaa !15
  %104 = fsub double %100, %103
  %105 = fmul double %97, %104
  %106 = load double, ptr %8, align 8, !tbaa !9
  %107 = fdiv double %105, %106
  %108 = fadd double %96, %107
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.point3D, ptr %109, i32 0, i32 2
  store double %108, ptr %110, align 8, !tbaa !15
  br label %111

111:                                              ; preds = %93, %88
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = load ptr, ptr %7, align 8, !tbaa !5
  %114 = call double @find_dist3d(ptr noundef %112, ptr noundef %113)
  %115 = load double, ptr %6, align 8, !tbaa !9
  %116 = fcmp une double %114, %115
  br i1 %116, label %117, label %122

117:                                              ; preds = %111
  %118 = load ptr, ptr %4, align 8, !tbaa !5
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = load double, ptr %6, align 8, !tbaa !9
  %121 = call ptr @normal_3d(ptr noundef %118, ptr noundef %119, double noundef %120)
  store ptr %121, ptr %7, align 8, !tbaa !5
  br label %122

122:                                              ; preds = %117, %111
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret ptr %123
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @normal_3d(ptr noundef, ptr noundef, double noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }
attributes #4 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"point3D", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !13, i64 41, !13, i64 42}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !13, i64 40}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!12, !13, i64 41}
!20 = !{!12, !13, i64 42}


; 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: nounwind uwtable
declare dso_local double @find_dist3d(ptr noundef, ptr noundef) local_unnamed_addr #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: nounwind uwtable
define dso_local ptr @find_bet3d(ptr noundef %0, ptr noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #2
  %5 = tail call double @find_dist3d(ptr noundef %0, ptr noundef %1)
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  %7 = load <2 x double>, ptr %1, align 8, !tbaa !5
  store <2 x double> %7, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  store double %9, ptr %10, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load i8, ptr %11, align 8, !tbaa !13, !range !14, !noundef !15
  %13 = trunc nuw i8 %12 to i1
  br i1 %13, label %18, label %14

14:                                               ; preds = %3
  %15 = getelementptr inbounds i8, ptr %1, i64 40
  %16 = load i8, ptr %15, align 8, !tbaa !13, !range !14, !noundef !15
  %17 = trunc nuw i8 %16 to i1
  br i1 %17, label %18, label %25

18:                                               ; preds = %14, %3
  %19 = load double, ptr %0, align 8, !tbaa !16
  %20 = extractelement <2 x double> %7, i64 0
  %21 = fsub double %20, %19
  %22 = fmul double %21, %2
  %23 = fdiv double %22, %5
  %24 = fadd double %19, %23
  store double %24, ptr %4, align 8, !tbaa !16
  br label %25

25:                                               ; preds = %18, %14
  %26 = getelementptr inbounds i8, ptr %0, i64 41
  %27 = load i8, ptr %26, align 1, !tbaa !17, !range !14, !noundef !15
  %28 = trunc nuw i8 %27 to i1
  br i1 %28, label %33, label %29

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %1, i64 41
  %31 = load i8, ptr %30, align 1, !tbaa !17, !range !14, !noundef !15
  %32 = trunc nuw i8 %31 to i1
  br i1 %32, label %33, label %41

33:                                               ; preds = %29, %25
  %34 = getelementptr inbounds i8, ptr %0, i64 8
  %35 = load double, ptr %34, align 8, !tbaa !18
  %36 = extractelement <2 x double> %7, i64 1
  %37 = fsub double %36, %35
  %38 = fmul double %37, %2
  %39 = fdiv double %38, %5
  %40 = fadd double %35, %39
  store double %40, ptr %6, align 8, !tbaa !18
  br label %41

41:                                               ; preds = %33, %29
  %42 = getelementptr inbounds i8, ptr %0, i64 42
  %43 = load i8, ptr %42, align 2, !tbaa !19, !range !14, !noundef !15
  %44 = trunc nuw i8 %43 to i1
  br i1 %44, label %49, label %45

45:                                               ; preds = %41
  %46 = getelementptr inbounds i8, ptr %1, i64 42
  %47 = load i8, ptr %46, align 2, !tbaa !19, !range !14, !noundef !15
  %48 = trunc nuw i8 %47 to i1
  br i1 %48, label %49, label %56

49:                                               ; preds = %45, %41
  %50 = getelementptr inbounds i8, ptr %0, i64 16
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = fsub double %9, %51
  %53 = fmul double %52, %2
  %54 = fdiv double %53, %5
  %55 = fadd double %51, %54
  store double %55, ptr %10, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %49, %45
  %57 = tail call double @find_dist3d(ptr noundef nonnull %0, ptr noundef nonnull %4)
  %58 = fcmp une double %57, %2
  br i1 %58, label %59, label %61

59:                                               ; preds = %56
  %60 = tail call ptr @normal_3d(ptr noundef nonnull %0, ptr noundef nonnull %4, double noundef %2)
  br label %61

61:                                               ; preds = %59, %56
  %.0 = phi ptr [ %60, %59 ], [ %4, %56 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @normal_3d(ptr noundef, ptr noundef, double noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 = { 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, !6, i64 16}
!10 = !{!"point3D", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 32, !12, i64 40, !12, i64 41, !12, i64 42}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!10, !12, i64 40}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !6, i64 0}
!17 = !{!10, !12, i64 41}
!18 = !{!10, !6, i64 8}
!19 = !{!10, !12, i64 42}


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