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

; 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.8 = 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 ptr @libmetis__idxsmalloc(i64 noundef, i64 noundef, ptr noundef) #1

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

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

29:                                               ; preds = %2
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.graphdef, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  br label %37

33:                                               ; preds = %2
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.graphdef, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  br label %37

37:                                               ; preds = %33, %29
  %38 = phi ptr [ %32, %29 ], [ %36, %33 ]
  store ptr %38, ptr %14, align 8, !tbaa !5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = load i64, ptr %9, align 8, !tbaa !13
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call i64 @libmetis__idxargmax(i64 noundef %40, ptr noundef %41)
  %43 = getelementptr inbounds i64, ptr %39, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !13
  %45 = add nsw i64 %44, 1
  store i64 %45, ptr %10, align 8, !tbaa !13
  %46 = load i64, ptr %10, align 8, !tbaa !13
  %47 = call ptr @libmetis__idxsmalloc(i64 noundef %46, i64 noundef -1, ptr noundef @.str.8)
  store ptr %47, ptr %15, align 8, !tbaa !5
  store i64 0, ptr %11, align 8, !tbaa !13
  store i64 0, ptr %5, align 8, !tbaa !13
  br label %48

48:                                               ; preds = %102, %37
  %49 = load i64, ptr %5, align 8, !tbaa !13
  %50 = load i64, ptr %9, align 8, !tbaa !13
  %51 = icmp slt i64 %49, %50
  br i1 %51, label %52, label %105

52:                                               ; preds = %48
  %53 = load i64, ptr %5, align 8, !tbaa !13
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i64, ptr %5, align 8, !tbaa !13
  %57 = getelementptr inbounds i64, ptr %55, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !13
  %59 = getelementptr inbounds i64, ptr %54, i64 %58
  store i64 %53, ptr %59, align 8, !tbaa !13
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = load i64, ptr %5, align 8, !tbaa !13
  %62 = getelementptr inbounds i64, ptr %60, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !13
  store i64 %63, ptr %6, align 8, !tbaa !13
  br label %64

64:                                               ; preds = %98, %52
  %65 = load i64, ptr %6, align 8, !tbaa !13
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load i64, ptr %5, align 8, !tbaa !13
  %68 = add nsw i64 %67, 1
  %69 = getelementptr inbounds i64, ptr %66, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !13
  %71 = icmp slt i64 %65, %70
  br i1 %71, label %72, label %101

72:                                               ; preds = %64
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = load i64, ptr %6, align 8, !tbaa !13
  %76 = getelementptr inbounds i64, ptr %74, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !13
  %78 = getelementptr inbounds i64, ptr %73, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !13
  store i64 %79, ptr %7, align 8, !tbaa !13
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  %81 = load i64, ptr %7, align 8, !tbaa !13
  %82 = getelementptr inbounds i64, ptr %80, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !13
  %84 = load i64, ptr %5, align 8, !tbaa !13
  %85 = icmp ne i64 %83, %84
  br i1 %85, label %86, label %97

86:                                               ; preds = %72
  %87 = load i64, ptr %5, align 8, !tbaa !13
  %88 = load ptr, ptr %15, align 8, !tbaa !5
  %89 = load i64, ptr %7, align 8, !tbaa !13
  %90 = getelementptr inbounds i64, ptr %88, i64 %89
  store i64 %87, ptr %90, align 8, !tbaa !13
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = load i64, ptr %5, align 8, !tbaa !13
  %93 = getelementptr inbounds i64, ptr %91, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !13
  %95 = load i64, ptr %11, align 8, !tbaa !13
  %96 = add nsw i64 %95, %94
  store i64 %96, ptr %11, align 8, !tbaa !13
  br label %97

97:                                               ; preds = %86, %72
  br label %98

98:                                               ; preds = %97
  %99 = load i64, ptr %6, align 8, !tbaa !13
  %100 = add nsw i64 %99, 1
  store i64 %100, ptr %6, align 8, !tbaa !13
  br label %64, !llvm.loop !18

101:                                              ; preds = %64
  br label %102

102:                                              ; preds = %101
  %103 = load i64, ptr %5, align 8, !tbaa !13
  %104 = add nsw i64 %103, 1
  store i64 %104, ptr %5, align 8, !tbaa !13
  br label %48, !llvm.loop !20

105:                                              ; preds = %48
  call void (ptr, ...) @gk_free(ptr noundef %15, ptr noundef null)
  %106 = load i64, ptr %11, align 8, !tbaa !13
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i64 %106
}

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, !11, i64 0}
!10 = !{!"graphdef", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !11, i64 120, !6, i64 128, !6, i64 136, !11, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !11, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !6, i64 24}
!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.8 = external hidden unnamed_addr constant [22 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 ptr @libmetis__idxsmalloc(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

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

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 i64 @libmetis__ComputeVolume(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %15

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  br label %15

15:                                               ; preds = %2, %12
  %16 = phi ptr [ %14, %12 ], [ %10, %2 ]
  %17 = tail call i64 @libmetis__idxargmax(i64 noundef %4, ptr noundef %1) #3
  %18 = getelementptr inbounds i64, ptr %1, i64 %17
  %19 = load i64, ptr %18, align 8, !tbaa !16
  %20 = add nsw i64 %19, 1
  %21 = tail call ptr @libmetis__idxsmalloc(i64 noundef %20, i64 noundef -1, ptr noundef nonnull @.str.8) #3
  store ptr %21, ptr %3, align 8, !tbaa !17
  %22 = icmp sgt i64 %4, 0
  br i1 %22, label %.lr.ph40, label %._crit_edge

.loopexit:                                        ; preds = %44, %.lr.ph40
  %.1.lcssa = phi i64 [ %.03338, %.lr.ph40 ], [ %.2, %44 ]
  %exitcond.not = icmp eq i64 %28, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph40, !llvm.loop !18

.lr.ph40:                                         ; preds = %15, %.loopexit
  %.039 = phi i64 [ %28, %.loopexit ], [ 0, %15 ]
  %.03338 = phi i64 [ %.1.lcssa, %.loopexit ], [ 0, %15 ]
  %23 = getelementptr inbounds i64, ptr %1, i64 %.039
  %24 = load i64, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds i64, ptr %21, i64 %24
  store i64 %.039, ptr %25, align 8, !tbaa !16
  %26 = getelementptr inbounds i64, ptr %6, i64 %.039
  %27 = load i64, ptr %26, align 8, !tbaa !16
  %28 = add nuw nsw i64 %.039, 1
  %29 = getelementptr inbounds i64, ptr %6, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !16
  %31 = icmp slt i64 %27, %30
  br i1 %31, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph40
  %32 = getelementptr inbounds i64, ptr %16, i64 %.039
  br label %33

33:                                               ; preds = %.lr.ph, %44
  %34 = phi i64 [ %30, %.lr.ph ], [ %45, %44 ]
  %.03236 = phi i64 [ %27, %.lr.ph ], [ %46, %44 ]
  %.135 = phi i64 [ %.03338, %.lr.ph ], [ %.2, %44 ]
  %35 = getelementptr inbounds i64, ptr %8, i64 %.03236
  %36 = load i64, ptr %35, align 8, !tbaa !16
  %37 = getelementptr inbounds i64, ptr %1, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !16
  %39 = getelementptr inbounds i64, ptr %21, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !16
  %.not = icmp eq i64 %40, %.039
  br i1 %.not, label %44, label %41

41:                                               ; preds = %33
  store i64 %.039, ptr %39, align 8, !tbaa !16
  %42 = load i64, ptr %32, align 8, !tbaa !16
  %43 = add nsw i64 %42, %.135
  %.pre = load i64, ptr %29, align 8, !tbaa !16
  br label %44

44:                                               ; preds = %33, %41
  %45 = phi i64 [ %.pre, %41 ], [ %34, %33 ]
  %.2 = phi i64 [ %43, %41 ], [ %.135, %33 ]
  %46 = add nsw i64 %.03236, 1
  %47 = icmp slt i64 %46, %45
  br i1 %47, label %33, label %.loopexit, !llvm.loop !20

._crit_edge:                                      ; preds = %.loopexit, %15
  %.033.lcssa = phi i64 [ 0, %15 ], [ %.1.lcssa, %.loopexit ]
  call void (ptr, ...) @gk_free(ptr noundef nonnull %3, ptr noundef null) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i64 %.033.lcssa
}

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 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, !10, i64 40}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !10, i64 24}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !10, 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,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass