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

; 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.14 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [62 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 ptr @libmetis__idxmalloc(i64 noundef, 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 i32 @mprintf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @libmetis__IsConnected(ptr noundef %0, ptr noundef %1, i64 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, 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 i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.graphdef, ptr %17, i32 0, i32 0
  %19 = load i64, ptr %18, align 8, !tbaa !11
  store i64 %19, ptr %10, align 8, !tbaa !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.graphdef, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  store ptr %22, ptr %13, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.graphdef, ptr %23, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  store ptr %25, ptr %14, align 8, !tbaa !5
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = call ptr @libmetis__idxsmalloc(i64 noundef %26, i64 noundef 0, ptr noundef @.str.14)
  store ptr %27, ptr %15, align 8, !tbaa !5
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = call ptr @libmetis__idxmalloc(i64 noundef %28, ptr noundef @.str.15)
  store ptr %29, ptr %16, align 8, !tbaa !5
  %30 = load ptr, ptr %15, align 8, !tbaa !5
  %31 = getelementptr inbounds i64, ptr %30, i64 0
  store i64 1, ptr %31, align 8, !tbaa !9
  %32 = load ptr, ptr %16, align 8, !tbaa !5
  %33 = getelementptr inbounds i64, ptr %32, i64 0
  store i64 0, ptr %33, align 8, !tbaa !9
  store i64 0, ptr %11, align 8, !tbaa !9
  store i64 1, ptr %12, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %79, %3
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = load i64, ptr %12, align 8, !tbaa !9
  %37 = icmp slt i64 %35, %36
  br i1 %37, label %38, label %80

38:                                               ; preds = %34
  %39 = load ptr, ptr %16, align 8, !tbaa !5
  %40 = load i64, ptr %11, align 8, !tbaa !9
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr %11, align 8, !tbaa !9
  %42 = getelementptr inbounds i64, ptr %39, i64 %40
  %43 = load i64, ptr %42, align 8, !tbaa !9
  store i64 %43, ptr %7, align 8, !tbaa !9
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = getelementptr inbounds i64, ptr %44, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !9
  store i64 %47, ptr %8, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %76, %38
  %49 = load i64, ptr %8, align 8, !tbaa !9
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = load i64, ptr %7, align 8, !tbaa !9
  %52 = add nsw i64 %51, 1
  %53 = getelementptr inbounds i64, ptr %50, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = icmp slt i64 %49, %54
  br i1 %55, label %56, label %79

56:                                               ; preds = %48
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = load i64, ptr %8, align 8, !tbaa !9
  %59 = getelementptr inbounds i64, ptr %57, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !9
  store i64 %60, ptr %9, align 8, !tbaa !9
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  %62 = load i64, ptr %9, align 8, !tbaa !9
  %63 = getelementptr inbounds i64, ptr %61, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !9
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %75, label %66

66:                                               ; preds = %56
  %67 = load i64, ptr %9, align 8, !tbaa !9
  %68 = load ptr, ptr %16, align 8, !tbaa !5
  %69 = load i64, ptr %12, align 8, !tbaa !9
  %70 = add nsw i64 %69, 1
  store i64 %70, ptr %12, align 8, !tbaa !9
  %71 = getelementptr inbounds i64, ptr %68, i64 %69
  store i64 %67, ptr %71, align 8, !tbaa !9
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = load i64, ptr %9, align 8, !tbaa !9
  %74 = getelementptr inbounds i64, ptr %72, i64 %73
  store i64 1, ptr %74, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %66, %56
  br label %76

76:                                               ; preds = %75
  %77 = load i64, ptr %8, align 8, !tbaa !9
  %78 = add nsw i64 %77, 1
  store i64 %78, ptr %8, align 8, !tbaa !9
  br label %48, !llvm.loop !16

79:                                               ; preds = %48
  br label %34, !llvm.loop !18

80:                                               ; preds = %34
  %81 = load i64, ptr %11, align 8, !tbaa !9
  %82 = load i64, ptr %10, align 8, !tbaa !9
  %83 = icmp ne i64 %81, %82
  br i1 %83, label %84, label %92

84:                                               ; preds = %80
  %85 = load i64, ptr %6, align 8, !tbaa !9
  %86 = icmp ne i64 %85, 0
  br i1 %86, label %87, label %92

87:                                               ; preds = %84
  %88 = load i64, ptr %10, align 8, !tbaa !9
  %89 = load i64, ptr %11, align 8, !tbaa !9
  %90 = sub nsw i64 %88, %89
  %91 = call i32 (ptr, ...) @mprintf(ptr noundef @.str.20, i64 noundef %90)
  br label %92

92:                                               ; preds = %87, %84, %80
  %93 = load i64, ptr %11, align 8, !tbaa !9
  %94 = load i64, ptr %10, align 8, !tbaa !9
  %95 = icmp eq i64 %93, %94
  %96 = zext i1 %95 to i64
  %97 = select i1 %95, i32 1, i32 0
  %98 = sext i32 %97 to i64
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  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
  ret i64 %98
}

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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"graphdef", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !10, i64 120, !6, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !10, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 40}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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.14 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [62 x i8], align 1

declare ptr @libmetis__idxsmalloc(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @libmetis__idxmalloc(i64 noundef, ptr noundef) local_unnamed_addr #0

declare i32 @mprintf(ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, 2) i64 @libmetis__IsConnected(ptr nocapture noundef readnone %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %1, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = tail call ptr @libmetis__idxsmalloc(i64 noundef %4, i64 noundef 0, ptr noundef nonnull @.str.14) #2
  %10 = tail call ptr @libmetis__idxmalloc(i64 noundef %4, ptr noundef nonnull @.str.15) #2
  store i64 1, ptr %9, align 8, !tbaa !14
  store i64 0, ptr %10, align 8, !tbaa !14
  br label %12

.loopexit:                                        ; preds = %29, %12
  %.1.lcssa = phi i64 [ %.03438, %12 ], [ %.2, %29 ]
  %11 = icmp slt i64 %13, %.1.lcssa
  br i1 %11, label %12, label %33, !llvm.loop !15

12:                                               ; preds = %3, %.loopexit
  %.03339 = phi i64 [ 0, %3 ], [ %13, %.loopexit ]
  %.03438 = phi i64 [ 1, %3 ], [ %.1.lcssa, %.loopexit ]
  %13 = add nuw nsw i64 %.03339, 1
  %14 = getelementptr inbounds i64, ptr %10, i64 %.03339
  %15 = load i64, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds i64, ptr %6, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = getelementptr i8, ptr %16, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !14
  %20 = icmp slt i64 %17, %19
  br i1 %20, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %12, %29
  %21 = phi i64 [ %30, %29 ], [ %19, %12 ]
  %.037 = phi i64 [ %31, %29 ], [ %17, %12 ]
  %.136 = phi i64 [ %.2, %29 ], [ %.03438, %12 ]
  %22 = getelementptr inbounds i64, ptr %8, i64 %.037
  %23 = load i64, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds i64, ptr %9, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !14
  %.not = icmp eq i64 %25, 0
  br i1 %.not, label %26, label %29

26:                                               ; preds = %.lr.ph
  %27 = add nsw i64 %.136, 1
  %28 = getelementptr inbounds i64, ptr %10, i64 %.136
  store i64 %23, ptr %28, align 8, !tbaa !14
  store i64 1, ptr %24, align 8, !tbaa !14
  %.pre = load i64, ptr %18, align 8, !tbaa !14
  br label %29

29:                                               ; preds = %.lr.ph, %26
  %30 = phi i64 [ %21, %.lr.ph ], [ %.pre, %26 ]
  %.2 = phi i64 [ %.136, %.lr.ph ], [ %27, %26 ]
  %31 = add nsw i64 %.037, 1
  %32 = icmp slt i64 %31, %30
  br i1 %32, label %.lr.ph, label %.loopexit, !llvm.loop !17

33:                                               ; preds = %.loopexit
  %34 = icmp ne i64 %13, %4
  %35 = icmp ne i64 %2, 0
  %or.cond = and i1 %35, %34
  br i1 %or.cond, label %36, label %39

36:                                               ; preds = %33
  %37 = sub nsw i64 %4, %13
  %38 = tail call i32 (ptr, ...) @mprintf(ptr noundef nonnull @.str.20, i64 noundef %37) #2
  br label %39

39:                                               ; preds = %36, %33
  %40 = icmp eq i64 %13, %4
  %41 = zext i1 %40 to i64
  ret i64 %41
}

attributes #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 = { 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 = { 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 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass