; LLVM IR from ShahjalalShohag/code-library :: Graph Theory/Maximum Clique.ll (Z12BronKerboschixxx)

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

@res = external dso_local global i32, align 4
@edges = external dso_local global [42 x i64], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12BronKerboschixxx(i32 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  %12 = load i64, ptr %7, align 8, !tbaa !9
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %14, label %23

14:                                               ; preds = %4
  %15 = load i64, ptr %8, align 8, !tbaa !9
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = call i64 @llvm.ctpop.i64(i64 %18)
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr %9, align 4, !tbaa !5
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @res, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %22 = load i32, ptr %21, align 4, !tbaa !5
  store i32 %22, ptr @res, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %94

23:                                               ; preds = %14, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %34, %23
  %25 = load i32, ptr %10, align 4, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = shl i64 1, %26
  %28 = load i64, ptr %7, align 8, !tbaa !9
  %29 = load i64, ptr %8, align 8, !tbaa !9
  %30 = or i64 %28, %29
  %31 = and i64 %27, %30
  %32 = icmp ne i64 %31, 0
  %33 = xor i1 %32, true
  br i1 %33, label %34, label %37

34:                                               ; preds = %24
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %10, align 4, !tbaa !5
  br label %24, !llvm.loop !11

37:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %90, %37
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %93

43:                                               ; preds = %38
  %44 = load i32, ptr %11, align 4, !tbaa !5
  %45 = zext i32 %44 to i64
  %46 = shl i64 1, %45
  %47 = load i64, ptr %7, align 8, !tbaa !9
  %48 = and i64 %46, %47
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %50, label %89

50:                                               ; preds = %43
  %51 = load i32, ptr %11, align 4, !tbaa !5
  %52 = zext i32 %51 to i64
  %53 = shl i64 1, %52
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = and i64 %53, %57
  %59 = icmp ne i64 %58, 0
  br i1 %59, label %89, label %60

60:                                               ; preds = %50
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = load i32, ptr %11, align 4, !tbaa !5
  %64 = zext i32 %63 to i64
  %65 = shl i64 1, %64
  %66 = or i64 %62, %65
  %67 = load i64, ptr %7, align 8, !tbaa !9
  %68 = load i32, ptr %11, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = and i64 %67, %71
  %73 = load i64, ptr %8, align 8, !tbaa !9
  %74 = load i32, ptr %11, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !9
  %78 = and i64 %73, %77
  call void @_Z12BronKerboschixxx(i32 noundef %61, i64 noundef %66, i64 noundef %72, i64 noundef %78)
  %79 = load i32, ptr %11, align 4, !tbaa !5
  %80 = zext i32 %79 to i64
  %81 = shl i64 1, %80
  %82 = load i64, ptr %7, align 8, !tbaa !9
  %83 = sub nsw i64 %82, %81
  store i64 %83, ptr %7, align 8, !tbaa !9
  %84 = load i32, ptr %11, align 4, !tbaa !5
  %85 = zext i32 %84 to i64
  %86 = shl i64 1, %85
  %87 = load i64, ptr %8, align 8, !tbaa !9
  %88 = or i64 %87, %86
  store i64 %88, ptr %8, align 8, !tbaa !9
  br label %89

89:                                               ; preds = %60, %50, %43
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %11, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %11, align 4, !tbaa !5
  br label %38, !llvm.loop !13

93:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %94

94:                                               ; preds = %93, %17
  ret void
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { inlinehint mustprogress 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 #4 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

@res = external dso_local global i32, align 4
@edges = external dso_local local_unnamed_addr global [42 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z12BronKerboschixxx(i32 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = alloca i32, align 4
  %6 = or i64 %3, %2
  %or.cond = icmp eq i64 %6, 0
  br i1 %or.cond, label %7, label %.preheader33

7:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %8 = tail call range(i64 0, 65) i64 @llvm.ctpop.i64(i64 %1)
  %9 = trunc nuw nsw i64 %8 to i32
  store i32 %9, ptr %5, align 4, !tbaa !5
  %10 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @res, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %11 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %11, ptr @res, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %.loopexit

.preheader33:                                     ; preds = %4, %.preheader33
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader33 ], [ 0, %4 ]
  %12 = shl nuw i64 1, %indvars.iv
  %13 = and i64 %12, %6
  %.not = icmp eq i64 %13, 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %.not, label %.preheader33, label %.preheader, !llvm.loop !9

.preheader:                                       ; preds = %.preheader33
  %14 = icmp sgt i32 %0, 0
  br i1 %14, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %15 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %indvars.iv
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %16

16:                                               ; preds = %.lr.ph, %30
  %indvars.iv38 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next39, %30 ]
  %.02735 = phi i64 [ %3, %.lr.ph ], [ %.1, %30 ]
  %.02834 = phi i64 [ %2, %.lr.ph ], [ %.129, %30 ]
  %17 = shl nuw i64 1, %indvars.iv38
  %18 = and i64 %17, %.02834
  %.not31 = icmp eq i64 %18, 0
  br i1 %.not31, label %30, label %19

19:                                               ; preds = %16
  %20 = load i64, ptr %15, align 8, !tbaa !11
  %21 = and i64 %20, %17
  %.not32 = icmp eq i64 %21, 0
  br i1 %.not32, label %22, label %30

22:                                               ; preds = %19
  %23 = or i64 %17, %1
  %24 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %indvars.iv38
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = and i64 %25, %.02834
  %27 = and i64 %25, %.02735
  tail call void @_Z12BronKerboschixxx(i32 noundef %0, i64 noundef %23, i64 noundef %26, i64 noundef %27)
  %28 = sub nsw i64 %.02834, %17
  %29 = or i64 %17, %.02735
  br label %30

30:                                               ; preds = %16, %19, %22
  %.129 = phi i64 [ %.02834, %19 ], [ %28, %22 ], [ %.02834, %16 ]
  %.1 = phi i64 [ %.02735, %19 ], [ %29, %22 ], [ %.02735, %16 ]
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next39, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %16, !llvm.loop !13

.loopexit:                                        ; preds = %30, %.preheader, %7
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.ctpop.i64(i64) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { inlinehint mustprogress 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 #4 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}


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