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

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

@n = external dso_local global i32, align 4
@x0 = external dso_local global i32, align 4
@x1 = external dso_local global i32, align 4
@x2 = external dso_local global i32, align 4
@x3 = external dso_local global i32, align 4
@y0 = external dso_local global i32, align 4
@y1 = external dso_local global i32, align 4
@y2 = external dso_local global i32, align 4
@y3 = external dso_local global i32, align 4
@sum = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 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
  store i32 0, ptr %1, align 4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %4

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

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

9:                                                ; preds = %4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @x1, ptr noundef @y1, ptr noundef @x2, ptr noundef @y2)
  %11 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @x0, ptr noundef nonnull align 4 dereferenceable(4) @x1)
  %12 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %12, ptr @x0, align 4, !tbaa !5
  %13 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @x3, ptr noundef nonnull align 4 dereferenceable(4) @x2)
  %14 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %14, ptr @x3, align 4, !tbaa !5
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @y0, ptr noundef nonnull align 4 dereferenceable(4) @y1)
  %16 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %16, ptr @y0, align 4, !tbaa !5
  %17 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @y3, ptr noundef nonnull align 4 dereferenceable(4) @y2)
  %18 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %18, ptr @y3, align 4, !tbaa !5
  %19 = load i32, ptr @x2, align 4, !tbaa !5
  %20 = load i32, ptr @x1, align 4, !tbaa !5
  %21 = sub nsw i32 %19, %20
  %22 = load i32, ptr @y2, align 4, !tbaa !5
  %23 = load i32, ptr @y1, align 4, !tbaa !5
  %24 = sub nsw i32 %22, %23
  %25 = mul nsw i32 %21, %24
  %26 = load i32, ptr @sum, align 4, !tbaa !5
  %27 = add nsw i32 %26, %25
  store i32 %27, ptr @sum, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %9
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !5
  br label %4, !llvm.loop !9

31:                                               ; preds = %8
  %32 = load i32, ptr @x3, align 4, !tbaa !5
  %33 = load i32, ptr @x0, align 4, !tbaa !5
  %34 = sub nsw i32 %32, %33
  %35 = load i32, ptr @y3, align 4, !tbaa !5
  %36 = load i32, ptr @y0, align 4, !tbaa !5
  %37 = sub nsw i32 %35, %36
  %38 = icmp eq i32 %34, %37
  br i1 %38, label %39, label %51

39:                                               ; preds = %31
  %40 = load i32, ptr @sum, align 4, !tbaa !5
  %41 = load i32, ptr @x3, align 4, !tbaa !5
  %42 = load i32, ptr @x0, align 4, !tbaa !5
  %43 = sub nsw i32 %41, %42
  %44 = load i32, ptr @y3, align 4, !tbaa !5
  %45 = load i32, ptr @y0, align 4, !tbaa !5
  %46 = sub nsw i32 %44, %45
  %47 = mul nsw i32 %43, %46
  %48 = icmp eq i32 %40, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %39
  %50 = call i32 @puts(ptr noundef @.str.2)
  br label %53

51:                                               ; preds = %39, %31
  %52 = call i32 @puts(ptr noundef @.str.3)
  br label %53

53:                                               ; preds = %51, %49
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

declare i32 @puts(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" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 #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"}


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

@n = external dso_local global i32, align 4
@x0 = external dso_local global i32, align 4
@x1 = external dso_local global i32, align 4
@x2 = external dso_local global i32, align 4
@x3 = external dso_local global i32, align 4
@y0 = external dso_local global i32, align 4
@y1 = external dso_local global i32, align 4
@y2 = external dso_local global i32, align 4
@y3 = external dso_local global i32, align 4
@sum = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress 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 @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = load i32, ptr @y3, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %4 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %19, %.lr.ph ]
  %5 = load i32, ptr @x3, align 4, !tbaa !5
  %6 = load i32, ptr @x0, align 4, !tbaa !5
  %7 = sub nsw i32 %5, %6
  %8 = load i32, ptr @y0, align 4, !tbaa !5
  %9 = sub nsw i32 %4, %8
  %10 = icmp eq i32 %7, %9
  br i1 %10, label %32, label %36

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.04 = phi i32 [ %29, %.lr.ph ], [ 0, %0 ]
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @x1, ptr noundef nonnull @y1, ptr noundef nonnull @x2, ptr noundef nonnull @y2)
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @x0, ptr noundef nonnull align 4 dereferenceable(4) @x1)
  %13 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %13, ptr @x0, align 4, !tbaa !5
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @x3, ptr noundef nonnull align 4 dereferenceable(4) @x2)
  %15 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %15, ptr @x3, align 4, !tbaa !5
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @y0, ptr noundef nonnull align 4 dereferenceable(4) @y1)
  %17 = load i32, ptr %16, align 4, !tbaa !5
  store i32 %17, ptr @y0, align 4, !tbaa !5
  %18 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @y3, ptr noundef nonnull align 4 dereferenceable(4) @y2)
  %19 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %19, ptr @y3, align 4, !tbaa !5
  %20 = load i32, ptr @x2, align 4, !tbaa !5
  %21 = load i32, ptr @x1, align 4, !tbaa !5
  %22 = sub nsw i32 %20, %21
  %23 = load i32, ptr @y2, align 4, !tbaa !5
  %24 = load i32, ptr @y1, align 4, !tbaa !5
  %25 = sub nsw i32 %23, %24
  %26 = mul nsw i32 %25, %22
  %27 = load i32, ptr @sum, align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  store i32 %28, ptr @sum, align 4, !tbaa !5
  %29 = add nuw nsw i32 %.04, 1
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !9

32:                                               ; preds = %._crit_edge
  %33 = load i32, ptr @sum, align 4, !tbaa !5
  %34 = mul nsw i32 %7, %7
  %35 = icmp eq i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32, %._crit_edge
  br label %37

37:                                               ; preds = %32, %36
  %.str.3.sink = phi ptr [ @.str.3, %36 ], [ @.str.2, %32 ]
  %38 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

attributes #0 = { mustprogress 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" }
attributes #2 = { inlinehint mustprogress 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" }

!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: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass