; LLVM IR from Tunghohin/Competitive_Coding :: Codeforces/cf1526_B.ll (Z5solvev)

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  %4 = 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)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %22, %0
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 11
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  store i32 2, ptr %3, align 4
  br label %25

9:                                                ; preds = %5
  %10 = load i64, ptr %1, align 8, !tbaa !9
  %11 = srem i64 %10, 11
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %13, label %15

13:                                               ; preds = %9
  %14 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  store i32 1, ptr %3, align 4
  br label %25

15:                                               ; preds = %9
  %16 = load i64, ptr %1, align 8, !tbaa !9
  %17 = sub nsw i64 %16, 111
  store i64 %17, ptr %1, align 8, !tbaa !9
  %18 = load i64, ptr %1, align 8, !tbaa !9
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %15
  store i32 2, ptr %3, align 4
  br label %25

21:                                               ; preds = %15
  br label %22

22:                                               ; preds = %21
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !11

25:                                               ; preds = %20, %13, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %26 = load i32, ptr %3, align 4
  switch i32 %26, label %29 [
    i32 2, label %27
  ]

27:                                               ; preds = %25
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
  store i32 0, ptr %3, align 4
  br label %29

29:                                               ; preds = %27, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  %30 = load i32, ptr %3, align 4
  switch i32 %30, label %32 [
    i32 0, label %31
    i32 1, label %31
  ]

31:                                               ; preds = %29, %29
  ret void

32:                                               ; preds = %29
  unreachable
}

; 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)) #0 align 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) #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 = { 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 = { 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"}


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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %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)
  %.promoted = load i64, ptr %1, align 8, !tbaa !5
  %3 = srem i64 %.promoted, 11
  %4 = icmp eq i64 %3, 0
  br i1 %4, label %.critedge, label %64

5:                                                ; preds = %64
  %6 = urem i64 %65, 11
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %.critedge, label %8

8:                                                ; preds = %5
  %9 = add nsw i64 %.promoted, -222
  store i64 %9, ptr %1, align 8, !tbaa !5
  %10 = icmp ult i64 %.promoted, 222
  br i1 %10, label %.critedge, label %11

11:                                               ; preds = %8
  %12 = urem i64 %9, 11
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %.critedge, label %14

14:                                               ; preds = %11
  %15 = add nsw i64 %.promoted, -333
  store i64 %15, ptr %1, align 8, !tbaa !5
  %16 = icmp ult i64 %.promoted, 333
  br i1 %16, label %.critedge, label %17

17:                                               ; preds = %14
  %18 = urem i64 %15, 11
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %.critedge, label %20

20:                                               ; preds = %17
  %21 = add nsw i64 %.promoted, -444
  store i64 %21, ptr %1, align 8, !tbaa !5
  %22 = icmp ult i64 %.promoted, 444
  br i1 %22, label %.critedge, label %23

23:                                               ; preds = %20
  %24 = urem i64 %21, 11
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %.critedge, label %26

26:                                               ; preds = %23
  %27 = add nsw i64 %.promoted, -555
  store i64 %27, ptr %1, align 8, !tbaa !5
  %28 = icmp ult i64 %.promoted, 555
  br i1 %28, label %.critedge, label %29

29:                                               ; preds = %26
  %30 = urem i64 %27, 11
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %.critedge, label %32

32:                                               ; preds = %29
  %33 = add nsw i64 %.promoted, -666
  store i64 %33, ptr %1, align 8, !tbaa !5
  %34 = icmp ult i64 %.promoted, 666
  br i1 %34, label %.critedge, label %35

35:                                               ; preds = %32
  %36 = urem i64 %33, 11
  %37 = icmp eq i64 %36, 0
  br i1 %37, label %.critedge, label %38

38:                                               ; preds = %35
  %39 = add nsw i64 %.promoted, -777
  store i64 %39, ptr %1, align 8, !tbaa !5
  %40 = icmp ult i64 %.promoted, 777
  br i1 %40, label %.critedge, label %41

41:                                               ; preds = %38
  %42 = urem i64 %39, 11
  %43 = icmp eq i64 %42, 0
  br i1 %43, label %.critedge, label %44

44:                                               ; preds = %41
  %45 = add nsw i64 %.promoted, -888
  store i64 %45, ptr %1, align 8, !tbaa !5
  %46 = icmp ult i64 %.promoted, 888
  br i1 %46, label %.critedge, label %47

47:                                               ; preds = %44
  %48 = urem i64 %45, 11
  %49 = icmp eq i64 %48, 0
  br i1 %49, label %.critedge, label %50

50:                                               ; preds = %47
  %51 = add nsw i64 %.promoted, -999
  store i64 %51, ptr %1, align 8, !tbaa !5
  %52 = icmp ult i64 %.promoted, 999
  br i1 %52, label %.critedge, label %53

53:                                               ; preds = %50
  %54 = urem i64 %51, 11
  %55 = icmp eq i64 %54, 0
  br i1 %55, label %.critedge, label %56

56:                                               ; preds = %53
  %57 = add nsw i64 %.promoted, -1110
  store i64 %57, ptr %1, align 8, !tbaa !5
  %58 = icmp ult i64 %.promoted, 1110
  br i1 %58, label %.critedge, label %59

59:                                               ; preds = %56
  %60 = urem i64 %57, 11
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %.critedge, label %62

62:                                               ; preds = %59
  %63 = add nsw i64 %.promoted, -1221
  store i64 %63, ptr %1, align 8, !tbaa !5
  br label %.critedge

64:                                               ; preds = %0
  %65 = add nsw i64 %.promoted, -111
  store i64 %65, ptr %1, align 8, !tbaa !5
  %66 = icmp slt i64 %.promoted, 111
  br i1 %66, label %.critedge, label %5

.critedge:                                        ; preds = %64, %8, %14, %20, %26, %32, %38, %44, %50, %56, %62, %0, %5, %11, %17, %23, %29, %35, %41, %47, %53, %59
  %.str.sink = phi ptr [ @.str, %59 ], [ @.str, %53 ], [ @.str, %47 ], [ @.str, %41 ], [ @.str, %35 ], [ @.str, %29 ], [ @.str, %23 ], [ @.str, %17 ], [ @.str, %11 ], [ @.str, %5 ], [ @.str, %0 ], [ @.str.1, %62 ], [ @.str.1, %56 ], [ @.str.1, %50 ], [ @.str.1, %44 ], [ @.str.1, %38 ], [ @.str.1, %32 ], [ @.str.1, %26 ], [ @.str.1, %20 ], [ @.str.1, %14 ], [ @.str.1, %8 ], [ @.str.1, %64 ]
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull %.str.sink)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret void
}

; 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 #0 align 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) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass