; 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.otri = type { ptr, i32 }
%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 }

@plus1mod3 = external dso_local global [3 x i32], 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 void @insertsubseg(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @markhull(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.otri, align 8
  %6 = alloca %struct.otri, align 8
  %7 = alloca %struct.otri, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mesh, ptr %9, i32 0, i32 48
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  store ptr %11, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  store i32 0, ptr %13, align 8, !tbaa !17
  %14 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds ptr, ptr %15, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = ptrtoint ptr %21 to i64
  %23 = and i64 %22, 3
  %24 = trunc i64 %23 to i32
  %25 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  store i32 %24, ptr %25, align 8, !tbaa !17
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = ptrtoint ptr %26 to i64
  %28 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !17
  %30 = sext i32 %29 to i64
  %31 = xor i64 %27, %30
  %32 = inttoptr i64 %31 to ptr
  %33 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  store ptr %32, ptr %33, align 8, !tbaa !16
  %34 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = getelementptr inbounds %struct.otri, ptr %7, i32 0, i32 0
  store ptr %35, ptr %36, align 8, !tbaa !16
  %37 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  %38 = load i32, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds %struct.otri, ptr %7, i32 0, i32 1
  store i32 %38, ptr %39, align 8, !tbaa !17
  br label %40

40:                                               ; preds = %128, %2
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @insertsubseg(ptr noundef %41, ptr noundef %42, ptr noundef %5, i32 noundef 1)
  %43 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !17
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [3 x i32], ptr @plus1mod3, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !18
  %48 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  store i32 %47, ptr %48, align 8, !tbaa !17
  %49 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !17
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds ptr, ptr %50, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  store ptr %55, ptr %8, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = ptrtoint ptr %56 to i64
  %58 = and i64 %57, 3
  %59 = trunc i64 %58 to i32
  %60 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  store i32 %59, ptr %60, align 8, !tbaa !17
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = ptrtoint ptr %61 to i64
  %63 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  %64 = load i32, ptr %63, align 8, !tbaa !17
  %65 = sext i32 %64 to i64
  %66 = xor i64 %62, %65
  %67 = inttoptr i64 %66 to ptr
  %68 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 0
  store ptr %67, ptr %68, align 8, !tbaa !16
  %69 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  %70 = load i32, ptr %69, align 8, !tbaa !17
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [3 x i32], ptr @plus1mod3, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !18
  %74 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  store i32 %73, ptr %74, align 8, !tbaa !17
  br label %75

75:                                               ; preds = %82, %40
  %76 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !16
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mesh, ptr %78, i32 0, i32 48
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  %81 = icmp ne ptr %77, %80
  br i1 %81, label %82, label %115

82:                                               ; preds = %75
  %83 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !16
  %85 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  store ptr %84, ptr %85, align 8, !tbaa !16
  %86 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  %87 = load i32, ptr %86, align 8, !tbaa !17
  %88 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  store i32 %87, ptr %88, align 8, !tbaa !17
  %89 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !16
  %91 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  %92 = load i32, ptr %91, align 8, !tbaa !17
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds ptr, ptr %90, i64 %93
  %95 = load ptr, ptr %94, align 8, !tbaa !5
  store ptr %95, ptr %8, align 8, !tbaa !5
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = ptrtoint ptr %96 to i64
  %98 = and i64 %97, 3
  %99 = trunc i64 %98 to i32
  %100 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  store i32 %99, ptr %100, align 8, !tbaa !17
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = ptrtoint ptr %101 to i64
  %103 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  %104 = load i32, ptr %103, align 8, !tbaa !17
  %105 = sext i32 %104 to i64
  %106 = xor i64 %102, %105
  %107 = inttoptr i64 %106 to ptr
  %108 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 0
  store ptr %107, ptr %108, align 8, !tbaa !16
  %109 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  %110 = load i32, ptr %109, align 8, !tbaa !17
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [3 x i32], ptr @plus1mod3, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !18
  %114 = getelementptr inbounds %struct.otri, ptr %6, i32 0, i32 1
  store i32 %113, ptr %114, align 8, !tbaa !17
  br label %75, !llvm.loop !19

115:                                              ; preds = %75
  br label %116

116:                                              ; preds = %115
  %117 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !16
  %119 = getelementptr inbounds %struct.otri, ptr %7, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !16
  %121 = icmp eq ptr %118, %120
  br i1 %121, label %122, label %128

122:                                              ; preds = %116
  %123 = getelementptr inbounds %struct.otri, ptr %5, i32 0, i32 1
  %124 = load i32, ptr %123, align 8, !tbaa !17
  %125 = getelementptr inbounds %struct.otri, ptr %7, i32 0, i32 1
  %126 = load i32, ptr %125, align 8, !tbaa !17
  %127 = icmp eq i32 %124, %126
  br label %128

128:                                              ; preds = %122, %116
  %129 = phi i1 [ false, %116 ], [ %127, %122 ]
  %130 = xor i1 %129, true
  br i1 %130, label %40, label %131, !llvm.loop !21

131:                                              ; preds = %128
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #2
  ret void
}

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, !6, i64 82840}
!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 = !{!15, !6, i64 0}
!17 = !{!15, !12, i64 8}
!18 = !{!12, !12, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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

%struct.otri = type { ptr, i32 }

@plus1mod3 = external dso_local local_unnamed_addr global [3 x i32], align 4

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

; Function Attrs: mustprogress 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 void @insertsubseg(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @markhull(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca %struct.otri, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #2
  %4 = getelementptr inbounds i8, ptr %0, i64 82840
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  %7 = load ptr, ptr %5, align 8, !tbaa !15
  %8 = ptrtoint ptr %7 to i64
  %9 = trunc i64 %8 to i32
  %10 = and i32 %9, 3
  store i32 %10, ptr %6, align 8, !tbaa !16
  %11 = and i64 %8, -4
  %12 = inttoptr i64 %11 to ptr
  store ptr %12, ptr %3, align 8, !tbaa !17
  br label %13

13:                                               ; preds = %24, %2
  call void @insertsubseg(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %3, i32 noundef 1)
  %14 = load i32, ptr %6, align 8, !tbaa !16
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [3 x i32], ptr @plus1mod3, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !18
  store i32 %17, ptr %6, align 8, !tbaa !16
  %18 = load ptr, ptr %3, align 8, !tbaa !17
  %19 = sext i32 %17 to i64
  %20 = getelementptr inbounds ptr, ptr %18, i64 %19
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %.pn.in.in20 = load ptr, ptr %20, align 8, !tbaa !15
  %.pn.in21 = ptrtoint ptr %.pn.in.in20 to i64
  %.sroa.06.0.in22 = and i64 %.pn.in21, -4
  %.sroa.06.023 = inttoptr i64 %.sroa.06.0.in22 to ptr
  %.not24 = icmp eq ptr %21, %.sroa.06.023
  br i1 %.not24, label %24, label %.lr.ph

.lr.ph:                                           ; preds = %13, %.lr.ph
  %.sroa.06.026 = phi ptr [ %.sroa.06.0, %.lr.ph ], [ %.sroa.06.023, %13 ]
  %.pn.in25 = phi i64 [ %.pn.in, %.lr.ph ], [ %.pn.in21, %13 ]
  %.pn = and i64 %.pn.in25, 3
  %.sroa.68.0.in = getelementptr inbounds [3 x i32], ptr @plus1mod3, i64 0, i64 %.pn
  %.sroa.68.0 = load i32, ptr %.sroa.68.0.in, align 4, !tbaa !18
  store ptr %.sroa.06.026, ptr %3, align 8, !tbaa !17
  %22 = sext i32 %.sroa.68.0 to i64
  %23 = getelementptr inbounds ptr, ptr %.sroa.06.026, i64 %22
  %.pn.in.in = load ptr, ptr %23, align 8, !tbaa !15
  %.pn.in = ptrtoint ptr %.pn.in.in to i64
  %.sroa.06.0.in = and i64 %.pn.in, -4
  %.sroa.06.0 = inttoptr i64 %.sroa.06.0.in to ptr
  %.not = icmp eq ptr %21, %.sroa.06.0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph
  store i32 %.sroa.68.0, ptr %6, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %._crit_edge, %13
  %25 = phi i32 [ %.sroa.68.0, %._crit_edge ], [ %17, %13 ]
  %26 = phi ptr [ %.sroa.06.026, %._crit_edge ], [ %18, %13 ]
  %27 = icmp ne ptr %26, %12
  %28 = icmp ne i32 %25, %10
  %.not19 = select i1 %27, i1 true, i1 %28
  br i1 %.not19, label %13, label %29, !llvm.loop !21

29:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #2
  ret void
}

attributes #0 = { mustprogress 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, !8, i64 82840}
!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 = !{!8, !8, i64 0}
!16 = !{!14, !11, i64 8}
!17 = !{!14, !8, i64 0}
!18 = !{!11, !11, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass