; LLVM IR from ekoontz/graphlab :: src/graphlab/extern/metis/libmetis/separator.ll_libmetis (ConstructSeparator)

; 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.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 }

; Function Attrs: nounwind uwtable
define dso_local void @libmetis__ConstructSeparator(ptr noundef %0, ptr noundef %1, float noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  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
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.graphdef, ptr %15, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !11
  store i64 %17, ptr %10, align 8, !tbaa !15
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.graphdef, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  store ptr %20, ptr %12, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.graphdef, ptr %21, i32 0, i32 20
  %23 = load i64, ptr %22, align 8, !tbaa !17
  store i64 %23, ptr %11, align 8, !tbaa !15
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.graphdef, ptr %24, i32 0, i32 22
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  store ptr %26, ptr %14, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i64, ptr %10, align 8, !tbaa !15
  %29 = call ptr @libmetis__idxwspacemalloc(ptr noundef %27, i64 noundef %28)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.graphdef, ptr %30, i32 0, i32 18
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  %33 = load i64, ptr %10, align 8, !tbaa !15
  %34 = mul i64 8, %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %29, ptr align 1 %32, i64 %34, i1 false)
  store ptr %29, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %7, align 8, !tbaa !15
  br label %35

35:                                               ; preds = %60, %3
  %36 = load i64, ptr %7, align 8, !tbaa !15
  %37 = load i64, ptr %11, align 8, !tbaa !15
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %39, label %63

39:                                               ; preds = %35
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = load i64, ptr %7, align 8, !tbaa !15
  %42 = getelementptr inbounds i64, ptr %40, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !15
  store i64 %43, ptr %8, align 8, !tbaa !15
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = load i64, ptr %8, align 8, !tbaa !15
  %46 = add nsw i64 %45, 1
  %47 = getelementptr inbounds i64, ptr %44, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = load i64, ptr %8, align 8, !tbaa !15
  %51 = getelementptr inbounds i64, ptr %49, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !15
  %53 = sub nsw i64 %48, %52
  %54 = icmp sgt i64 %53, 0
  br i1 %54, label %55, label %59

55:                                               ; preds = %39
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = load i64, ptr %8, align 8, !tbaa !15
  %58 = getelementptr inbounds i64, ptr %56, i64 %57
  store i64 2, ptr %58, align 8, !tbaa !15
  br label %59

59:                                               ; preds = %55, %39
  br label %60

60:                                               ; preds = %59
  %61 = load i64, ptr %7, align 8, !tbaa !15
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %7, align 8, !tbaa !15
  br label %35, !llvm.loop !20

63:                                               ; preds = %35
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  call void @libmetis__FreeRData(ptr noundef %64)
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  call void @libmetis__Allocate2WayNodePartitionMemory(ptr noundef %65, ptr noundef %66)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.graphdef, ptr %67, i32 0, i32 18
  %69 = load ptr, ptr %68, align 8, !tbaa !19
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = load i64, ptr %10, align 8, !tbaa !15
  %72 = mul i64 8, %71
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %69, ptr align 1 %70, i64 %72, i1 false)
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load i64, ptr %10, align 8, !tbaa !15
  call void @libmetis__idxwspacefree(ptr noundef %73, i64 noundef %74)
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  call void @libmetis__Compute2WayNodePartitionParams(ptr noundef %75, ptr noundef %76)
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = load float, ptr %6, align 4, !tbaa !9
  call void @libmetis__FM_2WayNodeRefine(ptr noundef %77, ptr noundef %78, float noundef %79, i64 noundef 8)
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

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

declare ptr @libmetis__idxwspacemalloc(ptr noundef, i64 noundef) #2

; 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__FreeRData(ptr noundef) #2

declare void @libmetis__Allocate2WayNodePartitionMemory(ptr noundef, ptr noundef) #2

declare void @libmetis__idxwspacefree(ptr noundef, i64 noundef) #2

declare void @libmetis__Compute2WayNodePartitionParams(ptr noundef, ptr noundef) #2

declare void @libmetis__FM_2WayNodeRefine(ptr noundef, ptr noundef, float noundef, i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"graphdef", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !14, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !13, i64 112, !13, i64 120, !6, i64 128, !6, i64 136, !13, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !13, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !13, i64 144}
!18 = !{!12, !6, i64 160}
!19 = !{!12, !6, i64 128}
!20 = distinct !{!20, !21}
!21 = !{!"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
define dso_local void @libmetis__ConstructSeparator(ptr noundef %0, ptr noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %1, i64 144
  %8 = load i64, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %1, i64 160
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = tail call ptr @libmetis__idxwspacemalloc(ptr noundef %0, i64 noundef %4) #3
  %12 = getelementptr inbounds i8, ptr %1, i64 128
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = shl i64 %4, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %11, ptr align 1 %13, i64 %14, i1 false)
  %15 = icmp sgt i64 %8, 0
  br i1 %15, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %xtraiter = and i64 %8, 1
  %16 = icmp eq i64 %8, 1
  br i1 %16, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %8, 9223372036854775806
  br label %.lr.ph

.lr.ph:                                           ; preds = %36, %.lr.ph.preheader.new
  %.031 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %37, %36 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %36 ]
  %17 = getelementptr inbounds i64, ptr %10, i64 %.031
  %18 = load i64, ptr %17, align 8, !tbaa !16
  %19 = getelementptr i64, ptr %6, i64 %18
  %20 = getelementptr i8, ptr %19, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = load i64, ptr %19, align 8, !tbaa !16
  %23 = icmp sgt i64 %21, %22
  br i1 %23, label %24, label %.lr.ph.1

24:                                               ; preds = %.lr.ph
  %25 = getelementptr inbounds i64, ptr %11, i64 %18
  store i64 2, ptr %25, align 8, !tbaa !16
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.lr.ph, %24
  %26 = or disjoint i64 %.031, 1
  %27 = getelementptr inbounds i64, ptr %10, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !16
  %29 = getelementptr i64, ptr %6, i64 %28
  %30 = getelementptr i8, ptr %29, i64 8
  %31 = load i64, ptr %30, align 8, !tbaa !16
  %32 = load i64, ptr %29, align 8, !tbaa !16
  %33 = icmp sgt i64 %31, %32
  br i1 %33, label %34, label %36

34:                                               ; preds = %.lr.ph.1
  %35 = getelementptr inbounds i64, ptr %11, i64 %28
  store i64 2, ptr %35, align 8, !tbaa !16
  br label %36

36:                                               ; preds = %34, %.lr.ph.1
  %37 = add nuw nsw i64 %.031, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !17

._crit_edge.loopexit.unr-lcssa:                   ; preds = %36, %.lr.ph.preheader
  %.031.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %37, %36 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %38 = getelementptr inbounds i64, ptr %10, i64 %.031.unr
  %39 = load i64, ptr %38, align 8, !tbaa !16
  %40 = getelementptr i64, ptr %6, i64 %39
  %41 = getelementptr i8, ptr %40, i64 8
  %42 = load i64, ptr %41, align 8, !tbaa !16
  %43 = load i64, ptr %40, align 8, !tbaa !16
  %44 = icmp sgt i64 %42, %43
  br i1 %44, label %45, label %._crit_edge

45:                                               ; preds = %.lr.ph.epil
  %46 = getelementptr inbounds i64, ptr %11, i64 %39
  store i64 2, ptr %46, align 8, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %45, %.lr.ph.epil, %3
  tail call void @libmetis__FreeRData(ptr noundef nonnull %1) #3
  tail call void @libmetis__Allocate2WayNodePartitionMemory(ptr noundef %0, ptr noundef nonnull %1) #3
  %47 = load ptr, ptr %12, align 8, !tbaa !15
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %47, ptr align 1 %11, i64 %14, i1 false)
  tail call void @libmetis__idxwspacefree(ptr noundef %0, i64 noundef %4) #3
  tail call void @libmetis__Compute2WayNodePartitionParams(ptr noundef %0, ptr noundef nonnull %1) #3
  tail call void @libmetis__FM_2WayNodeRefine(ptr noundef %0, ptr noundef nonnull %1, float noundef %2, i64 noundef 8) #3
  ret void
}

declare ptr @libmetis__idxwspacemalloc(ptr noundef, i64 noundef) local_unnamed_addr #1

; 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__FreeRData(ptr noundef) local_unnamed_addr #1

declare void @libmetis__Allocate2WayNodePartitionMemory(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @libmetis__idxwspacefree(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @libmetis__Compute2WayNodePartitionParams(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @libmetis__FM_2WayNodeRefine(ptr noundef, ptr noundef, float noundef, i64 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 = { 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 0}
!6 = !{!"graphdef", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !7, i64 112, !7, i64 120, !10, i64 128, !10, i64 136, !7, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !7, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !7, i64 144}
!14 = !{!6, !10, i64 160}
!15 = !{!6, !10, i64 128}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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