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

@randomseed = external dso_local global i64, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @poolzero(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @exactinit() #0

; Function Attrs: nounwind uwtable
define dso_local void @triangleinit(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.mesh, ptr %3, i32 0, i32 2
  call void @poolzero(ptr noundef %4)
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.mesh, ptr %5, i32 0, i32 0
  call void @poolzero(ptr noundef %6)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.mesh, ptr %7, i32 0, i32 1
  call void @poolzero(ptr noundef %8)
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mesh, ptr %9, i32 0, i32 3
  call void @poolzero(ptr noundef %10)
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.mesh, ptr %11, i32 0, i32 4
  call void @poolzero(ptr noundef %12)
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.mesh, ptr %13, i32 0, i32 5
  call void @poolzero(ptr noundef %14)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mesh, ptr %15, i32 0, i32 6
  call void @poolzero(ptr noundef %16)
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mesh, ptr %17, i32 0, i32 7
  call void @poolzero(ptr noundef %18)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mesh, ptr %19, i32 0, i32 52
  %21 = getelementptr inbounds %struct.otri, ptr %20, i32 0, i32 0
  store ptr null, ptr %21, align 8, !tbaa !9
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mesh, ptr %22, i32 0, i32 23
  store i32 0, ptr %23, align 8, !tbaa !16
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mesh, ptr %24, i32 0, i32 38
  store i64 1, ptr %25, align 8, !tbaa !17
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mesh, ptr %26, i32 0, i32 35
  store i32 0, ptr %27, align 8, !tbaa !18
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mesh, ptr %28, i32 0, i32 36
  store i32 0, ptr %29, align 4, !tbaa !19
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mesh, ptr %30, i32 0, i32 41
  store i64 0, ptr %31, align 8, !tbaa !20
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.mesh, ptr %32, i32 0, i32 40
  store i64 0, ptr %33, align 8, !tbaa !21
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mesh, ptr %34, i32 0, i32 39
  store i64 0, ptr %35, align 8, !tbaa !22
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mesh, ptr %36, i32 0, i32 43
  store i64 0, ptr %37, align 8, !tbaa !23
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mesh, ptr %38, i32 0, i32 44
  store i64 0, ptr %39, align 8, !tbaa !24
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mesh, ptr %40, i32 0, i32 42
  store i64 0, ptr %41, align 8, !tbaa !25
  store i64 1, ptr @randomseed, align 8, !tbaa !26
  call void @exactinit()
  ret void
}

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 82872}
!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 = !{!10, !12, i64 82680}
!17 = !{!10, !13, i64 82760}
!18 = !{!10, !12, i64 82744}
!19 = !{!10, !12, i64 82748}
!20 = !{!10, !13, i64 82784}
!21 = !{!10, !13, i64 82776}
!22 = !{!10, !13, i64 82768}
!23 = !{!10, !13, i64 82800}
!24 = !{!10, !13, i64 82808}
!25 = !{!10, !13, i64 82792}
!26 = !{!27, !27, i64 0}
!27 = !{!"long long", !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"

@randomseed = external dso_local local_unnamed_addr global i64, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @poolzero(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @exactinit() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @triangleinit(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @poolzero(ptr noundef nonnull %2)
  tail call void @poolzero(ptr noundef %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @poolzero(ptr noundef nonnull %3)
  %4 = getelementptr inbounds i8, ptr %0, i64 264
  tail call void @poolzero(ptr noundef nonnull %4)
  %5 = getelementptr inbounds i8, ptr %0, i64 352
  tail call void @poolzero(ptr noundef nonnull %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 440
  tail call void @poolzero(ptr noundef nonnull %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 528
  tail call void @poolzero(ptr noundef nonnull %7)
  %8 = getelementptr inbounds i8, ptr %0, i64 616
  tail call void @poolzero(ptr noundef nonnull %8)
  %9 = getelementptr inbounds i8, ptr %0, i64 82872
  store ptr null, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 82680
  store i32 0, ptr %10, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %0, i64 82760
  store i64 1, ptr %11, align 8, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %0, i64 82744
  store i32 0, ptr %12, align 8, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %0, i64 82748
  store i32 0, ptr %13, align 4, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %0, i64 82768
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %14, i8 0, i64 48, i1 false)
  store i64 1, ptr @randomseed, align 8, !tbaa !19
  tail call void @exactinit()
  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, !8, i64 82872}
!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 = !{!6, !11, i64 82680}
!16 = !{!6, !12, i64 82760}
!17 = !{!6, !11, i64 82744}
!18 = !{!6, !11, i64 82748}
!19 = !{!20, !20, i64 0}
!20 = !{!"long long", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass