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

; 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.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@gk_jbufs = external thread_local global [0 x [1 x %struct.__jmp_buf_tag]], align 8
@gk_cur_jbufs = external thread_local global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @METIS_MeshToDual(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #0 {
  %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 ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  store i32 0, ptr %19, align 4, !tbaa !9
  %21 = call i32 (...) @gk_malloc_init()
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %8
  store i32 -3, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %95

24:                                               ; preds = %8
  %25 = call i32 (...) @gk_sigtrap()
  %26 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @gk_jbufs)
  %27 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @gk_cur_jbufs)
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [0 x [1 x %struct.__jmp_buf_tag]], ptr %26, i64 0, i64 %29
  %31 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], ptr %30, i64 0, i64 0
  %32 = call i32 @_setjmp(ptr noundef %31) #7
  store i32 %32, ptr %18, align 4, !tbaa !9
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %24
  br label %57

35:                                               ; preds = %24
  %36 = load ptr, ptr %15, align 8, !tbaa !5
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 1
  br i1 %38, label %39, label %44

39:                                               ; preds = %35
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = load ptr, ptr %13, align 8, !tbaa !5
  call void @libmetis__ChangeMesh2CNumbering(i32 noundef %41, ptr noundef %42, ptr noundef %43)
  store i32 1, ptr %19, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %39, %35
  %45 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr null, ptr %45, align 8, !tbaa !5
  %46 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr null, ptr %46, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = load ptr, ptr %16, align 8, !tbaa !5
  %56 = load ptr, ptr %17, align 8, !tbaa !5
  call void @libmetis__CreateGraphDual(i32 noundef %48, i32 noundef %50, ptr noundef %51, ptr noundef %52, i32 noundef %54, ptr noundef %55, ptr noundef %56)
  br label %57

57:                                               ; preds = %44, %34
  %58 = load i32, ptr %19, align 4, !tbaa !9
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %71

60:                                               ; preds = %57
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = load ptr, ptr %17, align 8, !tbaa !5
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  call void @libmetis__ChangeMesh2FNumbering(i32 noundef %62, ptr noundef %63, ptr noundef %64, i32 noundef %66, ptr noundef %68, ptr noundef %70)
  br label %71

71:                                               ; preds = %60, %57
  %72 = call i32 (...) @gk_siguntrap()
  call void @gk_malloc_cleanup(i32 noundef 0)
  %73 = load i32, ptr %18, align 4, !tbaa !9
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %92

75:                                               ; preds = %71
  %76 = load ptr, ptr %16, align 8, !tbaa !5
  %77 = load ptr, ptr %76, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %82

79:                                               ; preds = %75
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  %81 = load ptr, ptr %80, align 8, !tbaa !5
  call void @free(ptr noundef %81) #6
  br label %82

82:                                               ; preds = %79, %75
  %83 = load ptr, ptr %17, align 8, !tbaa !5
  %84 = load ptr, ptr %83, align 8, !tbaa !5
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %89

86:                                               ; preds = %82
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = load ptr, ptr %87, align 8, !tbaa !5
  call void @free(ptr noundef %88) #6
  br label %89

89:                                               ; preds = %86, %82
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr null, ptr %90, align 8, !tbaa !5
  %91 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr null, ptr %91, align 8, !tbaa !5
  br label %92

92:                                               ; preds = %89, %71
  %93 = load i32, ptr %18, align 4, !tbaa !9
  %94 = call i32 @libmetis__metis_rcode(i32 noundef %93)
  store i32 %94, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %95

95:                                               ; preds = %92, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  %96 = load i32, ptr %9, align 4
  ret i32 %96
}

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

declare i32 @gk_malloc_init(...) #2

declare i32 @gk_sigtrap(...) #2

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #4

declare void @libmetis__ChangeMesh2CNumbering(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @libmetis__CreateGraphDual(i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

declare void @libmetis__ChangeMesh2FNumbering(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

declare i32 @gk_siguntrap(...) #2

declare void @gk_malloc_cleanup(i32 noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

declare i32 @libmetis__metis_rcode(i32 noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 returns_twice "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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind "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 #6 = { nounwind }
attributes #7 = { nounwind returns_twice }

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


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

%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@gk_jbufs = external thread_local global [0 x [1 x %struct.__jmp_buf_tag]], align 8
@gk_cur_jbufs = external thread_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @METIS_MeshToDual(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #0 {
  %9 = call i32 (...) @gk_malloc_init() #5
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %42, label %10

10:                                               ; preds = %8
  %11 = call i32 (...) @gk_sigtrap() #5
  %12 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @gk_jbufs)
  %13 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @gk_cur_jbufs)
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [0 x [1 x %struct.__jmp_buf_tag]], ptr %12, i64 0, i64 %15
  %17 = call i32 @_setjmp(ptr noundef nonnull %16) #6
  %.not31 = icmp eq i32 %17, 0
  br i1 %.not31, label %18, label %32

18:                                               ; preds = %10
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %.not37 = icmp eq i32 %19, 1
  br i1 %.not37, label %20, label %.critedge.critedge

20:                                               ; preds = %18
  %21 = load i32, ptr %0, align 4, !tbaa !5
  call void @libmetis__ChangeMesh2CNumbering(i32 noundef %21, ptr noundef %2, ptr noundef %3) #5
  store ptr null, ptr %7, align 8, !tbaa !9
  store ptr null, ptr %6, align 8, !tbaa !9
  %22 = load i32, ptr %0, align 4, !tbaa !5
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !5
  call void @libmetis__CreateGraphDual(i32 noundef %22, i32 noundef %23, ptr noundef %2, ptr noundef %3, i32 noundef %24, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %25 = load i32, ptr %0, align 4, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = load ptr, ptr %7, align 8, !tbaa !9
  call void @libmetis__ChangeMesh2FNumbering(i32 noundef %25, ptr noundef %2, ptr noundef %3, i32 noundef %25, ptr noundef %26, ptr noundef %27) #5
  br label %.critedge

.critedge.critedge:                               ; preds = %18
  store ptr null, ptr %7, align 8, !tbaa !9
  store ptr null, ptr %6, align 8, !tbaa !9
  %28 = load i32, ptr %0, align 4, !tbaa !5
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  call void @libmetis__CreateGraphDual(i32 noundef %28, i32 noundef %29, ptr noundef %2, ptr noundef %3, i32 noundef %30, ptr noundef nonnull %6, ptr noundef nonnull %7)
  br label %.critedge

.critedge:                                        ; preds = %.critedge.critedge, %20
  %31 = call i32 (...) @gk_siguntrap() #5
  call void @gk_malloc_cleanup(i32 noundef 0) #5
  br label %40

32:                                               ; preds = %10
  %33 = call i32 (...) @gk_siguntrap() #5
  call void @gk_malloc_cleanup(i32 noundef 0) #5
  %34 = load ptr, ptr %6, align 8, !tbaa !9
  %.not33 = icmp eq ptr %34, null
  br i1 %.not33, label %36, label %35

35:                                               ; preds = %32
  call void @free(ptr noundef nonnull %34) #5
  br label %36

36:                                               ; preds = %35, %32
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %.not34 = icmp eq ptr %37, null
  br i1 %.not34, label %39, label %38

38:                                               ; preds = %36
  call void @free(ptr noundef nonnull %37) #5
  br label %39

39:                                               ; preds = %38, %36
  store ptr null, ptr %7, align 8, !tbaa !9
  store ptr null, ptr %6, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %.critedge, %39
  %41 = call i32 @libmetis__metis_rcode(i32 noundef %17) #5
  br label %42

42:                                               ; preds = %8, %40
  %.028 = phi i32 [ %41, %40 ], [ -3, %8 ]
  ret i32 %.028
}

declare i32 @gk_malloc_init(...) local_unnamed_addr #1

declare i32 @gk_sigtrap(...) local_unnamed_addr #1

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @libmetis__CreateGraphDual(i32 noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare i32 @gk_siguntrap(...) local_unnamed_addr #1

declare void @gk_malloc_cleanup(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

declare i32 @libmetis__metis_rcode(i32 noundef) local_unnamed_addr #1

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 = { nounwind returns_twice "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind }
attributes #6 = { nounwind returns_twice }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass