; LLVM IR from ekoontz/graphlab :: src/graphlab/extern/metis/libmetis (minitpart)

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

; 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
define dso_local i64 @SelectQueueOneWay(i64 noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) #1 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca float, align 4
  store i64 %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store i64 -1, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store float 0.000000e+00, ptr %13, align 4, !tbaa !11
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %62, %5
  %15 = load i64, ptr %11, align 8, !tbaa !5
  %16 = load i64, ptr %6, align 8, !tbaa !5
  %17 = icmp slt i64 %15, %16
  br i1 %17, label %18, label %65

18:                                               ; preds = %14
  %19 = load ptr, ptr %7, align 8, !tbaa !9
  %20 = load i64, ptr %9, align 8, !tbaa !5
  %21 = load i64, ptr %6, align 8, !tbaa !5
  %22 = mul nsw i64 %20, %21
  %23 = load i64, ptr %11, align 8, !tbaa !5
  %24 = add nsw i64 %22, %23
  %25 = getelementptr inbounds float, ptr %19, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !11
  %27 = load ptr, ptr %8, align 8, !tbaa !9
  %28 = load i64, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds float, ptr %27, i64 %28
  %30 = load float, ptr %29, align 4, !tbaa !11
  %31 = fsub float %26, %30
  %32 = load float, ptr %13, align 4, !tbaa !11
  %33 = fcmp oge float %31, %32
  br i1 %33, label %34, label %61

34:                                               ; preds = %18
  %35 = load ptr, ptr %10, align 8, !tbaa !9
  %36 = load i64, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds [2 x %struct.PQueueType], ptr %35, i64 %36
  %38 = getelementptr inbounds [2 x %struct.PQueueType], ptr %37, i64 0, i64 0
  %39 = call i64 @PQueueGetSize(ptr noundef %38)
  %40 = load ptr, ptr %10, align 8, !tbaa !9
  %41 = load i64, ptr %11, align 8, !tbaa !5
  %42 = getelementptr inbounds [2 x %struct.PQueueType], ptr %40, i64 %41
  %43 = getelementptr inbounds [2 x %struct.PQueueType], ptr %42, i64 0, i64 1
  %44 = call i64 @PQueueGetSize(ptr noundef %43)
  %45 = add nsw i64 %39, %44
  %46 = icmp sgt i64 %45, 0
  br i1 %46, label %47, label %61

47:                                               ; preds = %34
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  %49 = load i64, ptr %9, align 8, !tbaa !5
  %50 = load i64, ptr %6, align 8, !tbaa !5
  %51 = mul nsw i64 %49, %50
  %52 = load i64, ptr %11, align 8, !tbaa !5
  %53 = add nsw i64 %51, %52
  %54 = getelementptr inbounds float, ptr %48, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !11
  %56 = load ptr, ptr %8, align 8, !tbaa !9
  %57 = getelementptr inbounds float, ptr %56, i64 0
  %58 = load float, ptr %57, align 4, !tbaa !11
  %59 = fsub float %55, %58
  store float %59, ptr %13, align 4, !tbaa !11
  %60 = load i64, ptr %11, align 8, !tbaa !5
  store i64 %60, ptr %12, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %47, %34, %18
  br label %62

62:                                               ; preds = %61
  %63 = load i64, ptr %11, align 8, !tbaa !5
  %64 = add nsw i64 %63, 1
  store i64 %64, ptr %11, align 8, !tbaa !5
  br label %14, !llvm.loop !13

65:                                               ; preds = %14
  %66 = load i64, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret i64 %66
}

declare i64 @PQueueGetSize(ptr noundef) #2

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 = { "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 #3 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%struct.PQueueType = type { i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i64 @SelectQueueOneWay(i64 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = icmp sgt i64 %0, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %7 = mul nsw i64 %3, %0
  %8 = getelementptr float, ptr %1, i64 %7
  %9 = getelementptr inbounds float, ptr %2, i64 %3
  br label %10

10:                                               ; preds = %.lr.ph, %27
  %.026 = phi float [ 0.000000e+00, %.lr.ph ], [ %.1, %27 ]
  %.02025 = phi i64 [ -1, %.lr.ph ], [ %.121, %27 ]
  %.02224 = phi i64 [ 0, %.lr.ph ], [ %28, %27 ]
  %11 = getelementptr float, ptr %8, i64 %.02224
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = load float, ptr %9, align 4, !tbaa !5
  %14 = fsub float %12, %13
  %15 = fcmp ult float %14, %.026
  br i1 %15, label %27, label %16

16:                                               ; preds = %10
  %17 = getelementptr inbounds [2 x %struct.PQueueType], ptr %4, i64 %.02224
  %18 = tail call i64 @PQueueGetSize(ptr noundef %17) #2
  %19 = getelementptr inbounds i8, ptr %17, i64 88
  %20 = tail call i64 @PQueueGetSize(ptr noundef nonnull %19) #2
  %21 = add nsw i64 %20, %18
  %22 = icmp sgt i64 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %16
  %24 = load float, ptr %11, align 4, !tbaa !5
  %25 = load float, ptr %2, align 4, !tbaa !5
  %26 = fsub float %24, %25
  br label %27

27:                                               ; preds = %10, %16, %23
  %.121 = phi i64 [ %.02224, %23 ], [ %.02025, %16 ], [ %.02025, %10 ]
  %.1 = phi float [ %26, %23 ], [ %.026, %16 ], [ %.026, %10 ]
  %28 = add nuw nsw i64 %.02224, 1
  %exitcond.not = icmp eq i64 %28, %0
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !9

._crit_edge:                                      ; preds = %27, %5
  %.020.lcssa = phi i64 [ -1, %5 ], [ %.121, %27 ]
  ret i64 %.020.lcssa
}

declare i64 @PQueueGetSize(ptr noundef) local_unnamed_addr #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 = { "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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