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

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

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

50:                                               ; preds = %3
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mesh, ptr %51, i32 0, i32 50
  %53 = load ptr, ptr %52, align 8, !tbaa !19
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.otri, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds ptr, ptr %56, i64 6
  store ptr %53, ptr %57, align 8, !tbaa !5
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mesh, ptr %58, i32 0, i32 50
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.otri, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = getelementptr inbounds ptr, ptr %63, i64 7
  store ptr %60, ptr %64, align 8, !tbaa !5
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mesh, ptr %65, i32 0, i32 50
  %67 = load ptr, ptr %66, align 8, !tbaa !19
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.otri, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !9
  %71 = getelementptr inbounds ptr, ptr %70, i64 8
  store ptr %67, ptr %71, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %50, %3
  store i32 0, ptr %7, align 4, !tbaa !20
  br label %73

73:                                               ; preds = %90, %72
  %74 = load i32, ptr %7, align 4, !tbaa !20
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mesh, ptr %75, i32 0, i32 27
  %77 = load i32, ptr %76, align 8, !tbaa !21
  %78 = icmp slt i32 %74, %77
  br i1 %78, label %79, label %93

79:                                               ; preds = %73
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.otri, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.mesh, ptr %83, i32 0, i32 33
  %85 = load i32, ptr %84, align 8, !tbaa !22
  %86 = load i32, ptr %7, align 4, !tbaa !20
  %87 = add nsw i32 %85, %86
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %82, i64 %88
  store float 0.000000e+00, ptr %89, align 4, !tbaa !23
  br label %90

90:                                               ; preds = %79
  %91 = load i32, ptr %7, align 4, !tbaa !20
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %7, align 4, !tbaa !20
  br label %73, !llvm.loop !24

93:                                               ; preds = %73
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.behavior, ptr %94, i32 0, i32 3
  %96 = load i32, ptr %95, align 4, !tbaa !26
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %107

98:                                               ; preds = %93
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.otri, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !9
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.mesh, ptr %102, i32 0, i32 34
  %104 = load i32, ptr %103, align 4, !tbaa !27
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds float, ptr %101, i64 %105
  store float -1.000000e+00, ptr %106, align 4, !tbaa !23
  br label %107

107:                                              ; preds = %98, %93
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.otri, ptr %108, i32 0, i32 1
  store i32 0, ptr %109, align 8, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #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 0}
!10 = !{!"otri", !6, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 82840}
!13 = !{!"mesh", !14, i64 0, !14, i64 88, !14, i64 176, !14, i64 264, !14, i64 352, !14, i64 440, !14, i64 528, !14, i64 616, !7, i64 704, !7, i64 33472, !7, i64 66240, !11, i64 82624, !6, i64 82632, !16, i64 82640, !16, i64 82644, !16, i64 82648, !16, i64 82652, !16, i64 82656, !11, i64 82660, !11, i64 82664, !11, i64 82668, !11, i64 82672, !11, i64 82676, !11, i64 82680, !15, i64 82688, !11, i64 82696, !11, i64 82700, !11, i64 82704, !15, 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, !15, i64 82760, !15, i64 82768, !15, i64 82776, !15, i64 82784, !15, i64 82792, !15, i64 82800, !15, i64 82808, !6, i64 82816, !6, i64 82824, !6, i64 82832, !6, i64 82840, !6, i64 82848, !6, i64 82856, !6, i64 82864, !10, i64 82872}
!14 = !{!"memorypool", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !15, i64 64, !15, i64 72, !11, i64 80, !11, i64 84}
!15 = !{!"long", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!18, !11, i64 120}
!18 = !{!"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, !16, i64 136, !16, i64 140, !16, i64 144, !16, i64 148}
!19 = !{!13, !6, i64 82856}
!20 = !{!11, !11, i64 0}
!21 = !{!13, !11, i64 82704}
!22 = !{!13, !11, i64 82736}
!23 = !{!16, !16, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!18, !11, i64 12}
!27 = !{!13, !11, i64 82740}
!28 = !{!10, !11, i64 8}


; 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: nounwind uwtable
declare dso_local ptr @poolalloc(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @maketriangle(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @poolalloc(ptr noundef %0)
  store ptr %4, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 82840
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  store ptr %6, ptr %4, align 8, !tbaa !16
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %6, ptr %8, align 8, !tbaa !16
  %9 = load ptr, ptr %5, align 8, !tbaa !11
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %9, ptr %11, align 8, !tbaa !16
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 24
  store ptr null, ptr %13, align 8, !tbaa !16
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 32
  store ptr null, ptr %15, align 8, !tbaa !16
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 40
  store ptr null, ptr %17, align 8, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %1, i64 120
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %30, label %20

20:                                               ; preds = %3
  %21 = getelementptr inbounds i8, ptr %0, i64 82856
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 48
  store ptr %22, ptr %24, align 8, !tbaa !16
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 56
  store ptr %22, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %21, align 8, !tbaa !19
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 64
  store ptr %27, ptr %29, align 8, !tbaa !16
  br label %30

30:                                               ; preds = %20, %3
  %31 = getelementptr inbounds i8, ptr %0, i64 82704
  %32 = load i32, ptr %31, align 8, !tbaa !20
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %30
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 82736
  %36 = load i32, ptr %35, align 8, !tbaa !21
  %37 = sext i32 %36 to i64
  %38 = shl nsw i64 %37, 2
  %scevgep = getelementptr i8, ptr %34, i64 %38
  %39 = zext nneg i32 %32 to i64
  %40 = shl nuw nsw i64 %39, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %scevgep, i8 0, i64 %40, i1 false), !tbaa !22
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %30
  %41 = getelementptr inbounds i8, ptr %1, i64 12
  %42 = load i32, ptr %41, align 4, !tbaa !23
  %.not27 = icmp eq i32 %42, 0
  br i1 %.not27, label %49, label %43

43:                                               ; preds = %._crit_edge
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %0, i64 82740
  %46 = load i32, ptr %45, align 4, !tbaa !24
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds float, ptr %44, i64 %47
  store float -1.000000e+00, ptr %48, align 4, !tbaa !22
  br label %49

49:                                               ; preds = %43, %._crit_edge
  %50 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 0, ptr %50, align 8, !tbaa !25
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass