; LLVM IR from ETH3D/dataset-pipeline :: thirdparty/cork/cork/isct (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, double, double, double, double, double, 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.event = type { double, double, ptr, i32 }

; 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 @trimalloc(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @traversalinit(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @vertextraverse(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @eventheapinsert(ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @createeventheap(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mesh, ptr %12, i32 0, i32 18
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = mul nsw i32 3, %14
  %16 = sdiv i32 %15, 2
  store i32 %16, ptr %10, align 4, !tbaa !16
  %17 = load i32, ptr %10, align 4, !tbaa !16
  %18 = mul nsw i32 %17, 8
  %19 = call ptr @trimalloc(i32 noundef %18)
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %19, ptr %20, align 8, !tbaa !5
  %21 = load i32, ptr %10, align 4, !tbaa !16
  %22 = mul nsw i32 %21, 32
  %23 = call ptr @trimalloc(i32 noundef %22)
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %23, ptr %24, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mesh, ptr %25, i32 0, i32 2
  call void @traversalinit(ptr noundef %26)
  store i32 0, ptr %11, align 4, !tbaa !16
  br label %27

27:                                               ; preds = %69, %4
  %28 = load i32, ptr %11, align 4, !tbaa !16
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mesh, ptr %29, i32 0, i32 18
  %31 = load i32, ptr %30, align 8, !tbaa !9
  %32 = icmp slt i32 %28, %31
  br i1 %32, label %33, label %72

33:                                               ; preds = %27
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call ptr @vertextraverse(ptr noundef %34)
  store ptr %35, ptr %9, align 8, !tbaa !5
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = load i32, ptr %11, align 4, !tbaa !16
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %struct.event, ptr %38, i64 %40
  %42 = getelementptr inbounds %struct.event, ptr %41, i32 0, i32 2
  store ptr %36, ptr %42, align 8, !tbaa !17
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds double, ptr %43, i64 0
  %45 = load double, ptr %44, align 8, !tbaa !19
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = load i32, ptr %11, align 4, !tbaa !16
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %struct.event, ptr %47, i64 %49
  %51 = getelementptr inbounds %struct.event, ptr %50, i32 0, i32 0
  store double %45, ptr %51, align 8, !tbaa !20
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds double, ptr %52, i64 1
  %54 = load double, ptr %53, align 8, !tbaa !19
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = load i32, ptr %11, align 4, !tbaa !16
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.event, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.event, ptr %59, i32 0, i32 1
  store double %54, ptr %60, align 8, !tbaa !21
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load i32, ptr %11, align 4, !tbaa !16
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !16
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds %struct.event, ptr %65, i64 %67
  call void @eventheapinsert(ptr noundef %62, i32 noundef %63, ptr noundef %68)
  br label %69

69:                                               ; preds = %33
  %70 = load i32, ptr %11, align 4, !tbaa !16
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %11, align 4, !tbaa !16
  br label %27, !llvm.loop !22

72:                                               ; preds = %27
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr null, ptr %73, align 8, !tbaa !5
  %74 = load i32, ptr %10, align 4, !tbaa !16
  %75 = sub nsw i32 %74, 1
  store i32 %75, ptr %11, align 4, !tbaa !16
  br label %76

76:                                               ; preds = %97, %72
  %77 = load i32, ptr %11, align 4, !tbaa !16
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mesh, ptr %78, i32 0, i32 18
  %80 = load i32, ptr %79, align 8, !tbaa !9
  %81 = icmp sge i32 %77, %80
  br i1 %81, label %82, label %100

82:                                               ; preds = %76
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = load ptr, ptr %83, align 8, !tbaa !5
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = load i32, ptr %11, align 4, !tbaa !16
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds %struct.event, ptr %86, i64 %88
  %90 = getelementptr inbounds %struct.event, ptr %89, i32 0, i32 2
  store ptr %84, ptr %90, align 8, !tbaa !17
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = load ptr, ptr %91, align 8, !tbaa !5
  %93 = load i32, ptr %11, align 4, !tbaa !16
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds %struct.event, ptr %92, i64 %94
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %95, ptr %96, align 8, !tbaa !5
  br label %97

97:                                               ; preds = %82
  %98 = load i32, ptr %11, align 4, !tbaa !16
  %99 = add nsw i32 %98, -1
  store i32 %99, ptr %11, align 4, !tbaa !16
  br label %76, !llvm.loop !24

100:                                              ; preds = %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #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 82680}
!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 82648, !14, i64 82656, !14, i64 82664, !14, i64 82672, !12, i64 82680, !12, i64 82684, !12, i64 82688, !12, i64 82692, !12, i64 82696, !12, i64 82700, !13, i64 82704, !12, i64 82712, !12, i64 82716, !12, i64 82720, !13, i64 82728, !12, i64 82736, !12, i64 82740, !12, i64 82744, !12, i64 82748, !12, i64 82752, !12, i64 82756, !12, i64 82760, !12, i64 82764, !12, i64 82768, !13, i64 82776, !13, i64 82784, !13, i64 82792, !13, i64 82800, !13, i64 82808, !13, i64 82816, !13, i64 82824, !6, i64 82832, !6, i64 82840, !6, i64 82848, !6, i64 82856, !6, i64 82864, !6, i64 82872, !6, i64 82880, !15, i64 82888}
!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 = !{!"double", !7, i64 0}
!15 = !{!"otri", !6, i64 0, !12, i64 8}
!16 = !{!12, !12, i64 0}
!17 = !{!18, !6, i64 16}
!18 = !{!"event", !14, i64 0, !14, i64 8, !6, i64 16, !12, i64 24}
!19 = !{!14, !14, i64 0}
!20 = !{!18, !14, i64 0}
!21 = !{!18, !14, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @createeventheap(ptr noundef %0, ptr nocapture noundef %1, ptr nocapture noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 82680
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = mul nsw i32 %6, 3
  %8 = sdiv i32 %7, 2
  %9 = shl nsw i32 %8, 3
  %10 = tail call ptr @trimalloc(i32 noundef %9)
  store ptr %10, ptr %1, align 8, !tbaa !15
  %11 = shl nsw i32 %8, 5
  %12 = tail call ptr @trimalloc(i32 noundef %11)
  store ptr %12, ptr %2, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @traversalinit(ptr noundef nonnull %13)
  %14 = load i32, ptr %5, align 8, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %4
  %.lcssa = phi i32 [ %14, %4 ], [ %36, %.lr.ph ]
  store ptr null, ptr %3, align 8, !tbaa !15
  %.not.not34 = icmp sgt i32 %8, %.lcssa
  br i1 %.not.not34, label %.lr.ph37.preheader, label %._crit_edge

.lr.ph37.preheader:                               ; preds = %.preheader
  %16 = sext i32 %8 to i64
  %17 = sext i32 %.lcssa to i64
  %18 = sub nsw i64 %16, %17
  %xtraiter = and i64 %18, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph37.prol.loopexit, label %.lr.ph37.prol

.lr.ph37.prol:                                    ; preds = %.lr.ph37.preheader
  %indvars.iv.next41.prol = add nsw i64 %16, -1
  %19 = load ptr, ptr %2, align 8, !tbaa !15
  %20 = getelementptr inbounds %struct.event, ptr %19, i64 %indvars.iv.next41.prol, i32 2
  store ptr null, ptr %20, align 8, !tbaa !16
  %21 = load ptr, ptr %2, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.event, ptr %21, i64 %indvars.iv.next41.prol
  store ptr %22, ptr %3, align 8, !tbaa !15
  br label %.lr.ph37.prol.loopexit

.lr.ph37.prol.loopexit:                           ; preds = %.lr.ph37.prol, %.lr.ph37.preheader
  %indvars.iv40.unr = phi i64 [ %16, %.lr.ph37.preheader ], [ %indvars.iv.next41.prol, %.lr.ph37.prol ]
  %storemerge35.unr = phi ptr [ null, %.lr.ph37.preheader ], [ %22, %.lr.ph37.prol ]
  %23 = add nsw i64 %16, -1
  %24 = icmp eq i64 %23, %17
  br i1 %24, label %._crit_edge, label %.lr.ph37

.lr.ph:                                           ; preds = %4, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %4 ]
  %25 = tail call ptr @vertextraverse(ptr noundef nonnull %0)
  %26 = load ptr, ptr %2, align 8, !tbaa !15
  %27 = getelementptr inbounds %struct.event, ptr %26, i64 %indvars.iv, i32 2
  store ptr %25, ptr %27, align 8, !tbaa !16
  %28 = load double, ptr %25, align 8, !tbaa !18
  %29 = load ptr, ptr %2, align 8, !tbaa !15
  %30 = getelementptr inbounds %struct.event, ptr %29, i64 %indvars.iv
  store double %28, ptr %30, align 8, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %25, i64 8
  %32 = load double, ptr %31, align 8, !tbaa !18
  %33 = getelementptr inbounds %struct.event, ptr %29, i64 %indvars.iv, i32 1
  store double %32, ptr %33, align 8, !tbaa !20
  %34 = load ptr, ptr %1, align 8, !tbaa !15
  %35 = trunc nuw nsw i64 %indvars.iv to i32
  tail call void @eventheapinsert(ptr noundef %34, i32 noundef %35, ptr noundef nonnull %30)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %36 = load i32, ptr %5, align 8, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next, %37
  br i1 %38, label %.lr.ph, label %.preheader, !llvm.loop !21

.lr.ph37:                                         ; preds = %.lr.ph37.prol.loopexit, %.lr.ph37
  %indvars.iv40 = phi i64 [ %indvars.iv.next41.1, %.lr.ph37 ], [ %indvars.iv40.unr, %.lr.ph37.prol.loopexit ]
  %storemerge35 = phi ptr [ %46, %.lr.ph37 ], [ %storemerge35.unr, %.lr.ph37.prol.loopexit ]
  %indvars.iv.next41 = add nsw i64 %indvars.iv40, -1
  %39 = load ptr, ptr %2, align 8, !tbaa !15
  %40 = getelementptr inbounds %struct.event, ptr %39, i64 %indvars.iv.next41, i32 2
  store ptr %storemerge35, ptr %40, align 8, !tbaa !16
  %41 = load ptr, ptr %2, align 8, !tbaa !15
  %42 = getelementptr inbounds %struct.event, ptr %41, i64 %indvars.iv.next41
  store ptr %42, ptr %3, align 8, !tbaa !15
  %indvars.iv.next41.1 = add nsw i64 %indvars.iv40, -2
  %43 = load ptr, ptr %2, align 8, !tbaa !15
  %44 = getelementptr inbounds %struct.event, ptr %43, i64 %indvars.iv.next41.1, i32 2
  store ptr %42, ptr %44, align 8, !tbaa !16
  %45 = load ptr, ptr %2, align 8, !tbaa !15
  %46 = getelementptr inbounds %struct.event, ptr %45, i64 %indvars.iv.next41.1
  store ptr %46, ptr %3, align 8, !tbaa !15
  %.not.not.1 = icmp sgt i64 %indvars.iv.next41.1, %17
  br i1 %.not.not.1, label %.lr.ph37, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph37.prol.loopexit, %.lr.ph37, %.preheader
  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, !11, i64 82680}
!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 82648, !13, i64 82656, !13, i64 82664, !13, i64 82672, !11, i64 82680, !11, i64 82684, !11, i64 82688, !11, i64 82692, !11, i64 82696, !11, i64 82700, !12, i64 82704, !11, i64 82712, !11, i64 82716, !11, i64 82720, !12, i64 82728, !11, i64 82736, !11, i64 82740, !11, i64 82744, !11, i64 82748, !11, i64 82752, !11, i64 82756, !11, i64 82760, !11, i64 82764, !11, i64 82768, !12, i64 82776, !12, i64 82784, !12, i64 82792, !12, i64 82800, !12, i64 82808, !12, i64 82816, !12, i64 82824, !8, i64 82832, !8, i64 82840, !8, i64 82848, !8, i64 82856, !8, i64 82864, !8, i64 82872, !8, i64 82880, !14, i64 82888}
!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 = !{!"double", !9, i64 0}
!14 = !{!"otri", !8, i64 0, !11, i64 8}
!15 = !{!8, !8, i64 0}
!16 = !{!17, !8, i64 16}
!17 = !{!"event", !13, i64 0, !13, i64 8, !8, i64 16, !11, i64 24}
!18 = !{!13, !13, i64 0}
!19 = !{!17, !13, i64 0}
!20 = !{!17, !13, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass