; LLVM IR from GGiecold-zz/Cluster_Ensembles :: src/Cluster_Ensembles/Hypergraph_Partitioning/metis-5.1.0/libmetis (parmetis)

; 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.graph_t = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, i32, i32, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

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

declare ptr @libmetis__SetupCtrl(i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #1

declare ptr @libmetis__SetupGraph(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare void @libmetis__AllocateWorkSpace(ptr noundef, ptr noundef) #1

declare void @libmetis__FreeCtrl(ptr noundef) #1

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

declare void @libmetis__FreeGraph(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @METIS_NodeRefine(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, float noundef %6) #2 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca float, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  store i32 %0, ptr %9, align 4, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !9
  store float %6, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %19 = call ptr @libmetis__SetupCtrl(i32 noundef 2, ptr noundef null, i32 noundef 1, i32 noundef 3, ptr noundef null, ptr noundef null)
  store ptr %19, ptr %17, align 8, !tbaa !9
  %20 = load ptr, ptr %17, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %7
  store i32 -2, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %54

23:                                               ; preds = %7
  %24 = load ptr, ptr %17, align 8, !tbaa !9
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = load ptr, ptr %10, align 8, !tbaa !9
  %27 = load ptr, ptr %12, align 8, !tbaa !9
  %28 = load ptr, ptr %11, align 8, !tbaa !9
  %29 = call ptr @libmetis__SetupGraph(ptr noundef %24, i32 noundef %25, i32 noundef 1, ptr noundef %26, ptr noundef %27, ptr noundef %28, ptr noundef null, ptr noundef null)
  store ptr %29, ptr %16, align 8, !tbaa !9
  %30 = load ptr, ptr %17, align 8, !tbaa !9
  %31 = load ptr, ptr %16, align 8, !tbaa !9
  call void @libmetis__AllocateWorkSpace(ptr noundef %30, ptr noundef %31)
  %32 = load ptr, ptr %17, align 8, !tbaa !9
  %33 = load ptr, ptr %16, align 8, !tbaa !9
  call void @libmetis__Allocate2WayNodePartitionMemory(ptr noundef %32, ptr noundef %33)
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = load ptr, ptr %13, align 8, !tbaa !9
  %37 = load ptr, ptr %16, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.graph_t, ptr %37, i32 0, i32 19
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = call ptr @libmetis__icopy(i64 noundef %35, ptr noundef %36, ptr noundef %39)
  %41 = load ptr, ptr %17, align 8, !tbaa !9
  %42 = load ptr, ptr %16, align 8, !tbaa !9
  call void @libmetis__Compute2WayNodePartitionParams(ptr noundef %41, ptr noundef %42)
  %43 = load ptr, ptr %17, align 8, !tbaa !9
  %44 = load ptr, ptr %16, align 8, !tbaa !9
  %45 = load ptr, ptr %14, align 8, !tbaa !9
  %46 = load float, ptr %15, align 4, !tbaa !11
  call void @libmetis__FM_2WayNodeRefine1SidedP(ptr noundef %43, ptr noundef %44, ptr noundef %45, float noundef %46, i32 noundef 10)
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = load ptr, ptr %16, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.graph_t, ptr %49, i32 0, i32 19
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = load ptr, ptr %13, align 8, !tbaa !9
  %53 = call ptr @libmetis__icopy(i64 noundef %48, ptr noundef %51, ptr noundef %52)
  call void @libmetis__FreeGraph(ptr noundef %16)
  call void @libmetis__FreeCtrl(ptr noundef %17)
  store i32 1, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %54

54:                                               ; preds = %23, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %55 = load i32, ptr %8, align 4
  ret i32 %55
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @libmetis__FM_2WayNodeRefine1SidedP(ptr noundef, ptr noundef, ptr noundef, float noundef, i32 noundef) #2

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 = !{!"int", !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 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 120}
!14 = !{!"graph_t", !6, i64 0, !6, i64 4, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !6, i64 116, !10, i64 120, !10, i64 128, !6, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @libmetis__SetupCtrl(i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @libmetis__SetupGraph(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare void @libmetis__FreeCtrl(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

declare void @libmetis__FreeGraph(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -2, 2) i32 @METIS_NodeRefine(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, float noundef %6) local_unnamed_addr #2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #3
  %10 = tail call ptr @libmetis__SetupCtrl(i32 noundef 2, ptr noundef null, i32 noundef 1, i32 noundef 3, ptr noundef null, ptr noundef null) #3
  store ptr %10, ptr %9, align 8, !tbaa !5
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %19, label %11

11:                                               ; preds = %7
  %12 = tail call ptr @libmetis__SetupGraph(ptr noundef nonnull %10, i32 noundef %0, i32 noundef 1, ptr noundef %1, ptr noundef %3, ptr noundef %2, ptr noundef null, ptr noundef null) #3
  store ptr %12, ptr %8, align 8, !tbaa !5
  tail call void @libmetis__AllocateWorkSpace(ptr noundef nonnull %10, ptr noundef %12) #3
  tail call void @libmetis__Allocate2WayNodePartitionMemory(ptr noundef nonnull %10, ptr noundef %12) #3
  %13 = sext i32 %0 to i64
  %14 = getelementptr inbounds i8, ptr %12, i64 120
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = tail call ptr @libmetis__icopy(i64 noundef %13, ptr noundef %4, ptr noundef %15) #3
  tail call void @libmetis__Compute2WayNodePartitionParams(ptr noundef nonnull %10, ptr noundef %12) #3
  tail call void @libmetis__FM_2WayNodeRefine1SidedP(ptr noundef nonnull %10, ptr noundef %12, ptr noundef %5, float noundef %6, i32 noundef 10)
  %17 = load ptr, ptr %14, align 8, !tbaa !9
  %18 = tail call ptr @libmetis__icopy(i64 noundef %13, ptr noundef %17, ptr noundef %4) #3
  call void @libmetis__FreeGraph(ptr noundef nonnull %8) #3
  call void @libmetis__FreeCtrl(ptr noundef nonnull %9) #3
  br label %19

19:                                               ; preds = %7, %11
  %.0 = phi i32 [ 1, %11 ], [ -2, %7 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  ret i32 %.0
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @libmetis__FM_2WayNodeRefine1SidedP(ptr noundef, ptr noundef, ptr noundef, float noundef, i32 noundef) local_unnamed_addr #2

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 120}
!10 = !{!"graph_t", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !11, i64 116, !6, i64 120, !6, i64 128, !11, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208}
!11 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass