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

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

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 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

; Function Attrs: nounwind uwtable
define dso_local void @libmetis__EstimateCFraction(i64 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, 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 i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  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 ptr %3, ptr %9, align 8, !tbaa !9
  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
  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 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %20 = load i64, ptr %6, align 8, !tbaa !5
  %21 = call ptr @libmetis__idxmalloc(i64 noundef %20, ptr noundef @.str)
  store ptr %21, ptr %18, align 8, !tbaa !9
  %22 = load i64, ptr %6, align 8, !tbaa !5
  %23 = call ptr @libmetis__idxsmalloc(i64 noundef %22, i64 noundef -1, ptr noundef @.str.1)
  store ptr %23, ptr %17, align 8, !tbaa !9
  %24 = load i64, ptr %6, align 8, !tbaa !5
  %25 = call ptr @libmetis__idxmalloc(i64 noundef %24, ptr noundef @.str.2)
  store ptr %25, ptr %19, align 8, !tbaa !9
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %19, align 8, !tbaa !9
  call void @libmetis__RandomPermute(i64 noundef %26, ptr noundef %27, i64 noundef 1)
  store i64 0, ptr %14, align 8, !tbaa !5
  store i64 0, ptr %12, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %92, %5
  %29 = load i64, ptr %12, align 8, !tbaa !5
  %30 = load i64, ptr %6, align 8, !tbaa !5
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %32, label %95

32:                                               ; preds = %28
  %33 = load ptr, ptr %19, align 8, !tbaa !9
  %34 = load i64, ptr %12, align 8, !tbaa !5
  %35 = getelementptr inbounds i64, ptr %33, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  store i64 %36, ptr %11, align 8, !tbaa !5
  %37 = load ptr, ptr %17, align 8, !tbaa !9
  %38 = load i64, ptr %11, align 8, !tbaa !5
  %39 = getelementptr inbounds i64, ptr %37, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = icmp eq i64 %40, -1
  br i1 %41, label %42, label %91

42:                                               ; preds = %32
  %43 = load i64, ptr %11, align 8, !tbaa !5
  store i64 %43, ptr %16, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  %45 = load i64, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds i64, ptr %44, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !5
  store i64 %47, ptr %13, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %71, %42
  %49 = load i64, ptr %13, align 8, !tbaa !5
  %50 = load ptr, ptr %7, align 8, !tbaa !9
  %51 = load i64, ptr %11, align 8, !tbaa !5
  %52 = add nsw i64 %51, 1
  %53 = getelementptr inbounds i64, ptr %50, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !5
  %55 = icmp slt i64 %49, %54
  br i1 %55, label %56, label %74

56:                                               ; preds = %48
  %57 = load ptr, ptr %17, align 8, !tbaa !9
  %58 = load ptr, ptr %8, align 8, !tbaa !9
  %59 = load i64, ptr %13, align 8, !tbaa !5
  %60 = getelementptr inbounds i64, ptr %58, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds i64, ptr %57, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !5
  %64 = icmp eq i64 %63, -1
  br i1 %64, label %65, label %70

65:                                               ; preds = %56
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = load i64, ptr %13, align 8, !tbaa !5
  %68 = getelementptr inbounds i64, ptr %66, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !5
  store i64 %69, ptr %16, align 8, !tbaa !5
  br label %74

70:                                               ; preds = %56
  br label %71

71:                                               ; preds = %70
  %72 = load i64, ptr %13, align 8, !tbaa !5
  %73 = add nsw i64 %72, 1
  store i64 %73, ptr %13, align 8, !tbaa !5
  br label %48, !llvm.loop !11

74:                                               ; preds = %65, %48
  %75 = load i64, ptr %14, align 8, !tbaa !5
  %76 = add nsw i64 %75, 1
  store i64 %76, ptr %14, align 8, !tbaa !5
  %77 = load ptr, ptr %18, align 8, !tbaa !9
  %78 = load i64, ptr %16, align 8, !tbaa !5
  %79 = getelementptr inbounds i64, ptr %77, i64 %78
  store i64 %75, ptr %79, align 8, !tbaa !5
  %80 = load ptr, ptr %18, align 8, !tbaa !9
  %81 = load i64, ptr %11, align 8, !tbaa !5
  %82 = getelementptr inbounds i64, ptr %80, i64 %81
  store i64 %75, ptr %82, align 8, !tbaa !5
  %83 = load i64, ptr %16, align 8, !tbaa !5
  %84 = load ptr, ptr %17, align 8, !tbaa !9
  %85 = load i64, ptr %11, align 8, !tbaa !5
  %86 = getelementptr inbounds i64, ptr %84, i64 %85
  store i64 %83, ptr %86, align 8, !tbaa !5
  %87 = load i64, ptr %11, align 8, !tbaa !5
  %88 = load ptr, ptr %17, align 8, !tbaa !9
  %89 = load i64, ptr %16, align 8, !tbaa !5
  %90 = getelementptr inbounds i64, ptr %88, i64 %89
  store i64 %87, ptr %90, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %74, %32
  br label %92

92:                                               ; preds = %91
  %93 = load i64, ptr %12, align 8, !tbaa !5
  %94 = add nsw i64 %93, 1
  store i64 %94, ptr %12, align 8, !tbaa !5
  br label %28, !llvm.loop !13

95:                                               ; preds = %28
  %96 = load i64, ptr %6, align 8, !tbaa !5
  %97 = load ptr, ptr %7, align 8, !tbaa !9
  %98 = load ptr, ptr %8, align 8, !tbaa !9
  %99 = load i64, ptr %14, align 8, !tbaa !5
  %100 = load ptr, ptr %18, align 8, !tbaa !9
  %101 = load ptr, ptr %17, align 8, !tbaa !9
  %102 = load ptr, ptr %19, align 8, !tbaa !9
  %103 = call i64 @libmetis__ComputeCoarseGraphSize(i64 noundef %96, ptr noundef %97, ptr noundef %98, i64 noundef %99, ptr noundef %100, ptr noundef %101, ptr noundef %102)
  store i64 %103, ptr %15, align 8, !tbaa !5
  %104 = load i64, ptr %14, align 8, !tbaa !5
  %105 = sitofp i64 %104 to double
  %106 = fmul double 1.000000e+00, %105
  %107 = load i64, ptr %6, align 8, !tbaa !5
  %108 = sitofp i64 %107 to double
  %109 = fmul double 1.000000e+00, %108
  %110 = fdiv double %106, %109
  %111 = fptrunc double %110 to float
  %112 = load ptr, ptr %9, align 8, !tbaa !9
  store float %111, ptr %112, align 4, !tbaa !14
  %113 = load i64, ptr %15, align 8, !tbaa !5
  %114 = sitofp i64 %113 to double
  %115 = fmul double 1.000000e+00, %114
  %116 = load ptr, ptr %7, align 8, !tbaa !9
  %117 = load i64, ptr %6, align 8, !tbaa !5
  %118 = getelementptr inbounds i64, ptr %116, i64 %117
  %119 = load i64, ptr %118, align 8, !tbaa !5
  %120 = sitofp i64 %119 to double
  %121 = fmul double 1.000000e+00, %120
  %122 = fdiv double %115, %121
  %123 = fptrunc double %122 to float
  %124 = load ptr, ptr %10, align 8, !tbaa !9
  store float %123, ptr %124, align 4, !tbaa !14
  call void (ptr, ...) @gk_free(ptr noundef %18, ptr noundef %17, ptr noundef %19, ptr noundef null)
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, 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
  ret void
}

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

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

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

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

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

declare void @gk_free(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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}


; 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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 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

; Function Attrs: nounwind uwtable
define dso_local void @libmetis__EstimateCFraction(i64 noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  %9 = tail call ptr @libmetis__idxmalloc(i64 noundef %0, ptr noundef nonnull @.str) #3
  store ptr %9, ptr %7, align 8, !tbaa !5
  %10 = tail call ptr @libmetis__idxsmalloc(i64 noundef %0, i64 noundef -1, ptr noundef nonnull @.str.1) #3
  store ptr %10, ptr %6, align 8, !tbaa !5
  %11 = tail call ptr @libmetis__idxmalloc(i64 noundef %0, ptr noundef nonnull @.str.2) #3
  store ptr %11, ptr %8, align 8, !tbaa !5
  tail call void @libmetis__RandomPermute(i64 noundef %0, ptr noundef %11, i64 noundef 1) #3
  %12 = icmp sgt i64 %0, 0
  br i1 %12, label %.lr.ph47, label %._crit_edge48

.lr.ph47:                                         ; preds = %5, %35
  %.03745 = phi i64 [ %36, %35 ], [ 0, %5 ]
  %.03844 = phi i64 [ %.1, %35 ], [ 0, %5 ]
  %13 = getelementptr inbounds i64, ptr %11, i64 %.03745
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds i64, ptr %10, i64 %14
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i64 %16, -1
  br i1 %17, label %18, label %35

18:                                               ; preds = %.lr.ph47
  %19 = getelementptr inbounds i64, ptr %1, i64 %14
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = getelementptr i8, ptr %19, i64 8
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = icmp slt i64 %20, %22
  br i1 %23, label %.lr.ph, label %._crit_edge

24:                                               ; preds = %.lr.ph
  %25 = add i64 %.03941, 1
  %exitcond.not = icmp eq i64 %25, %22
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

.lr.ph:                                           ; preds = %18, %24
  %.03941 = phi i64 [ %25, %24 ], [ %20, %18 ]
  %26 = getelementptr inbounds i64, ptr %2, i64 %.03941
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds i64, ptr %10, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = icmp eq i64 %29, -1
  br i1 %30, label %._crit_edge, label %24

._crit_edge:                                      ; preds = %24, %.lr.ph, %18
  %.0 = phi i64 [ %14, %18 ], [ %27, %.lr.ph ], [ %14, %24 ]
  %31 = add nsw i64 %.03844, 1
  %32 = getelementptr inbounds i64, ptr %9, i64 %.0
  store i64 %.03844, ptr %32, align 8, !tbaa !9
  %33 = getelementptr inbounds i64, ptr %9, i64 %14
  store i64 %.03844, ptr %33, align 8, !tbaa !9
  store i64 %.0, ptr %15, align 8, !tbaa !9
  %34 = getelementptr inbounds i64, ptr %10, i64 %.0
  store i64 %14, ptr %34, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %.lr.ph47, %._crit_edge
  %.1 = phi i64 [ %31, %._crit_edge ], [ %.03844, %.lr.ph47 ]
  %36 = add nuw nsw i64 %.03745, 1
  %exitcond50.not = icmp eq i64 %36, %0
  br i1 %exitcond50.not, label %._crit_edge48, label %.lr.ph47, !llvm.loop !13

._crit_edge48:                                    ; preds = %35, %5
  %.038.lcssa = phi i64 [ 0, %5 ], [ %.1, %35 ]
  %37 = tail call i64 @libmetis__ComputeCoarseGraphSize(i64 noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %.038.lcssa, ptr noundef %9, ptr noundef %10, ptr noundef %11)
  %38 = sitofp i64 %.038.lcssa to double
  %39 = sitofp i64 %0 to double
  %40 = fdiv double %38, %39
  %41 = fptrunc double %40 to float
  store float %41, ptr %3, align 4, !tbaa !14
  %42 = sitofp i64 %37 to double
  %43 = getelementptr inbounds i64, ptr %1, i64 %0
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = sitofp i64 %44 to double
  %46 = fdiv double %42, %45
  %47 = fptrunc double %46 to float
  store float %47, ptr %4, align 4, !tbaa !14
  call void (ptr, ...) @gk_free(ptr noundef nonnull %7, ptr noundef nonnull %6, ptr noundef nonnull %8, ptr noundef null) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret void
}

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

declare ptr @libmetis__idxmalloc(i64 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @libmetis__idxsmalloc(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare void @libmetis__RandomPermute(i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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

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

attributes #0 = { mustprogress 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}


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