; LLVM IR from tangjz/acm-icpc :: codeforces/complete (722A)

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

@hh = external dso_local global i32, align 4
@mm = external dso_local global i32, align 4
@hlim = external dso_local global i32, align 4
@mlim = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @hlim, ptr noundef @hh, ptr noundef @mm)
  %3 = load i32, ptr @hh, align 4, !tbaa !5
  %4 = load i32, ptr @hlim, align 4, !tbaa !5
  %5 = load i32, ptr @hlim, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 12
  %7 = zext i1 %6 to i32
  %8 = add nsw i32 %4, %7
  %9 = icmp sge i32 %3, %8
  br i1 %9, label %16, label %10

10:                                               ; preds = %0
  %11 = load i32, ptr @hlim, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 12
  br i1 %12, label %13, label %28

13:                                               ; preds = %10
  %14 = load i32, ptr @hh, align 4, !tbaa !5
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %28, label %16

16:                                               ; preds = %13, %0
  %17 = load i32, ptr @hlim, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 24
  br i1 %18, label %23, label %19

19:                                               ; preds = %16
  %20 = load i32, ptr @hh, align 4, !tbaa !5
  %21 = srem i32 %20, 10
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %26

23:                                               ; preds = %19, %16
  %24 = load i32, ptr @hh, align 4, !tbaa !5
  %25 = srem i32 %24, 10
  store i32 %25, ptr @hh, align 4, !tbaa !5
  br label %27

26:                                               ; preds = %19
  store i32 10, ptr @hh, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %26, %23
  br label %28

28:                                               ; preds = %27, %13, %10
  %29 = load i32, ptr @mm, align 4, !tbaa !5
  %30 = load i32, ptr @mlim, align 4, !tbaa !5
  %31 = icmp sge i32 %29, %30
  br i1 %31, label %32, label %35

32:                                               ; preds = %28
  %33 = load i32, ptr @mm, align 4, !tbaa !5
  %34 = srem i32 %33, 10
  store i32 %34, ptr @mm, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %32, %28
  %36 = load i32, ptr @hh, align 4, !tbaa !5
  %37 = load i32, ptr @mm, align 4, !tbaa !5
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %36, i32 noundef %37)
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

declare i32 @printf(ptr noundef, ...) #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 = { "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"}


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

@hh = external dso_local global i32, align 4
@mm = external dso_local global i32, align 4
@hlim = external dso_local global i32, align 4
@mlim = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @hlim, ptr noundef nonnull @hh, ptr noundef nonnull @mm)
  %2 = load i32, ptr @hh, align 4
  %3 = load i32, ptr @hlim, align 4, !tbaa !5
  %4 = icmp eq i32 %3, 12
  %5 = select i1 %4, i32 13, i32 %3
  %.not = icmp slt i32 %2, %5
  br i1 %.not, label %6, label %9

6:                                                ; preds = %0
  %7 = icmp ne i32 %3, 12
  %8 = icmp ne i32 %2, 0
  %or.cond = or i1 %8, %7
  br i1 %or.cond, label %13, label %.thread4

9:                                                ; preds = %0
  %10 = icmp eq i32 %3, 24
  %11 = srem i32 %2, 10
  %12 = icmp sgt i32 %11, 0
  %or.cond6 = or i1 %10, %12
  br i1 %or.cond6, label %.sink.split, label %.thread4

.thread4:                                         ; preds = %9, %6
  br label %.sink.split

.sink.split:                                      ; preds = %9, %.thread4
  %.sink = phi i32 [ 10, %.thread4 ], [ %11, %9 ]
  store i32 %.sink, ptr @hh, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %.sink.split, %6
  %14 = phi i32 [ %2, %6 ], [ %.sink, %.sink.split ]
  %15 = load i32, ptr @mm, align 4, !tbaa !5
  %16 = load i32, ptr @mlim, align 4, !tbaa !5
  %.not3 = icmp slt i32 %15, %16
  br i1 %.not3, label %19, label %17

17:                                               ; preds = %13
  %18 = srem i32 %15, 10
  store i32 %18, ptr @mm, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %17, %13
  %20 = phi i32 [ %18, %17 ], [ %15, %13 ]
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %14, i32 noundef %20)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree norecurse 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 = { nofree nounwind "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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass