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

; 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 }
%struct.ctrl_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, float, ptr, ptr, ptr, float, double, double, double, double, double, double, double, double, double, double, double, double, ptr, i64, i64, i64, 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

; 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 @libmetis__MlevelNodeBisectionL1(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.graph_t, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = sdiv i32 %10, 8
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ctrl_t, ptr %12, i32 0, i32 6
  store i32 %11, ptr %13, align 8, !tbaa !13
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ctrl_t, ptr %14, i32 0, i32 6
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = icmp sgt i32 %16, 100
  br i1 %17, label %18, label %21

18:                                               ; preds = %3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ctrl_t, ptr %19, i32 0, i32 6
  store i32 100, ptr %20, align 8, !tbaa !13
  br label %30

21:                                               ; preds = %3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ctrl_t, ptr %22, i32 0, i32 6
  %24 = load i32, ptr %23, align 8, !tbaa !13
  %25 = icmp slt i32 %24, 40
  br i1 %25, label %26, label %29

26:                                               ; preds = %21
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ctrl_t, ptr %27, i32 0, i32 6
  store i32 40, ptr %28, align 8, !tbaa !13
  br label %29

29:                                               ; preds = %26, %21
  br label %30

30:                                               ; preds = %29, %18
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call ptr @libmetis__CoarsenGraph(ptr noundef %31, ptr noundef %32)
  store ptr %33, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.graph_t, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ctrl_t, ptr %37, i32 0, i32 6
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = icmp sle i32 %36, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %30
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = sdiv i32 %42, 2
  br label %46

44:                                               ; preds = %30
  %45 = load i32, ptr %6, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %44, %41
  %47 = phi i32 [ %43, %41 ], [ %45, %44 ]
  %48 = icmp sge i32 1, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %46
  br label %65

50:                                               ; preds = %46
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.graph_t, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !11
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ctrl_t, ptr %54, i32 0, i32 6
  %56 = load i32, ptr %55, align 8, !tbaa !13
  %57 = icmp sle i32 %53, %56
  br i1 %57, label %58, label %61

58:                                               ; preds = %50
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = sdiv i32 %59, 2
  br label %63

61:                                               ; preds = %50
  %62 = load i32, ptr %6, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %61, %58
  %64 = phi i32 [ %60, %58 ], [ %62, %61 ]
  br label %65

65:                                               ; preds = %63, %49
  %66 = phi i32 [ 1, %49 ], [ %64, %63 ]
  store i32 %66, ptr %6, align 4, !tbaa !9
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load i32, ptr %6, align 4, !tbaa !9
  call void @libmetis__InitSeparator(ptr noundef %67, ptr noundef %68, i32 noundef %69)
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  call void @libmetis__Refine2WayNode(ptr noundef %70, ptr noundef %71, ptr noundef %72)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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

declare ptr @libmetis__CoarsenGraph(ptr noundef, ptr noundef) #2

declare void @libmetis__InitSeparator(ptr noundef, ptr noundef, i32 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"graph_t", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !10, i64 116, !6, i64 120, !6, i64 128, !10, 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}
!13 = !{!14, !10, i64 24}
!14 = !{!"ctrl_t", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !15, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !15, i64 128, !16, i64 136, !16, i64 144, !16, i64 152, !16, i64 160, !16, i64 168, !16, i64 176, !16, i64 184, !16, i64 192, !16, i64 200, !16, i64 208, !16, i64 216, !16, i64 224, !6, i64 232, !17, i64 240, !17, i64 248, !17, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320}
!15 = !{!"float", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!"long", !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"

; Function Attrs: nounwind uwtable
define dso_local void @libmetis__MlevelNodeBisectionL1(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %1, align 8, !tbaa !5
  %5 = sdiv i32 %4, 8
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %5, ptr %6, align 8, !tbaa !11
  %7 = icmp sgt i32 %4, 807
  br i1 %7, label %.sink.split, label %8

8:                                                ; preds = %3
  %9 = icmp slt i32 %4, 320
  br i1 %9, label %.sink.split, label %10

.sink.split:                                      ; preds = %8, %3
  %.sink = phi i32 [ 100, %3 ], [ 40, %8 ]
  store i32 %.sink, ptr %6, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %.sink.split, %8
  %11 = tail call ptr @libmetis__CoarsenGraph(ptr noundef nonnull %0, ptr noundef nonnull %1) #3
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %13 = load i32, ptr %6, align 8, !tbaa !11
  %.not = icmp sgt i32 %12, %13
  %14 = sdiv i32 %2, 2
  %15 = select i1 %.not, i32 %2, i32 %14
  %16 = tail call i32 @llvm.smax.i32(i32 %15, i32 1)
  tail call void @libmetis__InitSeparator(ptr noundef nonnull %0, ptr noundef nonnull %11, i32 noundef %16) #3
  tail call void @libmetis__Refine2WayNode(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %11) #3
  ret void
}

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

declare ptr @libmetis__CoarsenGraph(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @libmetis__InitSeparator(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"graph_t", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !10, i64 96, !10, i64 104, !7, i64 112, !7, i64 116, !10, i64 120, !10, i64 128, !7, 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}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !7, i64 24}
!12 = !{!"ctrl_t", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !10, i64 80, !7, i64 88, !7, i64 92, !13, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !13, i64 128, !14, i64 136, !14, i64 144, !14, i64 152, !14, i64 160, !14, i64 168, !14, i64 176, !14, i64 184, !14, i64 192, !14, i64 200, !14, i64 208, !14, i64 216, !14, i64 224, !10, i64 232, !15, i64 240, !15, i64 248, !15, i64 256, !10, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320}
!13 = !{!"float", !8, i64 0}
!14 = !{!"double", !8, i64 0}
!15 = !{!"long", !8, i64 0}


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