; LLVM IR from MinaFaried3/Assiut-University-Training---Newcomers :: l-sheet9_general_medium (L-Announcement!)

; 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_istream" = type { ptr, i64, %"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@counts = external dso_local global [100001 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %7 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %8, i64 8)
  %10 = extractvalue { i64, i1 } %9, 1
  %11 = extractvalue { i64, i1 } %9, 0
  %12 = select i1 %10, i64 -1, i64 %11
  %13 = call noalias noundef nonnull ptr @_Znam(i64 noundef %12) #7
  store ptr %13, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %31, %0
  %15 = load i64, ptr %4, align 8, !tbaa !5
  %16 = load i64, ptr %2, align 8, !tbaa !5
  %17 = icmp slt i64 %15, %16
  br i1 %17, label %19, label %18

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

19:                                               ; preds = %14
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = load i64, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %20, i64 %21
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %22)
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds i64, ptr %24, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %28 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = add nsw i64 %29, 1
  store i64 %30, ptr %28, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %19
  %32 = load i64, ptr %4, align 8, !tbaa !5
  %33 = add nsw i64 %32, 1
  store i64 %33, ptr %4, align 8, !tbaa !5
  br label %14, !llvm.loop !11

34:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %64, %34
  %36 = load i64, ptr %6, align 8, !tbaa !5
  %37 = load i64, ptr %2, align 8, !tbaa !5
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %67

40:                                               ; preds = %35
  %41 = load ptr, ptr %3, align 8, !tbaa !9
  %42 = load i64, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds i64, ptr %41, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %47 = icmp sgt i64 %46, 1
  br i1 %47, label %48, label %63

48:                                               ; preds = %40
  %49 = load ptr, ptr %3, align 8, !tbaa !9
  %50 = load i64, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds i64, ptr %49, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !5
  %53 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !5
  %55 = sub nsw i64 %54, 1
  %56 = load i64, ptr %5, align 8, !tbaa !5
  %57 = add nsw i64 %56, %55
  store i64 %57, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %3, align 8, !tbaa !9
  %59 = load i64, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds i64, ptr %58, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %61
  store i64 0, ptr %62, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %48, %40
  br label %64

64:                                               ; preds = %63
  %65 = load i64, ptr %6, align 8, !tbaa !5
  %66 = add nsw i64 %65, 1
  store i64 %66, ptr %6, align 8, !tbaa !5
  br label %35, !llvm.loop !13

67:                                               ; preds = %39
  %68 = load i64, ptr %5, align 8, !tbaa !5
  %69 = icmp eq i64 %68, 0
  br i1 %69, label %70, label %72

70:                                               ; preds = %67
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  br label %75

72:                                               ; preds = %67
  %73 = load i64, ptr %5, align 8, !tbaa !5
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %73)
  br label %75

75:                                               ; preds = %72, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  %76 = load i32, ptr %1, align 4
  ret i32 %76
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #2 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nobuiltin allocsize(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 }
attributes #7 = { builtin allocsize(0) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

%"class.std::basic_istream" = type { ptr, i64, %"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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@counts = external dso_local local_unnamed_addr global [100001 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = icmp ugt i64 %3, 2305843009213693951
  %5 = shl i64 %3, 3
  %6 = select i1 %4, i64 -1, i64 %5
  %7 = call noalias noundef nonnull ptr @_Znam(i64 noundef %6) #6
  %8 = icmp sgt i64 %3, 0
  br i1 %8, label %.lr.ph, label %._crit_edge.thread

.preheader:                                       ; preds = %.lr.ph
  %9 = icmp sgt i64 %18, 0
  br i1 %9, label %.lr.ph23.preheader, label %._crit_edge.thread

.lr.ph23.preheader:                               ; preds = %.preheader
  %xtraiter = and i64 %18, 1
  %10 = icmp eq i64 %18, 1
  br i1 %10, label %._crit_edge.unr-lcssa, label %.lr.ph23.preheader.new

.lr.ph23.preheader.new:                           ; preds = %.lr.ph23.preheader
  %unroll_iter = and i64 %18, 9223372036854775806
  br label %.lr.ph23

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01820 = phi i64 [ %17, %.lr.ph ], [ 0, %0 ]
  %11 = getelementptr inbounds i64, ptr %7, i64 %.01820
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %13 = load i64, ptr %11, align 8, !tbaa !5
  %14 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = add nsw i64 %15, 1
  store i64 %16, ptr %14, align 8, !tbaa !5
  %17 = add nuw nsw i64 %.01820, 1
  %18 = load i64, ptr %1, align 8, !tbaa !5
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge.unr-lcssa:                            ; preds = %46, %.lr.ph23.preheader
  %.1.lcssa.ph = phi i64 [ poison, %.lr.ph23.preheader ], [ %.1.1, %46 ]
  %.022.unr = phi i64 [ 0, %.lr.ph23.preheader ], [ %47, %46 ]
  %.01721.unr = phi i64 [ 0, %.lr.ph23.preheader ], [ %.1.1, %46 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph23.epil

.lr.ph23.epil:                                    ; preds = %._crit_edge.unr-lcssa
  %20 = getelementptr inbounds i64, ptr %7, i64 %.022.unr
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = icmp sgt i64 %23, 1
  br i1 %24, label %25, label %._crit_edge

25:                                               ; preds = %.lr.ph23.epil
  %26 = add i64 %.01721.unr, -1
  %27 = add i64 %26, %23
  store i64 0, ptr %22, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph23.epil, %25, %._crit_edge.unr-lcssa
  %.1.lcssa = phi i64 [ %.1.lcssa.ph, %._crit_edge.unr-lcssa ], [ %27, %25 ], [ %.01721.unr, %.lr.ph23.epil ]
  %28 = icmp eq i64 %.1.lcssa, 0
  br i1 %28, label %._crit_edge.thread, label %49

.lr.ph23:                                         ; preds = %46, %.lr.ph23.preheader.new
  %.022 = phi i64 [ 0, %.lr.ph23.preheader.new ], [ %47, %46 ]
  %.01721 = phi i64 [ 0, %.lr.ph23.preheader.new ], [ %.1.1, %46 ]
  %niter = phi i64 [ 0, %.lr.ph23.preheader.new ], [ %niter.next.1, %46 ]
  %29 = getelementptr inbounds i64, ptr %7, i64 %.022
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !5
  %33 = icmp sgt i64 %32, 1
  br i1 %33, label %34, label %.lr.ph23.1

34:                                               ; preds = %.lr.ph23
  %35 = add i64 %.01721, -1
  %36 = add i64 %35, %32
  store i64 0, ptr %31, align 8, !tbaa !5
  br label %.lr.ph23.1

.lr.ph23.1:                                       ; preds = %.lr.ph23, %34
  %.1 = phi i64 [ %36, %34 ], [ %.01721, %.lr.ph23 ]
  %37 = or disjoint i64 %.022, 1
  %38 = getelementptr inbounds i64, ptr %7, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds [100001 x i64], ptr @counts, i64 0, i64 %39
  %41 = load i64, ptr %40, align 8, !tbaa !5
  %42 = icmp sgt i64 %41, 1
  br i1 %42, label %43, label %46

43:                                               ; preds = %.lr.ph23.1
  %44 = add i64 %.1, -1
  %45 = add i64 %44, %41
  store i64 0, ptr %40, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %43, %.lr.ph23.1
  %.1.1 = phi i64 [ %45, %43 ], [ %.1, %.lr.ph23.1 ]
  %47 = add nuw nsw i64 %.022, 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.ph23, !llvm.loop !11

._crit_edge.thread:                               ; preds = %0, %.preheader, %._crit_edge
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  br label %51

49:                                               ; preds = %._crit_edge
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.1.lcssa)
  br label %51

51:                                               ; preds = %49, %._crit_edge.thread
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 0
}

; 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 uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) 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

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nobuiltin allocsize(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 = { "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 = { nounwind }
attributes #6 = { builtin allocsize(0) }

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


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