; 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.splaynode = type { %struct.otri, ptr, ptr, ptr }

@minus1mod3 = external dso_local global [3 x i32], align 4

; 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
declare dso_local i32 @rightofhyperbola(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @splayinsert(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
  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
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mesh, ptr %10, i32 0, i32 7
  %12 = call ptr @poolalloc(ptr noundef %11)
  store ptr %12, ptr %9, align 8, !tbaa !5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.otri, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.splaynode, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.otri, ptr %17, i32 0, i32 0
  store ptr %15, ptr %18, align 8, !tbaa !12
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.otri, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.splaynode, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.otri, ptr %23, i32 0, i32 1
  store i32 %21, ptr %24, align 8, !tbaa !15
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.otri, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.otri, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !14
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [3 x i32], ptr @minus1mod3, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = add nsw i32 %33, 3
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds ptr, ptr %27, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.splaynode, ptr %38, i32 0, i32 1
  store ptr %37, ptr %39, align 8, !tbaa !17
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %47

42:                                               ; preds = %4
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.splaynode, ptr %43, i32 0, i32 2
  store ptr null, ptr %44, align 8, !tbaa !18
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.splaynode, ptr %45, i32 0, i32 3
  store ptr null, ptr %46, align 8, !tbaa !19
  br label %77

47:                                               ; preds = %4
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.splaynode, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call i32 @rightofhyperbola(ptr noundef %48, ptr noundef %50, ptr noundef %51)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %65

54:                                               ; preds = %47
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.splaynode, ptr %56, i32 0, i32 2
  store ptr %55, ptr %57, align 8, !tbaa !18
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.splaynode, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.splaynode, ptr %61, i32 0, i32 3
  store ptr %60, ptr %62, align 8, !tbaa !19
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.splaynode, ptr %63, i32 0, i32 3
  store ptr null, ptr %64, align 8, !tbaa !19
  br label %76

65:                                               ; preds = %47
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.splaynode, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.splaynode, ptr %69, i32 0, i32 2
  store ptr %68, ptr %70, align 8, !tbaa !18
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.splaynode, ptr %72, i32 0, i32 3
  store ptr %71, ptr %73, align 8, !tbaa !19
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.splaynode, ptr %74, i32 0, i32 2
  store ptr null, ptr %75, align 8, !tbaa !18
  br label %76

76:                                               ; preds = %65, %54
  br label %77

77:                                               ; preds = %76, %42
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret ptr %78
}

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 0}
!13 = !{!"splaynode", !10, i64 0, !6, i64 16, !6, i64 24, !6, i64 32}
!14 = !{!10, !11, i64 8}
!15 = !{!13, !11, i64 8}
!16 = !{!11, !11, i64 0}
!17 = !{!13, !6, i64 16}
!18 = !{!13, !6, i64 24}
!19 = !{!13, !6, i64 32}


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

@minus1mod3 = external dso_local local_unnamed_addr global [3 x i32], align 4

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @splayinsert(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 616
  %6 = tail call ptr @poolalloc(ptr noundef nonnull %5)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %7, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %9, ptr %10, align 8, !tbaa !14
  %11 = sext i32 %9 to i64
  %12 = getelementptr inbounds [3 x i32], ptr @minus1mod3, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !15
  %14 = sext i32 %13 to i64
  %15 = getelementptr ptr, ptr %7, i64 %14
  %16 = getelementptr i8, ptr %15, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %17, ptr %18, align 8, !tbaa !17
  %19 = icmp eq ptr %1, null
  br i1 %19, label %20, label %22

20:                                               ; preds = %4
  %21 = getelementptr inbounds i8, ptr %6, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %21, i8 0, i64 16, i1 false)
  br label %33

22:                                               ; preds = %4
  %23 = tail call i32 @rightofhyperbola(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %3)
  %.not = icmp eq i32 %23, 0
  %24 = getelementptr inbounds i8, ptr %6, i64 32
  br i1 %.not, label %29, label %25

25:                                               ; preds = %22
  %26 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr %1, ptr %26, align 8, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %1, i64 32
  %28 = load ptr, ptr %27, align 8, !tbaa !19
  store ptr %28, ptr %24, align 8, !tbaa !19
  store ptr null, ptr %27, align 8, !tbaa !19
  br label %33

29:                                               ; preds = %22
  %30 = getelementptr inbounds i8, ptr %1, i64 24
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr %31, ptr %32, align 8, !tbaa !18
  store ptr %1, ptr %24, align 8, !tbaa !19
  store ptr null, ptr %30, align 8, !tbaa !18
  br label %33

33:                                               ; preds = %25, %29, %20
  ret ptr %6
}

; 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 0}
!12 = !{!"splaynode", !6, i64 0, !7, i64 16, !7, i64 24, !7, i64 32}
!13 = !{!6, !10, i64 8}
!14 = !{!12, !10, i64 8}
!15 = !{!10, !10, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !7, i64 16}
!18 = !{!12, !7, i64 24}
!19 = !{!12, !7, i64 32}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass