; LLVM IR from jingweizhanghuai/Morn :: src/image (morn_image_geometry2)

; 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.fmuladd.f64(double, double, 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
define dso_local double @PointVerticalDistance(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr noundef %6, ptr noundef %7) #2 {
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  store double %0, ptr %9, align 8, !tbaa !5
  store double %1, ptr %10, align 8, !tbaa !5
  store double %2, ptr %11, align 8, !tbaa !5
  store double %3, ptr %12, align 8, !tbaa !5
  store double %4, ptr %13, align 8, !tbaa !5
  store double %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !9
  store ptr %7, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %25 = load double, ptr %14, align 8, !tbaa !5
  %26 = load double, ptr %12, align 8, !tbaa !5
  %27 = fsub double %25, %26
  store double %27, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %28 = load double, ptr %13, align 8, !tbaa !5
  %29 = load double, ptr %11, align 8, !tbaa !5
  %30 = fsub double %28, %29
  store double %30, ptr %21, align 8, !tbaa !5
  %31 = load double, ptr %20, align 8, !tbaa !5
  %32 = fcmp oeq double %31, 0.000000e+00
  br i1 %32, label %33, label %51

33:                                               ; preds = %8
  %34 = load double, ptr %9, align 8, !tbaa !5
  store double %34, ptr %17, align 8, !tbaa !5
  %35 = load double, ptr %12, align 8, !tbaa !5
  store double %35, ptr %18, align 8, !tbaa !5
  %36 = load double, ptr %10, align 8, !tbaa !5
  %37 = load double, ptr %18, align 8, !tbaa !5
  %38 = fsub double %36, %37
  %39 = fcmp ogt double %38, 0.000000e+00
  br i1 %39, label %40, label %44

40:                                               ; preds = %33
  %41 = load double, ptr %10, align 8, !tbaa !5
  %42 = load double, ptr %18, align 8, !tbaa !5
  %43 = fsub double %41, %42
  br label %49

44:                                               ; preds = %33
  %45 = load double, ptr %10, align 8, !tbaa !5
  %46 = load double, ptr %18, align 8, !tbaa !5
  %47 = fsub double %45, %46
  %48 = fsub double 0.000000e+00, %47
  br label %49

49:                                               ; preds = %44, %40
  %50 = phi double [ %43, %40 ], [ %48, %44 ]
  store double %50, ptr %19, align 8, !tbaa !5
  br label %123

51:                                               ; preds = %8
  %52 = load double, ptr %21, align 8, !tbaa !5
  %53 = fcmp oeq double %52, 0.000000e+00
  br i1 %53, label %54, label %72

54:                                               ; preds = %51
  %55 = load double, ptr %11, align 8, !tbaa !5
  store double %55, ptr %17, align 8, !tbaa !5
  %56 = load double, ptr %10, align 8, !tbaa !5
  store double %56, ptr %18, align 8, !tbaa !5
  %57 = load double, ptr %9, align 8, !tbaa !5
  %58 = load double, ptr %17, align 8, !tbaa !5
  %59 = fsub double %57, %58
  %60 = fcmp ogt double %59, 0.000000e+00
  br i1 %60, label %61, label %65

61:                                               ; preds = %54
  %62 = load double, ptr %9, align 8, !tbaa !5
  %63 = load double, ptr %17, align 8, !tbaa !5
  %64 = fsub double %62, %63
  br label %70

65:                                               ; preds = %54
  %66 = load double, ptr %9, align 8, !tbaa !5
  %67 = load double, ptr %17, align 8, !tbaa !5
  %68 = fsub double %66, %67
  %69 = fsub double 0.000000e+00, %68
  br label %70

70:                                               ; preds = %65, %61
  %71 = phi double [ %64, %61 ], [ %69, %65 ]
  store double %71, ptr %19, align 8, !tbaa !5
  br label %122

72:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %73 = load double, ptr %20, align 8, !tbaa !5
  %74 = load double, ptr %13, align 8, !tbaa !5
  %75 = load double, ptr %21, align 8, !tbaa !5
  %76 = load double, ptr %14, align 8, !tbaa !5
  %77 = fmul double %75, %76
  %78 = fneg double %77
  %79 = call double @llvm.fmuladd.f64(double %73, double %74, double %78)
  store double %79, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %80 = load double, ptr %20, align 8, !tbaa !5
  %81 = load double, ptr %10, align 8, !tbaa !5
  %82 = load double, ptr %21, align 8, !tbaa !5
  %83 = load double, ptr %9, align 8, !tbaa !5
  %84 = fmul double %82, %83
  %85 = call double @llvm.fmuladd.f64(double %80, double %81, double %84)
  store double %85, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  %86 = load double, ptr %20, align 8, !tbaa !5
  %87 = load double, ptr %20, align 8, !tbaa !5
  %88 = load double, ptr %21, align 8, !tbaa !5
  %89 = load double, ptr %21, align 8, !tbaa !5
  %90 = fmul double %88, %89
  %91 = call double @llvm.fmuladd.f64(double %86, double %87, double %90)
  store double %91, ptr %24, align 8, !tbaa !5
  %92 = load double, ptr %22, align 8, !tbaa !5
  %93 = load double, ptr %20, align 8, !tbaa !5
  %94 = load double, ptr %21, align 8, !tbaa !5
  %95 = load double, ptr %23, align 8, !tbaa !5
  %96 = fmul double %94, %95
  %97 = call double @llvm.fmuladd.f64(double %92, double %93, double %96)
  %98 = load double, ptr %24, align 8, !tbaa !5
  %99 = fdiv double %97, %98
  store double %99, ptr %17, align 8, !tbaa !5
  %100 = load double, ptr %20, align 8, !tbaa !5
  %101 = load double, ptr %17, align 8, !tbaa !5
  %102 = load double, ptr %22, align 8, !tbaa !5
  %103 = fneg double %102
  %104 = call double @llvm.fmuladd.f64(double %100, double %101, double %103)
  %105 = load double, ptr %21, align 8, !tbaa !5
  %106 = fdiv double %104, %105
  store double %106, ptr %18, align 8, !tbaa !5
  %107 = load double, ptr %9, align 8, !tbaa !5
  %108 = load double, ptr %17, align 8, !tbaa !5
  %109 = fsub double %107, %108
  %110 = load double, ptr %9, align 8, !tbaa !5
  %111 = load double, ptr %17, align 8, !tbaa !5
  %112 = fsub double %110, %111
  %113 = load double, ptr %10, align 8, !tbaa !5
  %114 = load double, ptr %18, align 8, !tbaa !5
  %115 = fsub double %113, %114
  %116 = load double, ptr %10, align 8, !tbaa !5
  %117 = load double, ptr %18, align 8, !tbaa !5
  %118 = fsub double %116, %117
  %119 = fmul double %115, %118
  %120 = call double @llvm.fmuladd.f64(double %109, double %112, double %119)
  %121 = call double @sqrt(double noundef %120) #4
  store double %121, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  br label %122

122:                                              ; preds = %72, %70
  br label %123

123:                                              ; preds = %122, %49
  %124 = load ptr, ptr %15, align 8, !tbaa !9
  %125 = icmp ne ptr %124, null
  br i1 %125, label %126, label %130

126:                                              ; preds = %123
  %127 = load double, ptr %17, align 8, !tbaa !5
  %128 = fptrunc double %127 to float
  %129 = load ptr, ptr %15, align 8, !tbaa !9
  store float %128, ptr %129, align 4, !tbaa !11
  br label %130

130:                                              ; preds = %126, %123
  %131 = load ptr, ptr %16, align 8, !tbaa !9
  %132 = icmp ne ptr %131, null
  br i1 %132, label %133, label %137

133:                                              ; preds = %130
  %134 = load double, ptr %18, align 8, !tbaa !5
  %135 = fptrunc double %134 to float
  %136 = load ptr, ptr %16, align 8, !tbaa !9
  store float %135, ptr %136, align 4, !tbaa !11
  br label %137

137:                                              ; preds = %133, %130
  %138 = load double, ptr %19, align 8, !tbaa !5
  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 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  ret double %138
}

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

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 "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 = !{!"double", !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 = !{!"float", !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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local double @PointVerticalDistance(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, ptr noundef writeonly %6, ptr noundef writeonly %7) local_unnamed_addr #1 {
  %9 = fsub double %5, %3
  %10 = fsub double %4, %2
  %11 = fcmp oeq double %9, 0.000000e+00
  br i1 %11, label %12, label %15

12:                                               ; preds = %8
  %13 = fsub double %1, %3
  %14 = tail call double @llvm.fabs.f64(double %13)
  br label %38

15:                                               ; preds = %8
  %16 = fcmp oeq double %10, 0.000000e+00
  br i1 %16, label %17, label %20

17:                                               ; preds = %15
  %18 = fsub double %0, %2
  %19 = tail call double @llvm.fabs.f64(double %18)
  br label %38

20:                                               ; preds = %15
  %21 = fneg double %10
  %22 = fmul double %21, %5
  %23 = tail call double @llvm.fmuladd.f64(double %9, double %4, double %22)
  %24 = fmul double %10, %0
  %25 = tail call double @llvm.fmuladd.f64(double %9, double %1, double %24)
  %26 = fmul double %10, %10
  %27 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %26)
  %28 = fmul double %10, %25
  %29 = tail call double @llvm.fmuladd.f64(double %23, double %9, double %28)
  %30 = fdiv double %29, %27
  %31 = fneg double %23
  %32 = tail call double @llvm.fmuladd.f64(double %9, double %30, double %31)
  %33 = fdiv double %32, %10
  %34 = fsub double %0, %30
  %35 = fsub double %1, %33
  %36 = fmul double %35, %35
  %37 = tail call double @llvm.fmuladd.f64(double %34, double %34, double %36)
  %sqrt = tail call double @llvm.sqrt.f64(double %37)
  br label %38

38:                                               ; preds = %17, %20, %12
  %.059 = phi double [ %14, %12 ], [ %19, %17 ], [ %sqrt, %20 ]
  %.058 = phi double [ %3, %12 ], [ %1, %17 ], [ %33, %20 ]
  %.0 = phi double [ %0, %12 ], [ %2, %17 ], [ %30, %20 ]
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %41, label %39

39:                                               ; preds = %38
  %40 = fptrunc double %.0 to float
  store float %40, ptr %6, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %39, %38
  %.not67 = icmp eq ptr %7, null
  br i1 %.not67, label %44, label %42

42:                                               ; preds = %41
  %43 = fptrunc double %.058 to float
  store float %43, ptr %7, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %42, %41
  ret double %.059
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass