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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12BronKerboschixxx(i32 noundef, i64 noundef, i64 noundef, i64 noundef) #0

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z10max_cliquei(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  store i32 0, ptr @res, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %46, %1
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = icmp sle i32 %7, %8
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %49

11:                                               ; preds = %6
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sub nsw i32 %12, 1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %14
  store i64 0, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %42, %11
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %45

21:                                               ; preds = %16
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [42 x [42 x i32]], ptr @g, i64 0, i64 %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [42 x i32], ptr %24, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %41

30:                                               ; preds = %21
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = sub nsw i32 %31, 1
  %33 = zext i32 %32 to i64
  %34 = shl i64 1, %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sub nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !9
  %40 = or i64 %39, %34
  store i64 %40, ptr %38, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %30, %21
  br label %42

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

45:                                               ; preds = %20
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !5
  br label %6, !llvm.loop !13

49:                                               ; preds = %10
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = zext i32 %51 to i64
  %53 = shl i64 1, %52
  %54 = sub nsw i64 %53, 1
  call void @_Z12BronKerboschixxx(i32 noundef %50, i64 noundef 0, i64 noundef %54, i64 noundef 0)
  %55 = load i32, ptr @res, align 4, !tbaa !5
  ret i32 %55
}

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 = { 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"

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12BronKerboschixxx(i32 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z10max_cliquei(i32 noundef %0) local_unnamed_addr #0 {
  store i32 0, ptr @res, align 4, !tbaa !5
  %.not19 = icmp slt i32 %0, 1
  br i1 %.not19, label %._crit_edge23, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %1
  %2 = add nuw i32 %0, 1
  %wide.trip.count28 = zext i32 %2 to i64
  %3 = zext nneg i32 %0 to i64
  %xtraiter = and i64 %3, 1
  %4 = icmp eq i32 %2, 2
  %unroll_iter = and i64 %3, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph

._crit_edge23:                                    ; preds = %._crit_edge, %1
  %5 = zext nneg i32 %0 to i64
  %notmask = shl nsw i64 -1, %5
  %6 = xor i64 %notmask, -1
  tail call void @_Z12BronKerboschixxx(i32 noundef %0, i64 noundef 0, i64 noundef %6, i64 noundef 0)
  %7 = load i32, ptr @res, align 4, !tbaa !5
  ret i32 %7

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %indvars.iv25 = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next26, %._crit_edge ]
  %8 = add nsw i64 %indvars.iv25, -1
  %9 = getelementptr inbounds [42 x i64], ptr @edges, i64 0, i64 %8
  store i64 0, ptr %9, align 8, !tbaa !9
  br i1 %4, label %._crit_edge.unr-lcssa, label %.lr.ph.new

._crit_edge.unr-lcssa:                            ; preds = %30, %.lr.ph
  %.unr = phi i64 [ 0, %.lr.ph ], [ %31, %30 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next.1, %30 ]
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.unr-lcssa
  %10 = getelementptr inbounds [42 x [42 x i32]], ptr @g, i64 0, i64 %indvars.iv25, i64 %indvars.iv.unr
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %.not16.epil = icmp eq i32 %11, 0
  br i1 %.not16.epil, label %._crit_edge, label %12

12:                                               ; preds = %.epil.preheader
  %13 = add nsw i64 %indvars.iv.unr, -1
  %14 = shl nuw i64 1, %13
  %15 = or i64 %.unr, %14
  store i64 %15, ptr %9, align 8, !tbaa !9
  br label %._crit_edge

._crit_edge:                                      ; preds = %.epil.preheader, %12, %._crit_edge.unr-lcssa
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next26, %wide.trip.count28
  br i1 %exitcond29.not, label %._crit_edge23, label %.lr.ph, !llvm.loop !11

.lr.ph.new:                                       ; preds = %.lr.ph, %30
  %16 = phi i64 [ %31, %30 ], [ 0, %.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %30 ], [ 1, %.lr.ph ]
  %niter = phi i64 [ %niter.next.1, %30 ], [ 0, %.lr.ph ]
  %17 = getelementptr inbounds [42 x [42 x i32]], ptr @g, i64 0, i64 %indvars.iv25, i64 %indvars.iv
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not16 = icmp eq i32 %18, 0
  br i1 %.not16, label %23, label %19

19:                                               ; preds = %.lr.ph.new
  %20 = add nsw i64 %indvars.iv, -1
  %21 = shl nuw i64 1, %20
  %22 = or i64 %16, %21
  store i64 %22, ptr %9, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %.lr.ph.new, %19
  %24 = phi i64 [ %16, %.lr.ph.new ], [ %22, %19 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = getelementptr inbounds [42 x [42 x i32]], ptr @g, i64 0, i64 %indvars.iv25, i64 %indvars.iv.next
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %.not16.1 = icmp eq i32 %26, 0
  br i1 %.not16.1, label %30, label %27

27:                                               ; preds = %23
  %28 = shl nuw i64 1, %indvars.iv
  %29 = or i64 %24, %28
  store i64 %29, ptr %9, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %27, %23
  %31 = phi i64 [ %24, %23 ], [ %29, %27 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.unr-lcssa, label %.lr.ph.new, !llvm.loop !13
}

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

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


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