; LLVM IR from tangjz/acm-icpc :: codeforces/gym (100624H)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [4 x i8], align 1

; 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 @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @t)
  br label %4

4:                                                ; preds = %42, %0
  %5 = load i32, ptr @t, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @t, align 4, !tbaa !5
  %7 = icmp ne i32 %5, 0
  br i1 %7, label %8, label %45

8:                                                ; preds = %4
  store i32 0, ptr @ans, align 4, !tbaa !5
  call void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  br label %9

9:                                                ; preds = %41, %8
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @n, align 4, !tbaa !5
  %12 = icmp ne i32 %10, 0
  br i1 %12, label %13, label %42

13:                                               ; preds = %9
  call void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @x)
  call void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @y)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %37, %13
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp sle i32 %15, 10
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 6, ptr %3, align 4
  br label %40

18:                                               ; preds = %14
  %19 = load i32, ptr @x, align 4, !tbaa !5
  %20 = load i32, ptr @x, align 4, !tbaa !5
  %21 = mul nsw i32 %19, %20
  %22 = load i32, ptr @y, align 4, !tbaa !5
  %23 = load i32, ptr @y, align 4, !tbaa !5
  %24 = mul nsw i32 %22, %23
  %25 = add nsw i32 %21, %24
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = mul nsw i32 400, %26
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = mul nsw i32 %27, %28
  %30 = icmp sle i32 %25, %29
  br i1 %30, label %31, label %36

31:                                               ; preds = %18
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sub nsw i32 11, %32
  %34 = load i32, ptr @ans, align 4, !tbaa !5
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr @ans, align 4, !tbaa !5
  store i32 6, ptr %3, align 4
  br label %40

36:                                               ; preds = %18
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

40:                                               ; preds = %31, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %41

41:                                               ; preds = %40
  br label %9, !llvm.loop !11

42:                                               ; preds = %9
  %43 = load i32, ptr @ans, align 4, !tbaa !5
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %43)
  br label %4, !llvm.loop !12

45:                                               ; preds = %4
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #1

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

declare i32 @printf(ptr noundef, ...) #3

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 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 = { "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 = { 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"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @t)
  %1 = load i32, ptr @t, align 4, !tbaa !5
  %2 = add nsw i32 %1, -1
  store i32 %2, ptr @t, align 4, !tbaa !5
  %.not10 = icmp eq i32 %1, 0
  br i1 %.not10, label %._crit_edge13, label %.lr.ph12

.lr.ph12:                                         ; preds = %0, %._crit_edge
  store i32 0, ptr @ans, align 4, !tbaa !5
  tail call void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = add nsw i32 %3, -1
  store i32 %4, ptr @n, align 4, !tbaa !5
  %.not59 = icmp eq i32 %3, 0
  br i1 %.not59, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph12, %.loopexit
  tail call void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @x)
  tail call void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @y)
  %5 = load i32, ptr @x, align 4, !tbaa !5
  %6 = mul nsw i32 %5, %5
  %7 = load i32, ptr @y, align 4, !tbaa !5
  %8 = mul nsw i32 %7, %7
  %9 = add nuw nsw i32 %8, %6
  %.not6 = icmp ugt i32 %9, 400
  br i1 %.not6, label %13, label %10

10:                                               ; preds = %21, %20, %19, %18, %17, %16, %15, %14, %13, %.lr.ph
  %.08.lcssa.neg = phi i32 [ -1, %.lr.ph ], [ -2, %13 ], [ -3, %14 ], [ -4, %15 ], [ -5, %16 ], [ -6, %17 ], [ -7, %18 ], [ -8, %19 ], [ -9, %20 ], [ -10, %21 ]
  %11 = load i32, ptr @ans, align 4, !tbaa !5
  %reass.sub14 = add i32 %.08.lcssa.neg, %11
  %12 = add i32 %reass.sub14, 11
  store i32 %12, ptr @ans, align 4, !tbaa !5
  br label %.loopexit

13:                                               ; preds = %.lr.ph
  %.not6.1 = icmp ugt i32 %9, 1600
  br i1 %.not6.1, label %14, label %10

14:                                               ; preds = %13
  %.not6.2 = icmp ugt i32 %9, 3600
  br i1 %.not6.2, label %15, label %10

15:                                               ; preds = %14
  %.not6.3 = icmp ugt i32 %9, 6400
  br i1 %.not6.3, label %16, label %10

16:                                               ; preds = %15
  %.not6.4 = icmp ugt i32 %9, 10000
  br i1 %.not6.4, label %17, label %10

17:                                               ; preds = %16
  %.not6.5 = icmp ugt i32 %9, 14400
  br i1 %.not6.5, label %18, label %10

18:                                               ; preds = %17
  %.not6.6 = icmp ugt i32 %9, 19600
  br i1 %.not6.6, label %19, label %10

19:                                               ; preds = %18
  %.not6.7 = icmp ugt i32 %9, 25600
  br i1 %.not6.7, label %20, label %10

20:                                               ; preds = %19
  %.not6.8 = icmp ugt i32 %9, 32400
  br i1 %.not6.8, label %21, label %10

21:                                               ; preds = %20
  %.not6.9 = icmp ugt i32 %9, 40000
  br i1 %.not6.9, label %.loopexit, label %10

.loopexit:                                        ; preds = %21, %10
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr @n, align 4, !tbaa !5
  %.not5 = icmp eq i32 %22, 0
  br i1 %.not5, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.loopexit, %.lr.ph12
  %24 = load i32, ptr @ans, align 4, !tbaa !5
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %24)
  %26 = load i32, ptr @t, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %26, 0
  br i1 %.not, label %._crit_edge13, label %.lr.ph12, !llvm.loop !11

._crit_edge13:                                    ; preds = %._crit_edge, %0
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 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 = { 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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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