; LLVM IR from abhisheknaiidu/dsa :: gfg-DSA/Bits (2-duplicate)

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@__const.main.arr = external hidden unnamed_addr constant [6 x i32], align 16
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14abhisheknaiiduv() #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [6 x i32], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @_Z14abhisheknaiiduv()
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %6, ptr align 16 @__const.main.arr, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 6, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %28, %2
  %17 = load i32, ptr %9, align 4, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %31

21:                                               ; preds = %16
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [6 x i32], ptr %6, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = xor i32 %22, %26
  store i32 %27, ptr %8, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %21
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %9, align 4, !tbaa !5
  br label %16, !llvm.loop !11

31:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %32 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %32, ptr %11, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %41, %31
  %34 = load i32, ptr %11, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %46

36:                                               ; preds = %33
  %37 = load i32, ptr %11, align 4, !tbaa !5
  %38 = and i32 %37, 1
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %36
  br label %46

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

46:                                               ; preds = %40, %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %47 = load i32, ptr %10, align 4, !tbaa !5
  %48 = ashr i32 1, %47
  store i32 %48, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %70, %46
  %50 = load i32, ptr %14, align 4, !tbaa !5
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %73

54:                                               ; preds = %49
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = load i32, ptr %14, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [6 x i32], ptr %6, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = and i32 %55, %59
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %69

62:                                               ; preds = %54
  %63 = load i32, ptr %14, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [6 x i32], ptr %6, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = load i32, ptr %13, align 4, !tbaa !5
  %68 = xor i32 %67, %66
  store i32 %68, ptr %13, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %62, %54
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %14, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %14, align 4, !tbaa !5
  br label %49, !llvm.loop !14

73:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %74 = load i32, ptr %13, align 4, !tbaa !5
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = xor i32 %74, %75
  store i32 %76, ptr %15, align 4, !tbaa !5
  %77 = load i32, ptr %13, align 4, !tbaa !5
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %77)
  %79 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %78, ptr noundef @.str.4)
  %80 = load i32, ptr %15, align 4, !tbaa !5
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %79, i32 noundef %80)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #6
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #5

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 = { mustprogress norecurse 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 #5 = { "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 #6 = { 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 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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"

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@__const.main.arr = external hidden unnamed_addr constant [6 x i32], align 16
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z14abhisheknaiiduv() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
.preheader:
  tail call void @_Z14abhisheknaiiduv()
  %2 = load i32, ptr @__const.main.arr, align 16, !tbaa !5
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.arr, i64 4), align 4, !tbaa !5
  %4 = xor i32 %3, %2
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.arr, i64 8), align 8, !tbaa !5
  %6 = xor i32 %5, %4
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.arr, i64 12), align 4, !tbaa !5
  %8 = xor i32 %7, %6
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.arr, i64 16), align 16, !tbaa !5
  %10 = xor i32 %9, %8
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.arr, i64 20), align 4, !tbaa !5
  %12 = xor i32 %11, %10
  %.not31 = icmp ne i32 %11, %10
  %13 = and i32 %12, 1
  %.not2732 = icmp eq i32 %13, 0
  %or.cond33 = and i1 %.not31, %.not2732
  br i1 %or.cond33, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.02535 = phi i32 [ %15, %.lr.ph ], [ %12, %.preheader ]
  %.02634 = phi i32 [ %14, %.lr.ph ], [ 0, %.preheader ]
  %14 = add nuw nsw i32 %.02634, 1
  %15 = ashr exact i32 %.02535, 1
  %.not = icmp ne i32 %.02535, 0
  %16 = and i32 %.02535, 2
  %.not27 = icmp eq i32 %16, 0
  %or.cond = and i1 %.not, %.not27
  br i1 %or.cond, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.026.lcssa = phi i32 [ 0, %.preheader ], [ %14, %.lr.ph ]
  %17 = lshr i32 1, %.026.lcssa
  %18 = and i32 %2, %17
  %.not28 = icmp eq i32 %18, 0
  %19 = select i1 %.not28, i32 0, i32 %2
  %20 = and i32 %3, %17
  %.not28.1 = icmp eq i32 %20, 0
  %21 = select i1 %.not28.1, i32 0, i32 %3
  %spec.select.1 = xor i32 %21, %19
  %22 = and i32 %5, %17
  %.not28.2 = icmp eq i32 %22, 0
  %23 = select i1 %.not28.2, i32 0, i32 %5
  %spec.select.2 = xor i32 %23, %spec.select.1
  %24 = and i32 %7, %17
  %.not28.3 = icmp eq i32 %24, 0
  %25 = select i1 %.not28.3, i32 0, i32 %7
  %spec.select.3 = xor i32 %25, %spec.select.2
  %26 = and i32 %9, %17
  %.not28.4 = icmp eq i32 %26, 0
  %27 = select i1 %.not28.4, i32 0, i32 %9
  %spec.select.4 = xor i32 %27, %spec.select.3
  %28 = and i32 %11, %17
  %.not28.5 = icmp eq i32 %28, 0
  %29 = select i1 %.not28.5, i32 0, i32 %11
  %spec.select.5 = xor i32 %29, %spec.select.4
  %30 = xor i32 %spec.select.5, %12
  %31 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %spec.select.5)
  %32 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %31, ptr noundef nonnull @.str.4)
  %33 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %32, i32 noundef %30)
  ret i32 0
}

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

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 = { mustprogress norecurse 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 #2 = { inlinehint 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 #3 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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