; LLVM IR from MIT-SPARK/Kimera-VIO :: third_party/triangle/src (triangle)

; 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.mesh = type { %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, %struct.memorypool, [4096 x ptr], [4096 x ptr], [4096 x i32], i32, ptr, float, float, float, float, float, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.otri }
%struct.memorypool = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i64, i64, i32, i32 }
%struct.otri = type { ptr, i32 }
%struct.behavior = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float }

@ccwerrboundA = external dso_local global float, align 4

; 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 float @counterclockwiseadapt(ptr noundef, ptr noundef, ptr noundef, float noundef) #1

; Function Attrs: nounwind uwtable
define dso_local float @counterclockwise(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mesh, ptr %18, i32 0, i32 40
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = add nsw i64 %20, 1
  store i64 %21, ptr %19, align 8, !tbaa !9
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds float, ptr %22, i64 0
  %24 = load float, ptr %23, align 4, !tbaa !16
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds float, ptr %25, i64 0
  %27 = load float, ptr %26, align 4, !tbaa !16
  %28 = fsub float %24, %27
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = getelementptr inbounds float, ptr %29, i64 1
  %31 = load float, ptr %30, align 4, !tbaa !16
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds float, ptr %32, i64 1
  %34 = load float, ptr %33, align 4, !tbaa !16
  %35 = fsub float %31, %34
  %36 = fmul float %28, %35
  store float %36, ptr %12, align 4, !tbaa !16
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds float, ptr %37, i64 1
  %39 = load float, ptr %38, align 4, !tbaa !16
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = getelementptr inbounds float, ptr %40, i64 1
  %42 = load float, ptr %41, align 4, !tbaa !16
  %43 = fsub float %39, %42
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds float, ptr %44, i64 0
  %46 = load float, ptr %45, align 4, !tbaa !16
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds float, ptr %47, i64 0
  %49 = load float, ptr %48, align 4, !tbaa !16
  %50 = fsub float %46, %49
  %51 = fmul float %43, %50
  store float %51, ptr %13, align 4, !tbaa !16
  %52 = load float, ptr %12, align 4, !tbaa !16
  %53 = load float, ptr %13, align 4, !tbaa !16
  %54 = fsub float %52, %53
  store float %54, ptr %14, align 4, !tbaa !16
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.behavior, ptr %55, i32 0, i32 21
  %57 = load i32, ptr %56, align 4, !tbaa !17
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %5
  %60 = load float, ptr %14, align 4, !tbaa !16
  store float %60, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %115

61:                                               ; preds = %5
  %62 = load float, ptr %12, align 4, !tbaa !16
  %63 = fpext float %62 to double
  %64 = fcmp ogt double %63, 0.000000e+00
  br i1 %64, label %65, label %76

65:                                               ; preds = %61
  %66 = load float, ptr %13, align 4, !tbaa !16
  %67 = fpext float %66 to double
  %68 = fcmp ole double %67, 0.000000e+00
  br i1 %68, label %69, label %71

69:                                               ; preds = %65
  %70 = load float, ptr %14, align 4, !tbaa !16
  store float %70, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %115

71:                                               ; preds = %65
  %72 = load float, ptr %12, align 4, !tbaa !16
  %73 = load float, ptr %13, align 4, !tbaa !16
  %74 = fadd float %72, %73
  store float %74, ptr %15, align 4, !tbaa !16
  br label %75

75:                                               ; preds = %71
  br label %95

76:                                               ; preds = %61
  %77 = load float, ptr %12, align 4, !tbaa !16
  %78 = fpext float %77 to double
  %79 = fcmp olt double %78, 0.000000e+00
  br i1 %79, label %80, label %92

80:                                               ; preds = %76
  %81 = load float, ptr %13, align 4, !tbaa !16
  %82 = fpext float %81 to double
  %83 = fcmp oge double %82, 0.000000e+00
  br i1 %83, label %84, label %86

84:                                               ; preds = %80
  %85 = load float, ptr %14, align 4, !tbaa !16
  store float %85, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %115

86:                                               ; preds = %80
  %87 = load float, ptr %12, align 4, !tbaa !16
  %88 = fneg float %87
  %89 = load float, ptr %13, align 4, !tbaa !16
  %90 = fsub float %88, %89
  store float %90, ptr %15, align 4, !tbaa !16
  br label %91

91:                                               ; preds = %86
  br label %94

92:                                               ; preds = %76
  %93 = load float, ptr %14, align 4, !tbaa !16
  store float %93, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %115

94:                                               ; preds = %91
  br label %95

95:                                               ; preds = %94, %75
  %96 = load float, ptr @ccwerrboundA, align 4, !tbaa !16
  %97 = load float, ptr %15, align 4, !tbaa !16
  %98 = fmul float %96, %97
  store float %98, ptr %16, align 4, !tbaa !16
  %99 = load float, ptr %14, align 4, !tbaa !16
  %100 = load float, ptr %16, align 4, !tbaa !16
  %101 = fcmp oge float %99, %100
  br i1 %101, label %107, label %102

102:                                              ; preds = %95
  %103 = load float, ptr %14, align 4, !tbaa !16
  %104 = fneg float %103
  %105 = load float, ptr %16, align 4, !tbaa !16
  %106 = fcmp oge float %104, %105
  br i1 %106, label %107, label %109

107:                                              ; preds = %102, %95
  %108 = load float, ptr %14, align 4, !tbaa !16
  store float %108, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %115

109:                                              ; preds = %102
  %110 = load ptr, ptr %9, align 8, !tbaa !5
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load ptr, ptr %11, align 8, !tbaa !5
  %113 = load float, ptr %15, align 4, !tbaa !16
  %114 = call float @counterclockwiseadapt(ptr noundef %110, ptr noundef %111, ptr noundef %112, float noundef %113)
  store float %114, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %115

115:                                              ; preds = %109, %107, %92, %84, %69, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %116 = load float, ptr %6, align 4
  ret float %116
}

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 }

!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, !13, i64 82776}
!10 = !{!"mesh", !11, i64 0, !11, i64 88, !11, i64 176, !11, i64 264, !11, i64 352, !11, i64 440, !11, i64 528, !11, i64 616, !7, i64 704, !7, i64 33472, !7, i64 66240, !12, i64 82624, !6, i64 82632, !14, i64 82640, !14, i64 82644, !14, i64 82648, !14, i64 82652, !14, i64 82656, !12, i64 82660, !12, i64 82664, !12, i64 82668, !12, i64 82672, !12, i64 82676, !12, i64 82680, !13, i64 82688, !12, i64 82696, !12, i64 82700, !12, i64 82704, !13, i64 82712, !12, i64 82720, !12, i64 82724, !12, i64 82728, !12, i64 82732, !12, i64 82736, !12, i64 82740, !12, i64 82744, !12, i64 82748, !12, i64 82752, !13, i64 82760, !13, i64 82768, !13, i64 82776, !13, i64 82784, !13, i64 82792, !13, i64 82800, !13, i64 82808, !6, i64 82816, !6, i64 82824, !6, i64 82832, !6, i64 82840, !6, i64 82848, !6, i64 82856, !6, i64 82864, !15, i64 82872}
!11 = !{!"memorypool", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !13, i64 64, !13, i64 72, !12, i64 80, !12, i64 84}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"otri", !6, i64 0, !12, i64 8}
!16 = !{!14, !14, i64 0}
!17 = !{!18, !12, i64 84}
!18 = !{!"behavior", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132, !14, i64 136, !14, i64 140, !14, i64 144, !14, i64 148}


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

@ccwerrboundA = external dso_local local_unnamed_addr global float, align 4

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

; Function Attrs: nounwind uwtable
define dso_local float @counterclockwise(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 82776
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = add nsw i64 %7, 1
  store i64 %8, ptr %6, align 8, !tbaa !5
  %9 = load <2 x float>, ptr %4, align 4, !tbaa !15
  %10 = load <2 x float>, ptr %2, align 4, !tbaa !15
  %11 = fsub <2 x float> %10, %9
  %12 = load <2 x float>, ptr %3, align 4, !tbaa !15
  %13 = fsub <2 x float> %12, %9
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %15 = fmul <2 x float> %11, %14
  %16 = extractelement <2 x float> %15, i64 0
  %17 = extractelement <2 x float> %15, i64 1
  %18 = fsub float %16, %17
  %19 = getelementptr inbounds i8, ptr %1, i64 84
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %41

21:                                               ; preds = %5
  %22 = fcmp ogt float %16, 0.000000e+00
  br i1 %22, label %23, label %27

23:                                               ; preds = %21
  %24 = fcmp ugt float %17, 0.000000e+00
  br i1 %24, label %25, label %41

25:                                               ; preds = %23
  %26 = fadd float %16, %17
  br label %33

27:                                               ; preds = %21
  %28 = fcmp olt float %16, 0.000000e+00
  %29 = fcmp ult float %17, 0.000000e+00
  %or.cond40 = select i1 %28, i1 %29, i1 false
  br i1 %or.cond40, label %30, label %41

30:                                               ; preds = %27
  %31 = fneg float %16
  %32 = fsub float %31, %17
  br label %33

33:                                               ; preds = %30, %25
  %.035 = phi float [ %26, %25 ], [ %32, %30 ]
  %34 = load float, ptr @ccwerrboundA, align 4, !tbaa !15
  %35 = fmul float %.035, %34
  %36 = fcmp ult float %18, %35
  %37 = fneg float %18
  %38 = fcmp ugt float %35, %37
  %or.cond = and i1 %36, %38
  br i1 %or.cond, label %39, label %41

39:                                               ; preds = %33
  %40 = tail call float @counterclockwiseadapt(ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, float noundef %.035)
  br label %41

41:                                               ; preds = %33, %27, %23, %5, %39
  %.0 = phi float [ %40, %39 ], [ %18, %5 ], [ %18, %23 ], [ %18, %27 ], [ %18, %33 ]
  ret float %.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" }

!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, !12, i64 82776}
!6 = !{!"mesh", !7, i64 0, !7, i64 88, !7, i64 176, !7, i64 264, !7, i64 352, !7, i64 440, !7, i64 528, !7, i64 616, !9, i64 704, !9, i64 33472, !9, i64 66240, !11, i64 82624, !8, i64 82632, !13, i64 82640, !13, i64 82644, !13, i64 82648, !13, i64 82652, !13, i64 82656, !11, i64 82660, !11, i64 82664, !11, i64 82668, !11, i64 82672, !11, i64 82676, !11, i64 82680, !12, i64 82688, !11, i64 82696, !11, i64 82700, !11, i64 82704, !12, i64 82712, !11, i64 82720, !11, i64 82724, !11, i64 82728, !11, i64 82732, !11, i64 82736, !11, i64 82740, !11, i64 82744, !11, i64 82748, !11, i64 82752, !12, i64 82760, !12, i64 82768, !12, i64 82776, !12, i64 82784, !12, i64 82792, !12, i64 82800, !12, i64 82808, !8, i64 82816, !8, i64 82824, !8, i64 82832, !8, i64 82840, !8, i64 82848, !8, i64 82856, !8, i64 82864, !14, i64 82872}
!7 = !{!"memorypool", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !12, i64 64, !12, i64 72, !11, i64 80, !11, i64 84}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!"float", !9, i64 0}
!14 = !{!"otri", !8, i64 0, !11, i64 8}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !11, i64 84}
!17 = !{!"behavior", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !13, i64 136, !13, i64 140, !13, i64 144, !13, i64 148}


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