; 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: nounwind uwtable
define dso_local i32 @LineCrossCheck(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7) #0 {
  %9 = alloca i32, align 4
  %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 double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca i32, align 4
  store double %0, ptr %10, align 8, !tbaa !5
  store double %1, ptr %11, align 8, !tbaa !5
  store double %2, ptr %12, align 8, !tbaa !5
  store double %3, ptr %13, align 8, !tbaa !5
  store double %4, ptr %14, align 8, !tbaa !5
  store double %5, ptr %15, align 8, !tbaa !5
  store double %6, ptr %16, align 8, !tbaa !5
  store double %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %21 = load double, ptr %10, align 8, !tbaa !5
  %22 = load double, ptr %12, align 8, !tbaa !5
  %23 = fsub double %21, %22
  %24 = load double, ptr %15, align 8, !tbaa !5
  %25 = load double, ptr %13, align 8, !tbaa !5
  %26 = fsub double %24, %25
  %27 = load double, ptr %11, align 8, !tbaa !5
  %28 = load double, ptr %13, align 8, !tbaa !5
  %29 = fsub double %27, %28
  %30 = load double, ptr %14, align 8, !tbaa !5
  %31 = load double, ptr %12, align 8, !tbaa !5
  %32 = fsub double %30, %31
  %33 = fmul double %29, %32
  %34 = fneg double %33
  %35 = call double @llvm.fmuladd.f64(double %23, double %26, double %34)
  store double %35, ptr %18, align 8, !tbaa !5
  %36 = load double, ptr %10, align 8, !tbaa !5
  %37 = load double, ptr %12, align 8, !tbaa !5
  %38 = fsub double %36, %37
  %39 = load double, ptr %17, align 8, !tbaa !5
  %40 = load double, ptr %13, align 8, !tbaa !5
  %41 = fsub double %39, %40
  %42 = load double, ptr %11, align 8, !tbaa !5
  %43 = load double, ptr %13, align 8, !tbaa !5
  %44 = fsub double %42, %43
  %45 = load double, ptr %16, align 8, !tbaa !5
  %46 = load double, ptr %12, align 8, !tbaa !5
  %47 = fsub double %45, %46
  %48 = fmul double %44, %47
  %49 = fneg double %48
  %50 = call double @llvm.fmuladd.f64(double %38, double %41, double %49)
  store double %50, ptr %19, align 8, !tbaa !5
  %51 = load double, ptr %18, align 8, !tbaa !5
  %52 = fcmp ogt double %51, 0.000000e+00
  %53 = zext i1 %52 to i32
  %54 = load double, ptr %19, align 8, !tbaa !5
  %55 = fcmp ogt double %54, 0.000000e+00
  %56 = zext i1 %55 to i32
  %57 = icmp eq i32 %53, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %8
  store i32 0, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %115

59:                                               ; preds = %8
  %60 = load double, ptr %18, align 8, !tbaa !5
  %61 = fcmp oeq double %60, 0.000000e+00
  br i1 %61, label %65, label %62

62:                                               ; preds = %59
  %63 = load double, ptr %19, align 8, !tbaa !5
  %64 = fcmp oeq double %63, 0.000000e+00
  br i1 %64, label %65, label %66

65:                                               ; preds = %62, %59
  store i32 1, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %115

66:                                               ; preds = %62
  br label %67

67:                                               ; preds = %66
  %68 = load double, ptr %14, align 8, !tbaa !5
  %69 = load double, ptr %16, align 8, !tbaa !5
  %70 = fsub double %68, %69
  %71 = load double, ptr %11, align 8, !tbaa !5
  %72 = load double, ptr %17, align 8, !tbaa !5
  %73 = fsub double %71, %72
  %74 = load double, ptr %15, align 8, !tbaa !5
  %75 = load double, ptr %17, align 8, !tbaa !5
  %76 = fsub double %74, %75
  %77 = load double, ptr %10, align 8, !tbaa !5
  %78 = load double, ptr %16, align 8, !tbaa !5
  %79 = fsub double %77, %78
  %80 = fmul double %76, %79
  %81 = fneg double %80
  %82 = call double @llvm.fmuladd.f64(double %70, double %73, double %81)
  store double %82, ptr %18, align 8, !tbaa !5
  %83 = load double, ptr %14, align 8, !tbaa !5
  %84 = load double, ptr %16, align 8, !tbaa !5
  %85 = fsub double %83, %84
  %86 = load double, ptr %13, align 8, !tbaa !5
  %87 = load double, ptr %17, align 8, !tbaa !5
  %88 = fsub double %86, %87
  %89 = load double, ptr %15, align 8, !tbaa !5
  %90 = load double, ptr %17, align 8, !tbaa !5
  %91 = fsub double %89, %90
  %92 = load double, ptr %12, align 8, !tbaa !5
  %93 = load double, ptr %16, align 8, !tbaa !5
  %94 = fsub double %92, %93
  %95 = fmul double %91, %94
  %96 = fneg double %95
  %97 = call double @llvm.fmuladd.f64(double %85, double %88, double %96)
  store double %97, ptr %19, align 8, !tbaa !5
  %98 = load double, ptr %18, align 8, !tbaa !5
  %99 = fcmp ogt double %98, 0.000000e+00
  %100 = zext i1 %99 to i32
  %101 = load double, ptr %19, align 8, !tbaa !5
  %102 = fcmp ogt double %101, 0.000000e+00
  %103 = zext i1 %102 to i32
  %104 = icmp eq i32 %100, %103
  br i1 %104, label %105, label %106

105:                                              ; preds = %67
  store i32 0, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %115

106:                                              ; preds = %67
  %107 = load double, ptr %18, align 8, !tbaa !5
  %108 = fcmp oeq double %107, 0.000000e+00
  br i1 %108, label %112, label %109

109:                                              ; preds = %106
  %110 = load double, ptr %19, align 8, !tbaa !5
  %111 = fcmp oeq double %110, 0.000000e+00
  br i1 %111, label %112, label %113

112:                                              ; preds = %109, %106
  store i32 1, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %115

113:                                              ; preds = %109
  br label %114

114:                                              ; preds = %113
  store i32 1, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %115

115:                                              ; preds = %114, %112, %105, %65, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  %116 = load i32, ptr %9, align 4
  ret i32 %116
}

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

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

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

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


; 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local range(i32 0, 2) i32 @LineCrossCheck(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7) local_unnamed_addr #0 {
  %9 = fsub double %0, %2
  %10 = insertelement <2 x double> poison, double %5, i64 0
  %11 = insertelement <2 x double> %10, double %7, i64 1
  %12 = insertelement <2 x double> poison, double %3, i64 0
  %13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
  %14 = fsub <2 x double> %11, %13
  %15 = fsub double %1, %3
  %16 = insertelement <2 x double> poison, double %4, i64 0
  %17 = insertelement <2 x double> %16, double %6, i64 1
  %18 = insertelement <2 x double> poison, double %2, i64 0
  %19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
  %20 = fsub <2 x double> %17, %19
  %21 = fneg double %15
  %22 = insertelement <2 x double> poison, double %21, i64 0
  %23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
  %24 = fmul <2 x double> %20, %23
  %25 = insertelement <2 x double> poison, double %9, i64 0
  %26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
  %27 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %26, <2 x double> %14, <2 x double> %24)
  %28 = extractelement <2 x double> %27, i64 0
  %29 = fcmp ogt double %28, 0.000000e+00
  %30 = extractelement <2 x double> %27, i64 1
  %31 = fcmp ule double %30, 0.000000e+00
  %32 = xor i1 %29, %31
  br i1 %32, label %58, label %33

33:                                               ; preds = %8
  %34 = fcmp oeq <2 x double> %27, zeroinitializer
  %shift = shufflevector <2 x i1> %34, <2 x i1> poison, <2 x i32> <i32 1, i32 poison>
  %35 = or <2 x i1> %34, %shift
  %or.cond = extractelement <2 x i1> %35, i64 0
  br i1 %or.cond, label %58, label %36

36:                                               ; preds = %33
  %37 = fsub double %4, %6
  %38 = insertelement <2 x double> poison, double %1, i64 0
  %39 = insertelement <2 x double> %38, double %3, i64 1
  %40 = insertelement <2 x double> poison, double %7, i64 0
  %41 = shufflevector <2 x double> %40, <2 x double> poison, <2 x i32> zeroinitializer
  %42 = fsub <2 x double> %39, %41
  %43 = fsub double %5, %7
  %44 = insertelement <2 x double> poison, double %0, i64 0
  %45 = insertelement <2 x double> %44, double %2, i64 1
  %46 = insertelement <2 x double> poison, double %6, i64 0
  %47 = shufflevector <2 x double> %46, <2 x double> poison, <2 x i32> zeroinitializer
  %48 = fsub <2 x double> %45, %47
  %49 = fneg double %43
  %50 = insertelement <2 x double> poison, double %49, i64 0
  %51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> zeroinitializer
  %52 = fmul <2 x double> %48, %51
  %53 = insertelement <2 x double> poison, double %37, i64 0
  %54 = shufflevector <2 x double> %53, <2 x double> poison, <2 x i32> zeroinitializer
  %55 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %54, <2 x double> %42, <2 x double> %52)
  %56 = fcmp ogt <2 x double> %55, zeroinitializer
  %shift43 = shufflevector <2 x i1> %56, <2 x i1> poison, <2 x i32> <i32 1, i32 poison>
  %57 = xor <2 x i1> %56, %shift43
  %not. = extractelement <2 x i1> %57, i64 0
  %spec.select = zext i1 %not. to i32
  br label %58

58:                                               ; preds = %36, %33, %8
  %.0 = phi i32 [ 0, %8 ], [ 1, %33 ], [ %spec.select, %36 ]
  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>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 = { 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)"}


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