; LLVM IR from ShahjalalShohag/code-library :: Miscellaneous/Bitset Custom.ll (Z4initv)

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

@o = external dso_local global [64 x [64 x i64]], align 16
@z = external dso_local global [64 x [64 x i64]], align 16

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

4:                                                ; preds = %66, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 64
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %69

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

10:                                               ; preds = %62, %8
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 64
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %10
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = icmp eq i32 %15, %16
  br i1 %17, label %18, label %28

18:                                               ; preds = %14
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = zext i32 %19 to i64
  %21 = shl i64 1, %20
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [64 x [64 x i64]], ptr @o, i64 0, i64 %23
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [64 x i64], ptr %24, i64 0, i64 %26
  store i64 %21, ptr %27, align 8, !tbaa !9
  br label %47

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

47:                                               ; preds = %28, %18
  %48 = load i32, ptr %1, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [64 x [64 x i64]], ptr @o, i64 0, i64 %49
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [64 x i64], ptr %50, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = xor i64 -1, %54
  %56 = load i32, ptr %1, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [64 x [64 x i64]], ptr @z, i64 0, i64 %57
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [64 x i64], ptr %58, i64 0, i64 %60
  store i64 %55, ptr %61, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %47
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !11

65:                                               ; preds = %13
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %1, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !13

69:                                               ; preds = %7
  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 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 = { 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"

@o = external dso_local local_unnamed_addr global [64 x [64 x i64]], align 16
@z = external dso_local local_unnamed_addr global [64 x [64 x i64]], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %0, %.loopexit
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next23.peel, %.loopexit ]
  %2 = shl nuw i64 1, %indvars.iv
  %3 = getelementptr inbounds [64 x [64 x i64]], ptr @o, i64 0, i64 %indvars.iv, i64 %indvars.iv
  store i64 %2, ptr %3, align 8
  %4 = xor i64 %2, -1
  %5 = getelementptr inbounds [64 x [64 x i64]], ptr @z, i64 0, i64 %indvars.iv, i64 %indvars.iv
  store i64 %4, ptr %5, align 8, !tbaa !5
  %indvars.iv.next23.peel = add nuw nsw i64 %indvars.iv, 1
  %exitcond.peel.not = icmp eq i64 %indvars.iv.next23.peel, 64
  br i1 %exitcond.peel.not, label %.loopexit.thread, label %.peel.next

.peel.next:                                       ; preds = %1
  %6 = shl nuw i64 1, %indvars.iv
  br label %7

.loopexit.thread:                                 ; preds = %1, %.loopexit
  ret void

.loopexit:                                        ; preds = %7
  br i1 %exitcond.peel.not, label %.loopexit.thread, label %1, !llvm.loop !9

7:                                                ; preds = %.peel.next, %7
  %8 = phi i64 [ %2, %.peel.next ], [ %.sink28, %7 ]
  %indvars.iv22 = phi i64 [ %indvars.iv.next23.peel, %.peel.next ], [ %indvars.iv.next23, %7 ]
  %9 = icmp eq i64 %indvars.iv22, %indvars.iv
  %10 = shl nuw i64 1, %indvars.iv22
  %11 = or i64 %8, %10
  %.sink28 = select i1 %9, i64 %6, i64 %11
  %12 = getelementptr inbounds [64 x [64 x i64]], ptr @o, i64 0, i64 %indvars.iv, i64 %indvars.iv22
  store i64 %.sink28, ptr %12, align 8
  %13 = xor i64 %.sink28, -1
  %14 = getelementptr inbounds [64 x [64 x i64]], ptr @z, i64 0, i64 %indvars.iv, i64 %indvars.iv22
  store i64 %13, ptr %14, align 8, !tbaa !5
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next23, 64
  br i1 %exitcond.not, label %.loopexit, label %7, !llvm.loop !11
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(write, argmem: none, inaccessiblemem: none) 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12}
!12 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass