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

; 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.controldef = type { i64, i64, i64, i64, i64, i64, float, i64, i64, i64, i64, %struct.workspacedef, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }
%struct.workspacedef = type { ptr, i64, i64, ptr, ptr, i64, ptr, ptr }
%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 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1

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

18:                                               ; preds = %4
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.controldef, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = sub nsw i64 %21, 8
  store i64 %22, ptr %20, align 8, !tbaa !11
  br label %23

23:                                               ; preds = %18, %4
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.controldef, ptr %24, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = and i64 %26, 32
  %28 = icmp ne i64 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %23
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.controldef, ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !11
  %33 = sub nsw i64 %32, 32
  store i64 %33, ptr %31, align 8, !tbaa !11
  br label %34

34:                                               ; preds = %29, %23
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.controldef, ptr %35, i32 0, i32 1
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = and i64 %37, 1
  %39 = icmp ne i64 %38, 0
  br i1 %39, label %40, label %46

40:                                               ; preds = %34
  %41 = call double @gk_CPUSeconds()
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.controldef, ptr %42, i32 0, i32 13
  %44 = load double, ptr %43, align 8, !tbaa !17
  %45 = fsub double %44, %41
  store double %45, ptr %43, align 8, !tbaa !17
  br label %46

46:                                               ; preds = %40, %34
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.controldef, ptr %47, i32 0, i32 3
  %49 = load i64, ptr %48, align 8, !tbaa !18
  switch i64 %49, label %71 [
    i64 1, label %50
    i64 2, label %66
  ]

50:                                               ; preds = %46
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.graphdef, ptr %51, i32 0, i32 1
  %53 = load i64, ptr %52, align 8, !tbaa !19
  %54 = icmp eq i64 %53, 0
  br i1 %54, label %55, label %60

55:                                               ; preds = %50
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load float, ptr %8, align 4, !tbaa !9
  call void @libmetis__RandomBisection(ptr noundef %56, ptr noundef %57, ptr noundef %58, float noundef %59)
  br label %65

60:                                               ; preds = %50
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load float, ptr %8, align 4, !tbaa !9
  call void @libmetis__GrowBisection(ptr noundef %61, ptr noundef %62, ptr noundef %63, float noundef %64)
  br label %65

65:                                               ; preds = %60, %55
  br label %75

66:                                               ; preds = %46
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load float, ptr %8, align 4, !tbaa !9
  call void @libmetis__RandomBisection(ptr noundef %67, ptr noundef %68, ptr noundef %69, float noundef %70)
  br label %75

71:                                               ; preds = %46
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.controldef, ptr %72, i32 0, i32 3
  %74 = load i64, ptr %73, align 8, !tbaa !18
  call void (ptr, ...) @errexit(ptr noundef @.str, i64 noundef %74)
  br label %75

75:                                               ; preds = %71, %66, %65
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.controldef, ptr %76, i32 0, i32 1
  %78 = load i64, ptr %77, align 8, !tbaa !11
  %79 = and i64 %78, 16
  %80 = icmp ne i64 %79, 0
  br i1 %80, label %81, label %86

81:                                               ; preds = %75
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.graphdef, ptr %82, i32 0, i32 16
  %84 = load i64, ptr %83, align 8, !tbaa !22
  %85 = call i32 (ptr, ...) @mprintf(ptr noundef @.str.1, i64 noundef %84)
  br label %86

86:                                               ; preds = %81, %75
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.controldef, ptr %87, i32 0, i32 1
  %89 = load i64, ptr %88, align 8, !tbaa !11
  %90 = and i64 %89, 1
  %91 = icmp ne i64 %90, 0
  br i1 %91, label %92, label %98

92:                                               ; preds = %86
  %93 = call double @gk_CPUSeconds()
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.controldef, ptr %94, i32 0, i32 13
  %96 = load double, ptr %95, align 8, !tbaa !17
  %97 = fadd double %96, %93
  store double %97, ptr %95, align 8, !tbaa !17
  br label %98

98:                                               ; preds = %92, %86
  %99 = load i64, ptr %9, align 8, !tbaa !16
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.controldef, ptr %100, i32 0, i32 1
  store i64 %99, ptr %101, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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

declare double @gk_CPUSeconds() #2

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

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

declare void @errexit(ptr noundef, ...) #2

declare i32 @mprintf(ptr 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 }

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"controldef", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !10, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !14, i64 88, !15, i64 152, !15, i64 160, !15, i64 168, !15, i64 176, !15, i64 184, !15, i64 192, !15, i64 200, !15, i64 208, !15, i64 216, !15, i64 224, !15, i64 232, !15, i64 240, !15, i64 248, !15, i64 256, !15, i64 264, !15, i64 272}
!13 = !{!"long", !7, i64 0}
!14 = !{!"workspacedef", !6, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !6, i64 48, !6, i64 56}
!15 = !{!"double", !7, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !15, i64 160}
!18 = !{!12, !13, i64 24}
!19 = !{!20, !13, i64 8}
!20 = !{!"graphdef", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !21, i64 56, !21, i64 60, !21, i64 64, !21, i64 68, !21, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !13, i64 112, !13, i64 120, !6, i64 128, !6, i64 136, !13, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !13, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240}
!21 = !{!"int", !7, i64 0}
!22 = !{!20, !13, i64 112}


; 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 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @libmetis__Init2WayPartition(ptr noundef %0, ptr noundef %1, ptr noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = and i64 %6, 8
  %.not.not = icmp eq i64 %7, 0
  %8 = add nsw i64 %6, -8
  %9 = select i1 %.not.not, i64 %6, i64 %8
  %10 = and i64 %9, 32
  %.not27.not = icmp eq i64 %10, 0
  %11 = add nsw i64 %9, -32
  %12 = select i1 %.not27.not, i64 %9, i64 %11
  %13 = or disjoint i64 %7, %10
  %.not31 = icmp eq i64 %13, 0
  br i1 %.not31, label %15, label %14

14:                                               ; preds = %4
  store i64 %12, ptr %5, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %4, %14
  %16 = and i64 %12, 1
  %.not28 = icmp eq i64 %16, 0
  br i1 %.not28, label %22, label %17

17:                                               ; preds = %15
  %18 = tail call double @gk_CPUSeconds() #2
  %19 = getelementptr inbounds i8, ptr %0, i64 160
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = fsub double %20, %18
  store double %21, ptr %19, align 8, !tbaa !14
  br label %22

22:                                               ; preds = %17, %15
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = load i64, ptr %23, align 8, !tbaa !15
  switch i64 %24, label %32 [
    i64 1, label %25
    i64 2, label %31
  ]

25:                                               ; preds = %22
  %26 = getelementptr inbounds i8, ptr %1, i64 8
  %27 = load i64, ptr %26, align 8, !tbaa !16
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  tail call void @libmetis__RandomBisection(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, float noundef %3)
  br label %33

30:                                               ; preds = %25
  tail call void @libmetis__GrowBisection(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, float noundef %3)
  br label %33

31:                                               ; preds = %22
  tail call void @libmetis__RandomBisection(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, float noundef %3)
  br label %33

32:                                               ; preds = %22
  tail call void (ptr, ...) @errexit(ptr noundef nonnull @.str, i64 noundef %24) #2
  br label %33

33:                                               ; preds = %29, %30, %32, %31
  %34 = load i64, ptr %5, align 8, !tbaa !5
  %35 = and i64 %34, 16
  %.not29 = icmp eq i64 %35, 0
  br i1 %.not29, label %40, label %36

36:                                               ; preds = %33
  %37 = getelementptr inbounds i8, ptr %1, i64 112
  %38 = load i64, ptr %37, align 8, !tbaa !19
  %39 = tail call i32 (ptr, ...) @mprintf(ptr noundef nonnull @.str.1, i64 noundef %38) #2
  %.pre = load i64, ptr %5, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %36, %33
  %41 = phi i64 [ %.pre, %36 ], [ %34, %33 ]
  %42 = and i64 %41, 1
  %.not30 = icmp eq i64 %42, 0
  br i1 %.not30, label %48, label %43

43:                                               ; preds = %40
  %44 = tail call double @gk_CPUSeconds() #2
  %45 = getelementptr inbounds i8, ptr %0, i64 160
  %46 = load double, ptr %45, align 8, !tbaa !14
  %47 = fadd double %44, %46
  store double %47, ptr %45, align 8, !tbaa !14
  br label %48

48:                                               ; preds = %43, %40
  store i64 %6, ptr %5, align 8, !tbaa !5
  ret void
}

declare double @gk_CPUSeconds() local_unnamed_addr #1

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

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

declare void @errexit(ptr noundef, ...) local_unnamed_addr #1

declare i32 @mprintf(ptr 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 }

!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 8}
!6 = !{!"controldef", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !11, i64 88, !13, i64 152, !13, i64 160, !13, i64 168, !13, i64 176, !13, i64 184, !13, i64 192, !13, i64 200, !13, i64 208, !13, i64 216, !13, i64 224, !13, i64 232, !13, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !13, i64 272}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"workspacedef", !12, i64 0, !7, i64 8, !7, i64 16, !12, i64 24, !12, i64 32, !7, i64 40, !12, i64 48, !12, i64 56}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!6, !13, i64 160}
!15 = !{!6, !7, i64 24}
!16 = !{!17, !7, i64 8}
!17 = !{!"graphdef", !7, i64 0, !7, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !18, i64 56, !18, i64 60, !18, i64 64, !18, i64 68, !18, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !7, i64 112, !7, i64 120, !12, i64 128, !12, i64 136, !7, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !7, i64 208, !12, i64 216, !12, i64 224, !12, i64 232, !12, i64 240}
!18 = !{!"int", !8, i64 0}
!19 = !{!17, !7, i64 112}


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