; LLVM IR from Dev-XYS/Algorithms :: Combination.ll (Z16enum_combinationii)

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

@sc = external dso_local global i32, align 4
@sel = external dso_local global [50010 x i8], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16enum_combinationii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %29

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %24, %8
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = load i32, ptr @sc, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %27

14:                                               ; preds = %9
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !9, !range !11, !noundef !12
  %19 = trunc i8 %18 to i1
  br i1 %19, label %20, label %23

20:                                               ; preds = %14
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %21)
  br label %23

23:                                               ; preds = %20, %14
  br label %24

24:                                               ; preds = %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %5, align 4, !tbaa !5
  br label %9, !llvm.loop !13

27:                                               ; preds = %13
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %71

29:                                               ; preds = %2
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = icmp sgt i32 %30, %31
  br i1 %32, label %33, label %53

33:                                               ; preds = %29
  %34 = load i32, ptr @sc, align 4, !tbaa !5
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sub nsw i32 %34, %35
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %38
  store i8 1, ptr %39, align 1, !tbaa !9
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sub nsw i32 %42, 1
  call void @_Z16enum_combinationii(i32 noundef %41, i32 noundef %43)
  %44 = load i32, ptr @sc, align 4, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = sub nsw i32 %44, %45
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %48
  store i8 0, ptr %49, align 1, !tbaa !9
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z16enum_combinationii(i32 noundef %51, i32 noundef %52)
  br label %64

53:                                               ; preds = %29
  %54 = load i32, ptr @sc, align 4, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sub nsw i32 %54, %55
  %57 = sub nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %58
  store i8 1, ptr %59, align 1, !tbaa !9
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sub nsw i32 %60, 1
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  call void @_Z16enum_combinationii(i32 noundef %61, i32 noundef %63)
  br label %64

64:                                               ; preds = %53, %33
  %65 = load i32, ptr @sc, align 4, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = sub nsw i32 %65, %66
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %69
  store i8 0, ptr %70, align 1, !tbaa !9
  br label %71

71:                                               ; preds = %64, %27
  ret void
}

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

declare i32 @printf(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 = { 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 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@sc = external dso_local local_unnamed_addr global i32, align 4
@sel = external dso_local local_unnamed_addr global [50010 x i8], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z16enum_combinationii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq i32 %1, 0
  br i1 %3, label %.preheader, label %18

.preheader:                                       ; preds = %2
  %4 = load i32, ptr @sc, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %14, %.preheader
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %37

.lr.ph:                                           ; preds = %.preheader, %14
  %7 = phi i32 [ %15, %14 ], [ %4, %.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %14 ], [ 0, %.preheader ]
  %8 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %indvars.iv
  %9 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %11, label %14

11:                                               ; preds = %.lr.ph
  %12 = trunc nuw nsw i64 %indvars.iv to i32
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %12)
  %.pre = load i32, ptr @sc, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %.lr.ph, %11
  %15 = phi i32 [ %7, %.lr.ph ], [ %.pre, %11 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = sext i32 %15 to i64
  %17 = icmp slt i64 %indvars.iv.next, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !13

18:                                               ; preds = %2
  %19 = icmp sgt i32 %0, %1
  %20 = load i32, ptr @sc, align 4, !tbaa !5
  %21 = xor i32 %0, -1
  %22 = add i32 %20, %21
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %23
  store i8 1, ptr %24, align 1, !tbaa !9
  %25 = add nsw i32 %0, -1
  %26 = add nsw i32 %1, -1
  tail call void @_Z16enum_combinationii(i32 noundef %25, i32 noundef %26)
  br i1 %19, label %27, label %32

27:                                               ; preds = %18
  %28 = load i32, ptr @sc, align 4, !tbaa !5
  %29 = add i32 %28, %21
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %30
  store i8 0, ptr %31, align 1, !tbaa !9
  tail call void @_Z16enum_combinationii(i32 noundef %25, i32 noundef %1)
  br label %32

32:                                               ; preds = %18, %27
  %33 = load i32, ptr @sc, align 4, !tbaa !5
  %34 = add i32 %33, %21
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [50010 x i8], ptr @sel, i64 0, i64 %35
  store i8 0, ptr %36, align 1, !tbaa !9
  br label %37

37:                                               ; preds = %32, %._crit_edge
  ret void
}

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

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

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


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