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

; 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.9 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 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 i32 @printf(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 i32 @libmetis__CheckInputGraphWeights(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %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 i32, align 4
  %17 = alloca i32, align 4
  store i32 %0, ptr %9, align 4, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !5
  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 ptr %6, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = icmp sle i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %7
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %96

22:                                               ; preds = %7
  %23 = load ptr, ptr %13, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %46

25:                                               ; preds = %22
  %26 = load i32, ptr %10, align 4, !tbaa !5
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = mul nsw i32 %26, %27
  store i32 %28, ptr %16, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %42, %25
  %30 = load i32, ptr %16, align 4, !tbaa !5
  %31 = icmp sge i32 %30, 0
  br i1 %31, label %32, label %45

32:                                               ; preds = %29
  %33 = load ptr, ptr %13, align 8, !tbaa !9
  %34 = load i32, ptr %16, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr %33, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = icmp slt i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %32
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %96

41:                                               ; preds = %32
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %16, align 4, !tbaa !5
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr %16, align 4, !tbaa !5
  br label %29, !llvm.loop !11

45:                                               ; preds = %29
  br label %46

46:                                               ; preds = %45, %22
  %47 = load ptr, ptr %14, align 8, !tbaa !9
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %68

49:                                               ; preds = %46
  %50 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %50, ptr %16, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %64, %49
  %52 = load i32, ptr %16, align 4, !tbaa !5
  %53 = icmp sge i32 %52, 0
  br i1 %53, label %54, label %67

54:                                               ; preds = %51
  %55 = load ptr, ptr %14, align 8, !tbaa !9
  %56 = load i32, ptr %16, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %55, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = icmp slt i32 %59, 0
  br i1 %60, label %61, label %63

61:                                               ; preds = %54
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %96

63:                                               ; preds = %54
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %16, align 4, !tbaa !5
  %66 = add nsw i32 %65, -1
  store i32 %66, ptr %16, align 4, !tbaa !5
  br label %51, !llvm.loop !13

67:                                               ; preds = %51
  br label %68

68:                                               ; preds = %67, %46
  %69 = load ptr, ptr %15, align 8, !tbaa !9
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %95

71:                                               ; preds = %68
  %72 = load ptr, ptr %11, align 8, !tbaa !9
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i32, ptr %72, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sub nsw i32 %76, 1
  store i32 %77, ptr %16, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %91, %71
  %79 = load i32, ptr %16, align 4, !tbaa !5
  %80 = icmp sge i32 %79, 0
  br i1 %80, label %81, label %94

81:                                               ; preds = %78
  %82 = load ptr, ptr %15, align 8, !tbaa !9
  %83 = load i32, ptr %16, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i32, ptr %82, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = icmp slt i32 %86, 0
  br i1 %87, label %88, label %90

88:                                               ; preds = %81
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %96

90:                                               ; preds = %81
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %16, align 4, !tbaa !5
  %93 = add nsw i32 %92, -1
  store i32 %93, ptr %16, align 4, !tbaa !5
  br label %78, !llvm.loop !14

94:                                               ; preds = %78
  br label %95

95:                                               ; preds = %94, %68
  store i32 1, ptr %8, align 4
  store i32 1, ptr %17, align 4
  br label %96

96:                                               ; preds = %95, %88, %61, %39, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  %97 = load i32, ptr %8, align 4
  ret i32 %97
}

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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.9 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @libmetis__CheckInputGraphWeights(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readnone %3, ptr noundef readonly %4, ptr noundef readonly %5, ptr noundef readonly %6) local_unnamed_addr #1 {
  %8 = icmp slt i32 %1, 1
  br i1 %8, label %.loopexit.sink.split, label %9

9:                                                ; preds = %7
  %.not = icmp ne ptr %4, null
  %10 = mul nsw i32 %1, %0
  %11 = icmp sgt i32 %10, -1
  %or.cond = select i1 %.not, i1 %11, i1 false
  br i1 %or.cond, label %.lr.ph, label %.loopexit29

12:                                               ; preds = %.lr.ph
  %13 = add nsw i32 %.030, -1
  %14 = icmp sgt i32 %.030, 0
  br i1 %14, label %.lr.ph, label %.loopexit29, !llvm.loop !5

.lr.ph:                                           ; preds = %9, %12
  %.030 = phi i32 [ %13, %12 ], [ %10, %9 ]
  %15 = zext nneg i32 %.030 to i64
  %16 = getelementptr inbounds i32, ptr %4, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !7
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %.loopexit.sink.split, label %12

.loopexit29:                                      ; preds = %12, %9
  %.not26 = icmp ne ptr %5, null
  %19 = icmp sgt i32 %0, -1
  %or.cond34 = and i1 %.not26, %19
  br i1 %or.cond34, label %.lr.ph32, label %.loopexit28

20:                                               ; preds = %.lr.ph32
  %21 = add nsw i32 %.131, -1
  %22 = icmp sgt i32 %.131, 0
  br i1 %22, label %.lr.ph32, label %.loopexit28, !llvm.loop !11

.lr.ph32:                                         ; preds = %.loopexit29, %20
  %.131 = phi i32 [ %21, %20 ], [ %0, %.loopexit29 ]
  %23 = zext nneg i32 %.131 to i64
  %24 = getelementptr inbounds i32, ptr %5, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !7
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %.loopexit.sink.split, label %20

.loopexit28:                                      ; preds = %20, %.loopexit29
  %.not27 = icmp eq ptr %6, null
  br i1 %.not27, label %.loopexit, label %27

27:                                               ; preds = %.loopexit28
  %28 = sext i32 %0 to i64
  %29 = getelementptr inbounds i32, ptr %2, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !7
  %31 = zext i32 %30 to i64
  br label %32

32:                                               ; preds = %35, %27
  %indvars.iv = phi i64 [ %36, %35 ], [ %31, %27 ]
  %33 = trunc nuw i64 %indvars.iv to i32
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %35, label %.loopexit

35:                                               ; preds = %32
  %36 = add nsw i64 %indvars.iv, -1
  %37 = getelementptr inbounds i32, ptr %6, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !7
  %39 = icmp slt i32 %38, 0
  br i1 %39, label %.loopexit.sink.split, label %32, !llvm.loop !12

.loopexit.sink.split:                             ; preds = %.lr.ph, %.lr.ph32, %35, %7
  %.str.12.sink = phi ptr [ @.str.9, %7 ], [ @.str.12, %35 ], [ @.str.11, %.lr.ph32 ], [ @.str.10, %.lr.ph ]
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.12.sink)
  br label %.loopexit

.loopexit:                                        ; preds = %32, %.loopexit.sink.split, %.loopexit28
  %.021 = phi i32 [ 1, %.loopexit28 ], [ 0, %.loopexit.sink.split ], [ 1, %32 ]
  ret i32 %.021
}

attributes #0 = { nofree 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 #1 = { nofree 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" }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}
!12 = distinct !{!12, !6}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass