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

; Function Attrs: nounwind uwtable
define dso_local void @eventheapdelete(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  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 %4, align 8, !tbaa !5
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = sub nsw i32 %13, 1
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds ptr, ptr %12, i64 %15
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %17, ptr %7, align 8, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %20, label %87

20:                                               ; preds = %3
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.event, ptr %21, i32 0, i32 0
  %23 = load double, ptr %22, align 8, !tbaa !11
  store double %23, ptr %8, align 8, !tbaa !14
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.event, ptr %24, i32 0, i32 1
  %26 = load double, ptr %25, align 8, !tbaa !15
  store double %26, ptr %9, align 8, !tbaa !14
  br label %27

27:                                               ; preds = %83, %20
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = sub nsw i32 %28, 1
  %30 = ashr i32 %29, 1
  store i32 %30, ptr %10, align 4, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds ptr, ptr %31, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.event, ptr %35, i32 0, i32 1
  %37 = load double, ptr %36, align 8, !tbaa !15
  %38 = load double, ptr %9, align 8, !tbaa !14
  %39 = fcmp olt double %37, %38
  br i1 %39, label %60, label %40

40:                                               ; preds = %27
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.event, ptr %45, i32 0, i32 1
  %47 = load double, ptr %46, align 8, !tbaa !15
  %48 = load double, ptr %9, align 8, !tbaa !14
  %49 = fcmp oeq double %47, %48
  br i1 %49, label %50, label %61

50:                                               ; preds = %40
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds ptr, ptr %51, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.event, ptr %55, i32 0, i32 0
  %57 = load double, ptr %56, align 8, !tbaa !11
  %58 = load double, ptr %8, align 8, !tbaa !14
  %59 = fcmp ole double %57, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %50, %27
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %82

61:                                               ; preds = %50, %40
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds ptr, ptr %62, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds ptr, ptr %67, i64 %69
  store ptr %66, ptr %70, align 8, !tbaa !5
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = load i32, ptr %6, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds ptr, ptr %72, i64 %74
  %76 = load ptr, ptr %75, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.event, ptr %76, i32 0, i32 3
  store i32 %71, ptr %77, align 8, !tbaa !16
  %78 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %78, ptr %6, align 4, !tbaa !9
  %79 = load i32, ptr %6, align 4, !tbaa !9
  %80 = icmp sgt i32 %79, 0
  %81 = zext i1 %80 to i32
  store i32 %81, ptr %11, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %61, %60
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %27, label %86, !llvm.loop !17

86:                                               ; preds = %83
  br label %87

87:                                               ; preds = %86, %3
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = load i32, ptr %6, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds ptr, ptr %89, i64 %91
  store ptr %88, ptr %92, align 8, !tbaa !5
  %93 = load i32, ptr %6, align 4, !tbaa !9
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.event, ptr %94, i32 0, i32 3
  store i32 %93, ptr %95, align 8, !tbaa !16
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = load i32, ptr %5, align 4, !tbaa !9
  %98 = sub nsw i32 %97, 1
  %99 = load i32, ptr %6, align 4, !tbaa !9
  call void @eventheapify(ptr noundef %96, i32 noundef %98, i32 noundef %99)
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"event", !13, i64 0, !13, i64 8, !6, i64 16, !10, i64 24}
!13 = !{!"double", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 8}
!16 = !{!12, !10, i64 24}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nounwind uwtable
define dso_local void @eventheapdelete(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = add nsw i32 %1, -1
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds ptr, ptr %0, i64 %5
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp sgt i32 %2, 0
  br i1 %8, label %9, label %.thread

9:                                                ; preds = %3
  %10 = load double, ptr %7, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %7, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !13
  br label %13

13:                                               ; preds = %27, %9
  %.032 = phi i32 [ %2, %9 ], [ %15, %27 ]
  %14 = add nsw i32 %.032, -1
  %15 = lshr i32 %14, 1
  %16 = zext nneg i32 %15 to i64
  %17 = getelementptr inbounds ptr, ptr %0, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load double, ptr %19, align 8, !tbaa !13
  %21 = fcmp olt double %20, %12
  br i1 %21, label %.thread, label %22

22:                                               ; preds = %13
  %23 = fcmp oeq double %20, %12
  br i1 %23, label %24, label %27

24:                                               ; preds = %22
  %25 = load double, ptr %18, align 8, !tbaa !9
  %26 = fcmp ugt double %25, %10
  br i1 %26, label %27, label %.thread

27:                                               ; preds = %22, %24
  %28 = zext nneg i32 %.032 to i64
  %29 = getelementptr inbounds ptr, ptr %0, i64 %28
  store ptr %18, ptr %29, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %18, i64 24
  store i32 %.032, ptr %30, align 8, !tbaa !14
  %31 = icmp ult i32 %14, 2
  br i1 %31, label %.thread, label %13, !llvm.loop !15

.thread:                                          ; preds = %13, %24, %27, %3
  %.2 = phi i32 [ %2, %3 ], [ %.032, %13 ], [ %.032, %24 ], [ 0, %27 ]
  %32 = sext i32 %.2 to i64
  %33 = getelementptr inbounds ptr, ptr %0, i64 %32
  store ptr %7, ptr %33, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %7, i64 24
  store i32 %.2, ptr %34, align 8, !tbaa !14
  tail call void @eventheapify(ptr noundef %0, i32 noundef %4, i32 noundef %.2)
  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, !11, i64 0}
!10 = !{!"event", !11, i64 0, !11, i64 8, !6, i64 16, !12, i64 24}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !12, i64 24}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass