; LLVM IR from bohanwang/libpgo :: src/core/mesh (intersection_tunicate)

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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_ = external hidden unnamed_addr constant [121 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store i32 %0, ptr %9, align 4, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !9
  %16 = load i32, ptr %9, align 4, !tbaa !5
  %17 = icmp sle i32 1, %16
  br i1 %17, label %18, label %21

18:                                               ; preds = %7
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = icmp sle i32 %19, 2
  br label %21

21:                                               ; preds = %18, %7
  %22 = phi i1 [ false, %7 ], [ %20, %18 ]
  br i1 %22, label %23, label %24

23:                                               ; preds = %21
  br label %26

24:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 64, ptr noundef @__PRETTY_FUNCTION__._ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_) #2
  unreachable

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25, %23
  %27 = load ptr, ptr %13, align 8, !tbaa !9
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %35

29:                                               ; preds = %26
  %30 = load ptr, ptr %14, align 8, !tbaa !9
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load ptr, ptr %15, align 8, !tbaa !9
  %34 = icmp ne ptr %33, null
  br label %35

35:                                               ; preds = %32, %29, %26
  %36 = phi i1 [ false, %29 ], [ false, %26 ], [ %34, %32 ]
  br i1 %36, label %37, label %38

37:                                               ; preds = %35
  br label %40

38:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 65, ptr noundef @__PRETTY_FUNCTION__._ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_) #2
  unreachable

39:                                               ; No predecessors!
  br label %40

40:                                               ; preds = %39, %37
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %178

43:                                               ; preds = %40
  %44 = load ptr, ptr %11, align 8, !tbaa !9
  %45 = getelementptr inbounds double, ptr %44, i64 0
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = load ptr, ptr %12, align 8, !tbaa !9
  %48 = getelementptr inbounds double, ptr %47, i64 0
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = fcmp olt double %46, %49
  br i1 %50, label %51, label %104

51:                                               ; preds = %43
  %52 = load ptr, ptr %10, align 8, !tbaa !9
  %53 = getelementptr inbounds double, ptr %52, i64 0
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = load ptr, ptr %11, align 8, !tbaa !9
  %56 = getelementptr inbounds double, ptr %55, i64 0
  %57 = load double, ptr %56, align 8, !tbaa !11
  %58 = fcmp olt double %54, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %51
  store i32 0, ptr %8, align 4
  br label %185

60:                                               ; preds = %51
  %61 = load ptr, ptr %10, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %61, i64 0
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = load ptr, ptr %12, align 8, !tbaa !9
  %65 = getelementptr inbounds double, ptr %64, i64 0
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = fcmp ogt double %63, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %60
  store i32 0, ptr %8, align 4
  br label %185

69:                                               ; preds = %60
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr %13, align 8, !tbaa !9
  store double 1.000000e+00, ptr %71, align 8, !tbaa !11
  %72 = load ptr, ptr %12, align 8, !tbaa !9
  %73 = getelementptr inbounds double, ptr %72, i64 0
  %74 = load double, ptr %73, align 8, !tbaa !11
  %75 = load ptr, ptr %10, align 8, !tbaa !9
  %76 = getelementptr inbounds double, ptr %75, i64 0
  %77 = load double, ptr %76, align 8, !tbaa !11
  %78 = fsub double %74, %77
  %79 = load ptr, ptr %12, align 8, !tbaa !9
  %80 = getelementptr inbounds double, ptr %79, i64 0
  %81 = load double, ptr %80, align 8, !tbaa !11
  %82 = load ptr, ptr %11, align 8, !tbaa !9
  %83 = getelementptr inbounds double, ptr %82, i64 0
  %84 = load double, ptr %83, align 8, !tbaa !11
  %85 = fsub double %81, %84
  %86 = fdiv double %78, %85
  %87 = load ptr, ptr %14, align 8, !tbaa !9
  store double %86, ptr %87, align 8, !tbaa !11
  %88 = load ptr, ptr %10, align 8, !tbaa !9
  %89 = getelementptr inbounds double, ptr %88, i64 0
  %90 = load double, ptr %89, align 8, !tbaa !11
  %91 = load ptr, ptr %11, align 8, !tbaa !9
  %92 = getelementptr inbounds double, ptr %91, i64 0
  %93 = load double, ptr %92, align 8, !tbaa !11
  %94 = fsub double %90, %93
  %95 = load ptr, ptr %12, align 8, !tbaa !9
  %96 = getelementptr inbounds double, ptr %95, i64 0
  %97 = load double, ptr %96, align 8, !tbaa !11
  %98 = load ptr, ptr %11, align 8, !tbaa !9
  %99 = getelementptr inbounds double, ptr %98, i64 0
  %100 = load double, ptr %99, align 8, !tbaa !11
  %101 = fsub double %97, %100
  %102 = fdiv double %94, %101
  %103 = load ptr, ptr %15, align 8, !tbaa !9
  store double %102, ptr %103, align 8, !tbaa !11
  store i32 1, ptr %8, align 4
  br label %185

104:                                              ; preds = %43
  %105 = load ptr, ptr %11, align 8, !tbaa !9
  %106 = getelementptr inbounds double, ptr %105, i64 0
  %107 = load double, ptr %106, align 8, !tbaa !11
  %108 = load ptr, ptr %12, align 8, !tbaa !9
  %109 = getelementptr inbounds double, ptr %108, i64 0
  %110 = load double, ptr %109, align 8, !tbaa !11
  %111 = fcmp ogt double %107, %110
  br i1 %111, label %112, label %165

112:                                              ; preds = %104
  %113 = load ptr, ptr %10, align 8, !tbaa !9
  %114 = getelementptr inbounds double, ptr %113, i64 0
  %115 = load double, ptr %114, align 8, !tbaa !11
  %116 = load ptr, ptr %12, align 8, !tbaa !9
  %117 = getelementptr inbounds double, ptr %116, i64 0
  %118 = load double, ptr %117, align 8, !tbaa !11
  %119 = fcmp olt double %115, %118
  br i1 %119, label %120, label %121

120:                                              ; preds = %112
  store i32 0, ptr %8, align 4
  br label %185

121:                                              ; preds = %112
  %122 = load ptr, ptr %10, align 8, !tbaa !9
  %123 = getelementptr inbounds double, ptr %122, i64 0
  %124 = load double, ptr %123, align 8, !tbaa !11
  %125 = load ptr, ptr %11, align 8, !tbaa !9
  %126 = getelementptr inbounds double, ptr %125, i64 0
  %127 = load double, ptr %126, align 8, !tbaa !11
  %128 = fcmp ogt double %124, %127
  br i1 %128, label %129, label %130

129:                                              ; preds = %121
  store i32 0, ptr %8, align 4
  br label %185

130:                                              ; preds = %121
  br label %131

131:                                              ; preds = %130
  %132 = load ptr, ptr %13, align 8, !tbaa !9
  store double 1.000000e+00, ptr %132, align 8, !tbaa !11
  %133 = load ptr, ptr %12, align 8, !tbaa !9
  %134 = getelementptr inbounds double, ptr %133, i64 0
  %135 = load double, ptr %134, align 8, !tbaa !11
  %136 = load ptr, ptr %10, align 8, !tbaa !9
  %137 = getelementptr inbounds double, ptr %136, i64 0
  %138 = load double, ptr %137, align 8, !tbaa !11
  %139 = fsub double %135, %138
  %140 = load ptr, ptr %12, align 8, !tbaa !9
  %141 = getelementptr inbounds double, ptr %140, i64 0
  %142 = load double, ptr %141, align 8, !tbaa !11
  %143 = load ptr, ptr %11, align 8, !tbaa !9
  %144 = getelementptr inbounds double, ptr %143, i64 0
  %145 = load double, ptr %144, align 8, !tbaa !11
  %146 = fsub double %142, %145
  %147 = fdiv double %139, %146
  %148 = load ptr, ptr %14, align 8, !tbaa !9
  store double %147, ptr %148, align 8, !tbaa !11
  %149 = load ptr, ptr %10, align 8, !tbaa !9
  %150 = getelementptr inbounds double, ptr %149, i64 0
  %151 = load double, ptr %150, align 8, !tbaa !11
  %152 = load ptr, ptr %11, align 8, !tbaa !9
  %153 = getelementptr inbounds double, ptr %152, i64 0
  %154 = load double, ptr %153, align 8, !tbaa !11
  %155 = fsub double %151, %154
  %156 = load ptr, ptr %12, align 8, !tbaa !9
  %157 = getelementptr inbounds double, ptr %156, i64 0
  %158 = load double, ptr %157, align 8, !tbaa !11
  %159 = load ptr, ptr %11, align 8, !tbaa !9
  %160 = getelementptr inbounds double, ptr %159, i64 0
  %161 = load double, ptr %160, align 8, !tbaa !11
  %162 = fsub double %158, %161
  %163 = fdiv double %155, %162
  %164 = load ptr, ptr %15, align 8, !tbaa !9
  store double %163, ptr %164, align 8, !tbaa !11
  store i32 1, ptr %8, align 4
  br label %185

165:                                              ; preds = %104
  %166 = load ptr, ptr %10, align 8, !tbaa !9
  %167 = getelementptr inbounds double, ptr %166, i64 0
  %168 = load double, ptr %167, align 8, !tbaa !11
  %169 = load ptr, ptr %11, align 8, !tbaa !9
  %170 = getelementptr inbounds double, ptr %169, i64 0
  %171 = load double, ptr %170, align 8, !tbaa !11
  %172 = fcmp une double %168, %171
  br i1 %172, label %173, label %174

173:                                              ; preds = %165
  store i32 0, ptr %8, align 4
  br label %185

174:                                              ; preds = %165
  %175 = load ptr, ptr %13, align 8, !tbaa !9
  store double 1.000000e+00, ptr %175, align 8, !tbaa !11
  %176 = load ptr, ptr %14, align 8, !tbaa !9
  store double 5.000000e-01, ptr %176, align 8, !tbaa !11
  %177 = load ptr, ptr %15, align 8, !tbaa !9
  store double 5.000000e-01, ptr %177, align 8, !tbaa !11
  store i32 1, ptr %8, align 4
  br label %185

178:                                              ; preds = %40
  %179 = load ptr, ptr %12, align 8, !tbaa !9
  %180 = load ptr, ptr %11, align 8, !tbaa !9
  %181 = load ptr, ptr %15, align 8, !tbaa !9
  %182 = load ptr, ptr %14, align 8, !tbaa !9
  %183 = load ptr, ptr %13, align 8, !tbaa !9
  %184 = call noundef i32 @_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_(i32 noundef 1, ptr noundef %179, ptr noundef %180, ptr noundef null, ptr noundef %181, ptr noundef %182, ptr noundef %183)
  store i32 %184, ptr %8, align 4
  br label %185

185:                                              ; preds = %178, %174, %173, %131, %129, %120, %70, %68, %59
  %186 = load i32, ptr %8, align 4
  ret i32 %186
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

attributes #0 = { mustprogress 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 = { noreturn 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 #2 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_ = external hidden unnamed_addr constant [121 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr noundef writeonly %4, ptr noundef writeonly %5, ptr noundef writeonly %6) local_unnamed_addr #0 {
  %8 = add i32 %0, -1
  %9 = icmp ult i32 %8, 2
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 64, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_) #3
  unreachable

11:                                               ; preds = %7
  %12 = icmp ne ptr %4, null
  %13 = icmp ne ptr %5, null
  %or.cond = and i1 %12, %13
  %14 = icmp ne ptr %6, null
  %or.cond3 = and i1 %or.cond, %14
  br i1 %or.cond3, label %15, label %.critedge

.critedge:                                        ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 65, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_) #3
  unreachable

15:                                               ; preds = %11
  %16 = icmp eq i32 %0, 1
  tail call void @llvm.assume(i1 %16)
  %17 = load double, ptr %2, align 8, !tbaa !5
  %18 = load double, ptr %3, align 8, !tbaa !5
  %19 = fcmp olt double %17, %18
  br i1 %19, label %20, label %37

20:                                               ; preds = %15
  %21 = load double, ptr %1, align 8, !tbaa !5
  %22 = fcmp olt double %21, %17
  %23 = fcmp ogt double %21, %18
  %or.cond62 = or i1 %22, %23
  br i1 %or.cond62, label %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit, label %24

24:                                               ; preds = %20
  store double 1.000000e+00, ptr %4, align 8, !tbaa !5
  %25 = load double, ptr %3, align 8, !tbaa !5
  %26 = load double, ptr %1, align 8, !tbaa !5
  %27 = fsub double %25, %26
  %28 = load double, ptr %2, align 8, !tbaa !5
  %29 = fsub double %25, %28
  %30 = fdiv double %27, %29
  store double %30, ptr %5, align 8, !tbaa !5
  %31 = load double, ptr %1, align 8, !tbaa !5
  %32 = load double, ptr %2, align 8, !tbaa !5
  %33 = fsub double %31, %32
  %34 = load double, ptr %3, align 8, !tbaa !5
  %35 = fsub double %34, %32
  %36 = fdiv double %33, %35
  br label %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit.sink.split

37:                                               ; preds = %15
  %38 = fcmp ogt double %17, %18
  %39 = load double, ptr %1, align 8, !tbaa !5
  br i1 %38, label %40, label %56

40:                                               ; preds = %37
  %41 = fcmp olt double %39, %18
  %42 = fcmp ogt double %39, %17
  %or.cond63 = or i1 %41, %42
  br i1 %or.cond63, label %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit, label %43

43:                                               ; preds = %40
  store double 1.000000e+00, ptr %4, align 8, !tbaa !5
  %44 = load double, ptr %3, align 8, !tbaa !5
  %45 = load double, ptr %1, align 8, !tbaa !5
  %46 = fsub double %44, %45
  %47 = load double, ptr %2, align 8, !tbaa !5
  %48 = fsub double %44, %47
  %49 = fdiv double %46, %48
  store double %49, ptr %5, align 8, !tbaa !5
  %50 = load double, ptr %1, align 8, !tbaa !5
  %51 = load double, ptr %2, align 8, !tbaa !5
  %52 = fsub double %50, %51
  %53 = load double, ptr %3, align 8, !tbaa !5
  %54 = fsub double %53, %51
  %55 = fdiv double %52, %54
  br label %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit.sink.split

56:                                               ; preds = %37
  %57 = fcmp une double %39, %17
  br i1 %57, label %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit, label %58

58:                                               ; preds = %56
  store double 1.000000e+00, ptr %4, align 8, !tbaa !5
  store double 5.000000e-01, ptr %5, align 8, !tbaa !5
  br label %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit.sink.split

_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit.sink.split: ; preds = %24, %43, %58
  %.sink = phi double [ 5.000000e-01, %58 ], [ %55, %43 ], [ %36, %24 ]
  store double %.sink, ptr %6, align 8, !tbaa !5
  br label %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit

_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit: ; preds = %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit.sink.split, %56, %40, %20
  %.0 = phi i32 [ 0, %20 ], [ 0, %40 ], [ 0, %56 ], [ 1, %_ZN3pgo4Mesh22simplex_intersection1dEiPKdS2_S2_PdS3_S3_.exit.sink.split ]
  ret i32 %.0
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #2

attributes #0 = { mustprogress 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 = { noreturn 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 #2 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #3 = { noreturn 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++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InlinerPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass