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

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

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

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

30:                                               ; preds = %90, %6
  %31 = load i32, ptr %13, align 4, !tbaa !13
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %39, label %33

33:                                               ; preds = %30
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = call i32 @rightofhyperbola(ptr noundef %34, ptr noundef %35, ptr noundef %36)
  %38 = icmp ne i32 %37, 0
  br label %39

39:                                               ; preds = %33, %30
  %40 = phi i1 [ false, %30 ], [ %38, %33 ]
  br i1 %40, label %41, label %93

41:                                               ; preds = %39
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.otri, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !12
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [3 x i32], ptr @minus1mod3, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !13
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.otri, ptr %48, i32 0, i32 1
  store i32 %47, ptr %49, align 8, !tbaa !12
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.otri, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.otri, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 8, !tbaa !12
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds ptr, ptr %52, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  store ptr %58, ptr %14, align 8, !tbaa !5
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = ptrtoint ptr %59 to i64
  %61 = and i64 %60, 3
  %62 = trunc i64 %61 to i32
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.otri, ptr %63, i32 0, i32 1
  store i32 %62, ptr %64, align 8, !tbaa !12
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = ptrtoint ptr %65 to i64
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.otri, ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 8, !tbaa !12
  %70 = sext i32 %69 to i64
  %71 = xor i64 %66, %70
  %72 = inttoptr i64 %71 to ptr
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.otri, ptr %73, i32 0, i32 0
  store ptr %72, ptr %74, align 8, !tbaa !9
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.otri, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !9
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.otri, ptr %78, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  %81 = icmp eq ptr %77, %80
  br i1 %81, label %82, label %90

82:                                               ; preds = %41
  %83 = load ptr, ptr %11, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.otri, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 8, !tbaa !12
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.otri, ptr %86, i32 0, i32 1
  %88 = load i32, ptr %87, align 8, !tbaa !12
  %89 = icmp eq i32 %85, %88
  br label %90

90:                                               ; preds = %82, %41
  %91 = phi i1 [ false, %41 ], [ %89, %82 ]
  %92 = zext i1 %91 to i32
  store i32 %92, ptr %13, align 4, !tbaa !13
  br label %30, !llvm.loop !14

93:                                               ; preds = %39
  %94 = load i32, ptr %13, align 4, !tbaa !13
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %94, ptr %95, align 4, !tbaa !13
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  ret ptr %96
}

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 = !{!10, !11, i64 8}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @frontlocate(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %9, ptr %10, align 8, !tbaa !11
  %11 = tail call ptr @splay(ptr noundef %0, ptr noundef %1, ptr noundef %3, ptr noundef nonnull %4)
  %12 = tail call i32 @rightofhyperbola(ptr noundef %0, ptr noundef nonnull %4, ptr noundef %3)
  %.not2729 = icmp eq i32 %12, 0
  br i1 %.not2729, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %6, %.backedge
  %13 = load i32, ptr %10, align 8, !tbaa !11
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [3 x i32], ptr @minus1mod3, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = sext i32 %16 to i64
  %19 = getelementptr inbounds ptr, ptr %17, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = ptrtoint ptr %20 to i64
  %22 = trunc i64 %21 to i32
  %23 = and i32 %22, 3
  store i32 %23, ptr %10, align 8, !tbaa !11
  %24 = and i64 %21, -4
  %25 = inttoptr i64 %24 to ptr
  store ptr %25, ptr %4, align 8, !tbaa !5
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = icmp eq ptr %26, %25
  br i1 %27, label %28, label %.backedge

28:                                               ; preds = %.lr.ph
  %29 = load i32, ptr %8, align 8, !tbaa !11
  %30 = icmp eq i32 %23, %29
  br i1 %30, label %.critedge, label %.backedge

.backedge:                                        ; preds = %.lr.ph, %28
  %31 = tail call i32 @rightofhyperbola(ptr noundef %0, ptr noundef nonnull %4, ptr noundef %3)
  %.not27 = icmp eq i32 %31, 0
  br i1 %.not27, label %.critedge, label %.lr.ph, !llvm.loop !14

.critedge:                                        ; preds = %.backedge, %28, %6
  %.0.lcssa = phi i32 [ 0, %6 ], [ 0, %.backedge ], [ 1, %28 ]
  store i32 %.0.lcssa, ptr %5, align 4, !tbaa !12
  ret ptr %11
}

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, !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 = !{!6, !10, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass