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

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

@.str.3 = external hidden unnamed_addr constant [29 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 void @gk_free(ptr noundef, ...) #1

; 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 void @Moc_ComputePartitionBalance(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  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) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.graphdef, ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !11
  store i64 %18, ptr %11, align 8, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.graphdef, ptr %19, i32 0, i32 28
  %21 = load i64, ptr %20, align 8, !tbaa !14
  store i64 %21, ptr %12, align 8, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.graphdef, ptr %22, i32 0, i32 29
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  store ptr %24, ptr %14, align 8, !tbaa !5
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = call ptr @gk_fmalloc(i64 noundef %25, ptr noundef @.str.3)
  store ptr %26, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %78, %4
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = load i64, ptr %12, align 8, !tbaa !9
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %31, label %81

31:                                               ; preds = %27
  %32 = load i64, ptr %6, align 8, !tbaa !9
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = call ptr @gk_fset(i64 noundef %32, float noundef 0.000000e+00, ptr noundef %33)
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %58, %31
  %36 = load i64, ptr %9, align 8, !tbaa !9
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.graphdef, ptr %37, i32 0, i32 0
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = icmp slt i64 %36, %39
  br i1 %40, label %41, label %61

41:                                               ; preds = %35
  %42 = load ptr, ptr %14, align 8, !tbaa !5
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = load i64, ptr %12, align 8, !tbaa !9
  %45 = mul nsw i64 %43, %44
  %46 = load i64, ptr %10, align 8, !tbaa !9
  %47 = add nsw i64 %45, %46
  %48 = getelementptr inbounds float, ptr %42, i64 %47
  %49 = load float, ptr %48, align 4, !tbaa !16
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load i64, ptr %9, align 8, !tbaa !9
  %53 = getelementptr inbounds i64, ptr %51, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds float, ptr %50, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !16
  %57 = fadd float %56, %49
  store float %57, ptr %55, align 4, !tbaa !16
  br label %58

58:                                               ; preds = %41
  %59 = load i64, ptr %9, align 8, !tbaa !9
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %9, align 8, !tbaa !9
  br label %35, !llvm.loop !18

61:                                               ; preds = %35
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = sitofp i64 %62 to float
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = load i64, ptr %6, align 8, !tbaa !9
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = call i64 @gk_fargmax(i64 noundef %65, ptr noundef %66)
  %68 = getelementptr inbounds float, ptr %64, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !16
  %70 = fmul float %63, %69
  %71 = load i64, ptr %6, align 8, !tbaa !9
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = call float @gk_fsum(i64 noundef %71, ptr noundef %72, i64 noundef 1)
  %74 = fdiv float %70, %73
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = load i64, ptr %10, align 8, !tbaa !9
  %77 = getelementptr inbounds float, ptr %75, i64 %76
  store float %74, ptr %77, align 4, !tbaa !16
  br label %78

78:                                               ; preds = %61
  %79 = load i64, ptr %10, align 8, !tbaa !9
  %80 = add nsw i64 %79, 1
  store i64 %80, ptr %10, align 8, !tbaa !9
  br label %27, !llvm.loop !20

81:                                               ; preds = %27
  call void (ptr, ...) @gk_free(ptr noundef %13, ptr noundef null)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

declare ptr @gk_fmalloc(i64 noundef, ptr noundef) #1

declare ptr @gk_fset(i64 noundef, float noundef, ptr noundef) #1

declare i64 @gk_fargmax(i64 noundef, ptr noundef) #1

declare float @gk_fsum(i64 noundef, ptr noundef, i64 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 = { 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 0}
!12 = !{!"graphdef", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !13, 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}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 208}
!15 = !{!12, !6, i64 216}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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.3 = external hidden unnamed_addr constant [29 x i8], align 1

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

declare void @gk_free(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress 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 void @Moc_ComputePartitionBalance(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #2 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 208
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 216
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = tail call ptr @gk_fmalloc(i64 noundef %1, ptr noundef nonnull @.str.3) #3
  store ptr %10, ptr %5, align 8, !tbaa !13
  %11 = icmp sgt i64 %7, 0
  br i1 %11, label %.lr.ph26, label %._crit_edge27

.lr.ph26:                                         ; preds = %4
  %12 = sitofp i64 %1 to float
  br label %13

13:                                               ; preds = %.lr.ph26, %._crit_edge
  %.02124 = phi i64 [ 0, %.lr.ph26 ], [ %48, %._crit_edge ]
  %14 = tail call ptr @gk_fset(i64 noundef %1, float noundef 0.000000e+00, ptr noundef %10) #3
  %15 = load i64, ptr %0, align 8, !tbaa !14
  %invariant.gep = getelementptr float, ptr %9, i64 %.02124
  %16 = icmp sgt i64 %15, 0
  br i1 %16, label %.lr.ph.preheader, label %._crit_edge

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

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

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.023 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %33, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %18 = mul nuw nsw i64 %.023, %7
  %gep = getelementptr float, ptr %invariant.gep, i64 %18
  %19 = load float, ptr %gep, align 4, !tbaa !15
  %20 = getelementptr inbounds i64, ptr %2, i64 %.023
  %21 = load i64, ptr %20, align 8, !tbaa !17
  %22 = getelementptr inbounds float, ptr %10, i64 %21
  %23 = load float, ptr %22, align 4, !tbaa !15
  %24 = fadd float %19, %23
  store float %24, ptr %22, align 4, !tbaa !15
  %25 = or disjoint i64 %.023, 1
  %26 = mul nuw nsw i64 %25, %7
  %gep.1 = getelementptr float, ptr %invariant.gep, i64 %26
  %27 = load float, ptr %gep.1, align 4, !tbaa !15
  %28 = getelementptr inbounds i64, ptr %2, i64 %25
  %29 = load i64, ptr %28, align 8, !tbaa !17
  %30 = getelementptr inbounds float, ptr %10, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !15
  %32 = fadd float %27, %31
  store float %32, ptr %30, align 4, !tbaa !15
  %33 = add nuw nsw i64 %.023, 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 !18

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.023.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %33, %.lr.ph ]
  %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
  %34 = mul nuw nsw i64 %.023.unr, %7
  %gep.epil = getelementptr float, ptr %invariant.gep, i64 %34
  %35 = load float, ptr %gep.epil, align 4, !tbaa !15
  %36 = getelementptr inbounds i64, ptr %2, i64 %.023.unr
  %37 = load i64, ptr %36, align 8, !tbaa !17
  %38 = getelementptr inbounds float, ptr %10, i64 %37
  %39 = load float, ptr %38, align 4, !tbaa !15
  %40 = fadd float %35, %39
  store float %40, ptr %38, align 4, !tbaa !15
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %13
  %41 = tail call i64 @gk_fargmax(i64 noundef %1, ptr noundef %10) #3
  %42 = getelementptr inbounds float, ptr %10, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !15
  %44 = fmul float %43, %12
  %45 = tail call float @gk_fsum(i64 noundef %1, ptr noundef %10, i64 noundef 1) #3
  %46 = fdiv float %44, %45
  %47 = getelementptr inbounds float, ptr %3, i64 %.02124
  store float %46, ptr %47, align 4, !tbaa !15
  %48 = add nuw nsw i64 %.02124, 1
  %exitcond28.not = icmp eq i64 %48, %7
  br i1 %exitcond28.not, label %._crit_edge27, label %13, !llvm.loop !20

._crit_edge27:                                    ; preds = %._crit_edge, %4
  call void (ptr, ...) @gk_free(ptr noundef nonnull %5, ptr noundef null) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret void
}

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

declare ptr @gk_fset(i64 noundef, float noundef, ptr noundef) local_unnamed_addr #1

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

declare float @gk_fsum(i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 208}
!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 216}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !8, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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