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

; 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.controldef = type { i64, i64, i64, i64, i64, i64, float, i64, i64, i64, i64, %struct.workspacedef, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }
%struct.workspacedef = type { ptr, i64, i64, ptr, ptr, i64, ptr, ptr }
%struct.graphdef = type { i64, i64, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i64, i64, ptr, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare double @gk_CPUSeconds() #1

; Function Attrs: nounwind uwtable
define dso_local i64 @MCMlevelKWayRefinement(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca [10 x i64], align 16
  %16 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call ptr @libmetis__MCCoarsen2Way(ptr noundef %17, ptr noundef %18)
  store ptr %19, ptr %14, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.controldef, ptr %20, i32 0, i32 1
  %22 = load i64, ptr %21, align 8, !tbaa !11
  %23 = and i64 %22, 1
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %5
  %26 = call double @gk_CPUSeconds()
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.controldef, ptr %27, i32 0, i32 13
  %29 = load double, ptr %28, align 8, !tbaa !16
  %30 = fsub double %29, %26
  store double %30, ptr %28, align 8, !tbaa !16
  br label %31

31:                                               ; preds = %25, %5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = load i64, ptr %8, align 8, !tbaa !9
  call void @libmetis__MocAllocateKWayPartitionMemory(ptr noundef %32, ptr noundef %33, i64 noundef %34)
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.graphdef, ptr %35, i32 0, i32 0
  %37 = load i64, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.graphdef, ptr %38, i32 0, i32 0
  %40 = load i64, ptr %39, align 8, !tbaa !17
  %41 = icmp ne i64 %37, %40
  br i1 %41, label %42, label %49

42:                                               ; preds = %31
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.graphdef, ptr %43, i32 0, i32 0
  %45 = load i64, ptr %44, align 8, !tbaa !17
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.graphdef, ptr %46, i32 0, i32 0
  %48 = load i64, ptr %47, align 8, !tbaa !17
  call void (ptr, ...) @errexit(ptr noundef @.str, i64 noundef %45, i64 noundef %48)
  br label %49

49:                                               ; preds = %42, %31
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %71, %49
  %51 = load i64, ptr %11, align 8, !tbaa !9
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.graphdef, ptr %52, i32 0, i32 0
  %54 = load i64, ptr %53, align 8, !tbaa !17
  %55 = icmp slt i64 %51, %54
  br i1 %55, label %56, label %74

56:                                               ; preds = %50
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load i64, ptr %11, align 8, !tbaa !9
  %59 = getelementptr inbounds i64, ptr %57, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.graphdef, ptr %61, i32 0, i32 18
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.graphdef, ptr %64, i32 0, i32 15
  %66 = load ptr, ptr %65, align 8, !tbaa !21
  %67 = load i64, ptr %11, align 8, !tbaa !9
  %68 = getelementptr inbounds i64, ptr %66, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds i64, ptr %63, i64 %69
  store i64 %60, ptr %70, align 8, !tbaa !9
  br label %71

71:                                               ; preds = %56
  %72 = load i64, ptr %11, align 8, !tbaa !9
  %73 = add nsw i64 %72, 1
  store i64 %73, ptr %11, align 8, !tbaa !9
  br label %50, !llvm.loop !22

74:                                               ; preds = %50
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  %78 = load i64, ptr %8, align 8, !tbaa !9
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  call void @libmetis__MocRefineKWayHorizontal(ptr noundef %75, ptr noundef %76, ptr noundef %77, i64 noundef %78, ptr noundef %79)
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.graphdef, ptr %81, i32 0, i32 18
  %83 = load ptr, ptr %82, align 8, !tbaa !20
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.graphdef, ptr %84, i32 0, i32 0
  %86 = load i64, ptr %85, align 8, !tbaa !17
  %87 = mul i64 8, %86
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %80, ptr align 1 %83, i64 %87, i1 false)
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  call void @libmetis__FreeGraph(ptr noundef %88, i32 noundef 0)
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.graphdef, ptr %89, i32 0, i32 16
  %91 = load i64, ptr %90, align 8, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret i64 %91
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @libmetis__MCCoarsen2Way(ptr noundef, ptr noundef) #1

declare void @libmetis__MocAllocateKWayPartitionMemory(ptr noundef, ptr noundef, i64 noundef) #1

declare void @errexit(ptr noundef, ...) #1

declare void @libmetis__MocRefineKWayHorizontal(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare void @libmetis__FreeGraph(ptr noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"controldef", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !13, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !14, i64 88, !15, i64 152, !15, i64 160, !15, i64 168, !15, i64 176, !15, i64 184, !15, i64 192, !15, i64 200, !15, i64 208, !15, i64 216, !15, i64 224, !15, i64 232, !15, i64 240, !15, i64 248, !15, i64 256, !15, i64 264, !15, i64 272}
!13 = !{!"float", !7, i64 0}
!14 = !{!"workspacedef", !6, i64 0, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !6, i64 56}
!15 = !{!"double", !7, i64 0}
!16 = !{!12, !15, i64 160}
!17 = !{!18, !10, i64 0}
!18 = !{!"graphdef", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !19, i64 56, !19, i64 60, !19, i64 64, !19, i64 68, !19, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !10, i64 120, !6, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !10, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240}
!19 = !{!"int", !7, i64 0}
!20 = !{!18, !6, i64 128}
!21 = !{!18, !6, i64 104}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!18, !10, i64 112}


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

@.str = external hidden unnamed_addr constant [22 x i8], align 1

declare double @gk_CPUSeconds() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @MCMlevelKWayRefinement(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr nocapture noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = tail call ptr @libmetis__MCCoarsen2Way(ptr noundef %0, ptr noundef %1) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = and i64 %8, 1
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %15, label %10

10:                                               ; preds = %5
  %11 = tail call double @gk_CPUSeconds() #3
  %12 = getelementptr inbounds i8, ptr %0, i64 160
  %13 = load double, ptr %12, align 8, !tbaa !14
  %14 = fsub double %13, %11
  store double %14, ptr %12, align 8, !tbaa !14
  br label %15

15:                                               ; preds = %10, %5
  tail call void @libmetis__MocAllocateKWayPartitionMemory(ptr noundef nonnull %0, ptr noundef %6, i64 noundef %2) #3
  %16 = load i64, ptr %6, align 8, !tbaa !15
  %17 = load i64, ptr %1, align 8, !tbaa !15
  %.not30 = icmp eq i64 %16, %17
  br i1 %.not30, label %19, label %18

18:                                               ; preds = %15
  tail call void (ptr, ...) @errexit(ptr noundef nonnull @.str, i64 noundef %16, i64 noundef %17) #3
  %.pre = load i64, ptr %1, align 8, !tbaa !15
  br label %19

19:                                               ; preds = %18, %15
  %20 = phi i64 [ %.pre, %18 ], [ %16, %15 ]
  %21 = icmp sgt i64 %20, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %19
  %22 = getelementptr inbounds i8, ptr %6, i64 128
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %1, i64 104
  %25 = load ptr, ptr %24, align 8, !tbaa !19
  br label %26

26:                                               ; preds = %.lr.ph, %26
  %.031 = phi i64 [ 0, %.lr.ph ], [ %32, %26 ]
  %27 = getelementptr inbounds i64, ptr %3, i64 %.031
  %28 = load i64, ptr %27, align 8, !tbaa !20
  %29 = getelementptr inbounds i64, ptr %25, i64 %.031
  %30 = load i64, ptr %29, align 8, !tbaa !20
  %31 = getelementptr inbounds i64, ptr %23, i64 %30
  store i64 %28, ptr %31, align 8, !tbaa !20
  %32 = add nuw nsw i64 %.031, 1
  %33 = load i64, ptr %1, align 8, !tbaa !15
  %34 = icmp slt i64 %32, %33
  br i1 %34, label %26, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %26, %19
  tail call void @libmetis__MocRefineKWayHorizontal(ptr noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %6, i64 noundef %2, ptr noundef %4) #3
  %35 = getelementptr inbounds i8, ptr %1, i64 128
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = load i64, ptr %1, align 8, !tbaa !15
  %38 = shl i64 %37, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr align 1 %36, i64 %38, i1 false)
  tail call void @libmetis__FreeGraph(ptr noundef nonnull %1, i32 noundef 0) #3
  %39 = getelementptr inbounds i8, ptr %1, i64 112
  %40 = load i64, ptr %39, align 8, !tbaa !23
  ret i64 %40
}

declare ptr @libmetis__MCCoarsen2Way(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @libmetis__MocAllocateKWayPartitionMemory(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare void @errexit(ptr noundef, ...) local_unnamed_addr #0

declare void @libmetis__MocRefineKWayHorizontal(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @libmetis__FreeGraph(ptr noundef, i32 noundef) local_unnamed_addr #0

attributes #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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 8}
!6 = !{!"controldef", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !11, i64 88, !13, i64 152, !13, i64 160, !13, i64 168, !13, i64 176, !13, i64 184, !13, i64 192, !13, i64 200, !13, i64 208, !13, i64 216, !13, i64 224, !13, i64 232, !13, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !13, i64 272}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"workspacedef", !12, i64 0, !7, i64 8, !7, i64 16, !12, i64 24, !12, i64 32, !7, i64 40, !12, i64 48, !12, i64 56}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!6, !13, i64 160}
!15 = !{!16, !7, i64 0}
!16 = !{!"graphdef", !7, i64 0, !7, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !17, i64 56, !17, i64 60, !17, i64 64, !17, i64 68, !17, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !7, i64 112, !7, i64 120, !12, i64 128, !12, i64 136, !7, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !7, i64 208, !12, i64 216, !12, i64 224, !12, i64 232, !12, i64 240}
!17 = !{!"int", !8, i64 0}
!18 = !{!16, !12, i64 128}
!19 = !{!16, !12, i64 104}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!16, !7, i64 112}


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