; LLVM IR from seikhchilli/codeforces-solution :: Hit_the_Lottery (main)

; 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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %41, %31, %21, %11, %0
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %53

8:                                                ; preds = %5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp sge i32 %9, 100
  br i1 %10, label %11, label %18

11:                                               ; preds = %8
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = sdiv i32 %12, 100
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = add nsw i32 %14, %13
  store i32 %15, ptr %3, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = srem i32 %16, 100
  store i32 %17, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !9

18:                                               ; preds = %8
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = icmp sge i32 %19, 20
  br i1 %20, label %21, label %28

21:                                               ; preds = %18
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sdiv i32 %22, 20
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = add nsw i32 %24, %23
  store i32 %25, ptr %3, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = srem i32 %26, 20
  store i32 %27, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !9

28:                                               ; preds = %18
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = icmp sge i32 %29, 10
  br i1 %30, label %31, label %38

31:                                               ; preds = %28
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sdiv i32 %32, 10
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr %3, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = srem i32 %36, 10
  store i32 %37, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !9

38:                                               ; preds = %28
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = icmp sge i32 %39, 5
  br i1 %40, label %41, label %48

41:                                               ; preds = %38
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sdiv i32 %42, 5
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = add nsw i32 %44, %43
  store i32 %45, ptr %3, align 4, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = srem i32 %46, 5
  store i32 %47, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !9

48:                                               ; preds = %38
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sdiv i32 %49, 1
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = add nsw i32 %51, %50
  store i32 %52, ptr %3, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %48, %5
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %54)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %56 = load i32, ptr %1, align 4
  ret i32 %56
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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 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 = { "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 = distinct !{!9, !10}
!10 = !{!"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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #3
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %.pr = load i32, ptr %1, align 4, !tbaa !5
  %.not12 = icmp eq i32 %.pr, 0
  br i1 %.not12, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.backedge
  %.013 = phi i32 [ %.0.be, %.backedge ], [ 0, %0 ]
  %3 = phi i32 [ %.be, %.backedge ], [ %.pr, %0 ]
  %4 = icmp sgt i32 %3, 99
  br i1 %4, label %5, label %9

5:                                                ; preds = %.lr.ph
  %6 = udiv i32 %3, 100
  %7 = add nsw i32 %.013, %6
  %8 = urem i32 %3, 100
  store i32 %8, ptr %1, align 4, !tbaa !5
  br label %.backedge

.backedge:                                        ; preds = %5, %11, %17, %22
  %.be = phi i32 [ %24, %22 ], [ %19, %17 ], [ %.zext9, %11 ], [ %8, %5 ]
  %.0.be = phi i32 [ %23, %22 ], [ %18, %17 ], [ %13, %11 ], [ %7, %5 ]
  %.not = icmp eq i32 %.be, 0
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !9

9:                                                ; preds = %.lr.ph
  %10 = icmp sgt i32 %3, 19
  br i1 %10, label %11, label %15

11:                                               ; preds = %9
  %.lhs.trunc = trunc i32 %3 to i8
  %12 = udiv i8 %.lhs.trunc, 20
  %.zext = zext nneg i8 %12 to i32
  %13 = add nsw i32 %.013, %.zext
  %14 = urem i8 %.lhs.trunc, 20
  %.zext9 = zext nneg i8 %14 to i32
  store i32 %.zext9, ptr %1, align 4, !tbaa !5
  br label %.backedge

15:                                               ; preds = %9
  %16 = icmp sgt i32 %3, 9
  br i1 %16, label %17, label %20

17:                                               ; preds = %15
  %18 = add nsw i32 %.013, 1
  %19 = add nsw i32 %3, -10
  store i32 %19, ptr %1, align 4, !tbaa !5
  br label %.backedge

20:                                               ; preds = %15
  %21 = icmp sgt i32 %3, 4
  br i1 %21, label %22, label %25

22:                                               ; preds = %20
  %23 = add nsw i32 %.013, 1
  %24 = add nsw i32 %3, -5
  store i32 %24, ptr %1, align 4, !tbaa !5
  br label %.backedge

25:                                               ; preds = %20
  %26 = add nsw i32 %.013, %3
  br label %.loopexit

.loopexit:                                        ; preds = %.backedge, %0, %25
  %.1 = phi i32 [ %26, %25 ], [ 0, %0 ], [ %.0.be, %.backedge ]
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) 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 #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 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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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