; 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 void @poolinit(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @initializevertexpool(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  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 4, ptr %5) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.mesh, ptr %6, i32 0, i32 25
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mesh, ptr %9, i32 0, i32 26
  %11 = load i32, ptr %10, align 4, !tbaa !16
  %12 = add nsw i32 %8, %11
  %13 = sext i32 %12 to i64
  %14 = mul i64 %13, 4
  %15 = add i64 %14, 4
  %16 = sub i64 %15, 1
  %17 = udiv i64 %16, 4
  %18 = trunc i64 %17 to i32
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mesh, ptr %19, i32 0, i32 30
  store i32 %18, ptr %20, align 4, !tbaa !17
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mesh, ptr %21, i32 0, i32 30
  %23 = load i32, ptr %22, align 4, !tbaa !17
  %24 = add nsw i32 %23, 2
  %25 = sext i32 %24 to i64
  %26 = mul i64 %25, 4
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %5, align 4, !tbaa !18
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.behavior, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 4, !tbaa !19
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %48

32:                                               ; preds = %2
  %33 = load i32, ptr %5, align 4, !tbaa !18
  %34 = sext i32 %33 to i64
  %35 = add i64 %34, 8
  %36 = sub i64 %35, 1
  %37 = udiv i64 %36, 8
  %38 = trunc i64 %37 to i32
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.mesh, ptr %39, i32 0, i32 31
  store i32 %38, ptr %40, align 8, !tbaa !21
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mesh, ptr %41, i32 0, i32 31
  %43 = load i32, ptr %42, align 8, !tbaa !21
  %44 = add nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = mul i64 %45, 8
  %47 = trunc i64 %46 to i32
  store i32 %47, ptr %5, align 4, !tbaa !18
  br label %48

48:                                               ; preds = %32, %2
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.mesh, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %5, align 4, !tbaa !18
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mesh, ptr %52, i32 0, i32 18
  %54 = load i32, ptr %53, align 4, !tbaa !22
  %55 = icmp sgt i32 %54, 4092
  br i1 %55, label %56, label %60

56:                                               ; preds = %48
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mesh, ptr %57, i32 0, i32 18
  %59 = load i32, ptr %58, align 4, !tbaa !22
  br label %61

60:                                               ; preds = %48
  br label %61

61:                                               ; preds = %60, %56
  %62 = phi i32 [ %59, %56 ], [ 4092, %60 ]
  call void @poolinit(ptr noundef %50, i32 noundef %51, i32 noundef 4092, i32 noundef %62, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 4, 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, !12, i64 82696}
!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 82700}
!17 = !{!10, !12, i64 82724}
!18 = !{!12, !12, i64 0}
!19 = !{!20, !12, i64 0}
!20 = !{!"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}
!21 = !{!10, !12, i64 82728}
!22 = !{!10, !12, i64 82660}


; 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 void @poolinit(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @initializevertexpool(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 82696
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 82700
  %6 = load i32, ptr %5, align 4, !tbaa !15
  %7 = add nsw i32 %6, %4
  %8 = getelementptr inbounds i8, ptr %0, i64 82724
  store i32 %7, ptr %8, align 4, !tbaa !16
  %9 = shl i32 %7, 2
  %10 = add i32 %9, 8
  %11 = load i32, ptr %1, align 4, !tbaa !17
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %21, label %12

12:                                               ; preds = %2
  %13 = sext i32 %10 to i64
  %14 = add nsw i64 %13, 7
  %15 = lshr i64 %14, 3
  %16 = trunc i64 %15 to i32
  %17 = getelementptr inbounds i8, ptr %0, i64 82728
  store i32 %16, ptr %17, align 8, !tbaa !19
  %18 = shl i64 %15, 32
  %sext = add i64 %18, 4294967296
  %19 = lshr exact i64 %sext, 29
  %20 = trunc i64 %19 to i32
  br label %21

21:                                               ; preds = %12, %2
  %.0 = phi i32 [ %20, %12 ], [ %10, %2 ]
  %22 = getelementptr inbounds i8, ptr %0, i64 82660
  %23 = load i32, ptr %22, align 4, !tbaa !20
  %spec.select = tail call i32 @llvm.smax.i32(i32 %23, i32 4092)
  %24 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @poolinit(ptr noundef nonnull %24, i32 noundef %.0, i32 noundef 4092, i32 noundef %spec.select, i32 noundef 4)
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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 nosync nounwind speculatable willreturn memory(none) }

!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, !11, i64 82696}
!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 82700}
!16 = !{!6, !11, i64 82724}
!17 = !{!18, !11, i64 0}
!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, !13, i64 136, !13, i64 140, !13, i64 144, !13, i64 148}
!19 = !{!6, !11, i64 82728}
!20 = !{!6, !11, i64 82660}


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