; LLVM IR from tangjz/acm-icpc :: lydsy (5118)

; 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 i64, align 8
@v = external dso_local global i64, align 8
@x = external dso_local global i64, align 8
@y = external dso_local global i64, align 8
@a = external dso_local global i64, align 8
@b = external dso_local global i64, align 8
@c = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %4

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

8:                                                ; preds = %4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @y)
  store i64 1, ptr @n, align 8, !tbaa !9
  store i64 2, ptr @x, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %24, %8
  %11 = load i64, ptr @y, align 8, !tbaa !9
  %12 = icmp ne i64 %11, 0
  br i1 %12, label %13, label %30

13:                                               ; preds = %10
  %14 = load i64, ptr @y, align 8, !tbaa !9
  %15 = and i64 %14, 1
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %17, label %22

17:                                               ; preds = %13
  %18 = load i64, ptr @n, align 8, !tbaa !9
  %19 = load i64, ptr @x, align 8, !tbaa !9
  %20 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %18, i64 noundef %19, i64 noundef 1125899839733758)
  store i64 %20, ptr @n, align 8, !tbaa !9
  %21 = icmp ne i64 %20, 0
  br label %22

22:                                               ; preds = %17, %13
  %23 = phi i1 [ false, %13 ], [ %21, %17 ]
  br label %24

24:                                               ; preds = %22
  %25 = load i64, ptr @y, align 8, !tbaa !9
  %26 = ashr i64 %25, 1
  store i64 %26, ptr @y, align 8, !tbaa !9
  %27 = load i64, ptr @x, align 8, !tbaa !9
  %28 = load i64, ptr @x, align 8, !tbaa !9
  %29 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %27, i64 noundef %28, i64 noundef 1125899839733758)
  store i64 %29, ptr @x, align 8, !tbaa !9
  br label %10, !llvm.loop !11

30:                                               ; preds = %10
  store i64 1, ptr @v, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %36, %30
  %32 = load i64, ptr @v, align 8, !tbaa !9
  %33 = load i64, ptr @n, align 8, !tbaa !9
  %34 = icmp sle i64 %32, %33
  br i1 %34, label %35, label %39

35:                                               ; preds = %31
  br label %36

36:                                               ; preds = %35
  %37 = load i64, ptr @v, align 8, !tbaa !9
  %38 = shl i64 %37, 1
  store i64 %38, ptr @v, align 8, !tbaa !9
  br label %31, !llvm.loop !13

39:                                               ; preds = %31
  store i64 1, ptr @x, align 8, !tbaa !9
  store i64 0, ptr @y, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %80, %39
  %41 = load i64, ptr @v, align 8, !tbaa !9
  %42 = ashr i64 %41, 1
  store i64 %42, ptr @v, align 8, !tbaa !9
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %44, label %81

44:                                               ; preds = %40
  %45 = load i64, ptr @x, align 8, !tbaa !9
  %46 = icmp ne i64 %45, 1
  br i1 %46, label %50, label %47

47:                                               ; preds = %44
  %48 = load i64, ptr @y, align 8, !tbaa !9
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %50, label %69

50:                                               ; preds = %47, %44
  %51 = load i64, ptr @x, align 8, !tbaa !9
  store i64 %51, ptr @a, align 8, !tbaa !9
  %52 = load i64, ptr @y, align 8, !tbaa !9
  store i64 %52, ptr @b, align 8, !tbaa !9
  %53 = load i64, ptr @b, align 8, !tbaa !9
  %54 = load i64, ptr @b, align 8, !tbaa !9
  %55 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %53, i64 noundef %54, i64 noundef 1125899839733759)
  store i64 %55, ptr @c, align 8, !tbaa !9
  %56 = load i64, ptr @a, align 8, !tbaa !9
  %57 = load i64, ptr @a, align 8, !tbaa !9
  %58 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %56, i64 noundef %57, i64 noundef 1125899839733759)
  %59 = load i64, ptr @c, align 8, !tbaa !9
  %60 = call noundef i64 @_Z7mod_addxxx(i64 noundef %58, i64 noundef %59, i64 noundef 1125899839733759)
  store i64 %60, ptr @x, align 8, !tbaa !9
  %61 = load i64, ptr @a, align 8, !tbaa !9
  %62 = load i64, ptr @b, align 8, !tbaa !9
  %63 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %61, i64 noundef %62, i64 noundef 1125899839733759)
  store i64 %63, ptr @y, align 8, !tbaa !9
  %64 = load i64, ptr @y, align 8, !tbaa !9
  %65 = load i64, ptr @y, align 8, !tbaa !9
  %66 = call noundef i64 @_Z7mod_addxxx(i64 noundef %64, i64 noundef %65, i64 noundef 1125899839733759)
  %67 = load i64, ptr @c, align 8, !tbaa !9
  %68 = call noundef i64 @_Z7mod_addxxx(i64 noundef %66, i64 noundef %67, i64 noundef 1125899839733759)
  store i64 %68, ptr @y, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %50, %47
  %70 = load i64, ptr @n, align 8, !tbaa !9
  %71 = load i64, ptr @v, align 8, !tbaa !9
  %72 = and i64 %70, %71
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %80

74:                                               ; preds = %69
  %75 = load i64, ptr @x, align 8, !tbaa !9
  %76 = load i64, ptr @y, align 8, !tbaa !9
  %77 = call noundef i64 @_Z7mod_addxxx(i64 noundef %75, i64 noundef %76, i64 noundef 1125899839733759)
  store i64 %77, ptr @c, align 8, !tbaa !9
  %78 = load i64, ptr @y, align 8, !tbaa !9
  store i64 %78, ptr @x, align 8, !tbaa !9
  %79 = load i64, ptr @c, align 8, !tbaa !9
  store i64 %79, ptr @y, align 8, !tbaa !9
  br label %80

80:                                               ; preds = %74, %69
  br label %40, !llvm.loop !14

81:                                               ; preds = %40
  %82 = load i64, ptr @y, align 8, !tbaa !9
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %82)
  br label %4, !llvm.loop !15

84:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7mod_mulxxx(i64 noundef, i64 noundef, i64 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7mod_addxxx(i64 noundef, i64 noundef, i64 noundef) #3

declare i32 @printf(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 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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; 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 local_unnamed_addr global i64, align 8
@v = external dso_local local_unnamed_addr global i64, align 8
@x = external dso_local local_unnamed_addr global i64, align 8
@y = external dso_local global i64, align 8
@a = external dso_local local_unnamed_addr global i64, align 8
@b = external dso_local local_unnamed_addr global i64, align 8
@c = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind 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) #4
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = add nsw i32 %3, -1
  store i32 %4, ptr %1, align 4, !tbaa !5
  %.not13 = icmp eq i32 %3, 0
  br i1 %.not13, label %._crit_edge16, label %.lr.ph15

.lr.ph15:                                         ; preds = %0, %._crit_edge
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @y)
  store i64 1, ptr @n, align 8, !tbaa !9
  store i64 2, ptr @x, align 8, !tbaa !9
  %6 = load i64, ptr @y, align 8, !tbaa !9
  %.not39 = icmp eq i64 %6, 0
  br i1 %.not39, label %.preheader, label %.lr.ph

.preheader.loopexit:                              ; preds = %13
  %.pre18 = load i64, ptr @n, align 8, !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.lr.ph15
  %7 = phi i64 [ %.pre18, %.preheader.loopexit ], [ 1, %.lr.ph15 ]
  br label %19

.lr.ph:                                           ; preds = %.lr.ph15, %13
  %8 = phi i64 [ %18, %13 ], [ %6, %.lr.ph15 ]
  %storemerge10 = phi i64 [ %17, %13 ], [ 2, %.lr.ph15 ]
  %9 = and i64 %8, 1
  %.not8 = icmp eq i64 %9, 0
  br i1 %.not8, label %13, label %10

10:                                               ; preds = %.lr.ph
  %11 = load i64, ptr @n, align 8, !tbaa !9
  %12 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %11, i64 noundef %storemerge10, i64 noundef 1125899839733758)
  store i64 %12, ptr @n, align 8, !tbaa !9
  %.pre = load i64, ptr @y, align 8, !tbaa !9
  %.pre17 = load i64, ptr @x, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %.lr.ph, %10
  %14 = phi i64 [ %storemerge10, %.lr.ph ], [ %.pre17, %10 ]
  %15 = phi i64 [ %8, %.lr.ph ], [ %.pre, %10 ]
  %16 = ashr i64 %15, 1
  store i64 %16, ptr @y, align 8, !tbaa !9
  %17 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %14, i64 noundef %14, i64 noundef 1125899839733758)
  store i64 %17, ptr @x, align 8, !tbaa !9
  %18 = load i64, ptr @y, align 8, !tbaa !9
  %.not3 = icmp eq i64 %18, 0
  br i1 %.not3, label %.preheader.loopexit, label %.lr.ph, !llvm.loop !11

19:                                               ; preds = %19, %.preheader
  %storemerge4 = phi i64 [ %20, %19 ], [ 1, %.preheader ]
  %.not5 = icmp sgt i64 %storemerge4, %7
  %20 = shl i64 %storemerge4, 1
  br i1 %.not5, label %21, label %19, !llvm.loop !13

21:                                               ; preds = %19
  store i64 1, ptr @x, align 8, !tbaa !9
  store i64 0, ptr @y, align 8, !tbaa !9
  %22 = ashr i64 %storemerge4, 1
  store i64 %22, ptr @v, align 8, !tbaa !9
  %.not611 = icmp ult i64 %storemerge4, 2
  br i1 %.not611, label %._crit_edge, label %.lr.ph12

.lr.ph12:                                         ; preds = %21, %53
  %23 = phi i64 [ %55, %53 ], [ 0, %21 ]
  %24 = phi i64 [ %56, %53 ], [ 1, %21 ]
  %25 = phi i64 [ %59, %53 ], [ %22, %21 ]
  %26 = phi i64 [ %57, %53 ], [ 0, %21 ]
  %27 = phi i64 [ %58, %53 ], [ 1, %21 ]
  %28 = icmp ne i64 %27, 1
  %29 = icmp ne i64 %26, 0
  %or.cond = or i1 %28, %29
  br i1 %or.cond, label %30, label %42

30:                                               ; preds = %.lr.ph12
  store i64 %27, ptr @a, align 8, !tbaa !9
  store i64 %26, ptr @b, align 8, !tbaa !9
  %31 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %26, i64 noundef %26, i64 noundef 1125899839733759)
  store i64 %31, ptr @c, align 8, !tbaa !9
  %32 = load i64, ptr @a, align 8, !tbaa !9
  %33 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %32, i64 noundef %32, i64 noundef 1125899839733759)
  %34 = load i64, ptr @c, align 8, !tbaa !9
  %35 = call noundef i64 @_Z7mod_addxxx(i64 noundef %33, i64 noundef %34, i64 noundef 1125899839733759)
  store i64 %35, ptr @x, align 8, !tbaa !9
  %36 = load i64, ptr @a, align 8, !tbaa !9
  %37 = load i64, ptr @b, align 8, !tbaa !9
  %38 = call noundef i64 @_Z7mod_mulxxx(i64 noundef %36, i64 noundef %37, i64 noundef 1125899839733759)
  store i64 %38, ptr @y, align 8, !tbaa !9
  %39 = call noundef i64 @_Z7mod_addxxx(i64 noundef %38, i64 noundef %38, i64 noundef 1125899839733759)
  %40 = load i64, ptr @c, align 8, !tbaa !9
  %41 = call noundef i64 @_Z7mod_addxxx(i64 noundef %39, i64 noundef %40, i64 noundef 1125899839733759)
  store i64 %41, ptr @y, align 8, !tbaa !9
  %.pre19 = load i64, ptr @x, align 8, !tbaa !9
  %.pre21 = load i64, ptr @v, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %.lr.ph12, %30
  %43 = phi i64 [ %23, %.lr.ph12 ], [ %41, %30 ]
  %44 = phi i64 [ %24, %.lr.ph12 ], [ %.pre19, %30 ]
  %45 = phi i64 [ %25, %.lr.ph12 ], [ %.pre21, %30 ]
  %46 = phi i64 [ 0, %.lr.ph12 ], [ %41, %30 ]
  %47 = phi i64 [ 1, %.lr.ph12 ], [ %.pre19, %30 ]
  %48 = load i64, ptr @n, align 8, !tbaa !9
  %49 = and i64 %45, %48
  %.not7 = icmp eq i64 %49, 0
  br i1 %.not7, label %53, label %50

50:                                               ; preds = %42
  %51 = call noundef i64 @_Z7mod_addxxx(i64 noundef %44, i64 noundef %43, i64 noundef 1125899839733759)
  store i64 %51, ptr @c, align 8, !tbaa !9
  %52 = load i64, ptr @y, align 8, !tbaa !9
  store i64 %52, ptr @x, align 8, !tbaa !9
  store i64 %51, ptr @y, align 8, !tbaa !9
  %.pre22 = load i64, ptr @v, align 8, !tbaa !9
  br label %53

53:                                               ; preds = %50, %42
  %54 = phi i64 [ %.pre22, %50 ], [ %45, %42 ]
  %55 = phi i64 [ %51, %50 ], [ %43, %42 ]
  %56 = phi i64 [ %52, %50 ], [ %44, %42 ]
  %57 = phi i64 [ %51, %50 ], [ %46, %42 ]
  %58 = phi i64 [ %52, %50 ], [ %47, %42 ]
  %59 = ashr i64 %54, 1
  store i64 %59, ptr @v, align 8, !tbaa !9
  %.not6 = icmp ult i64 %54, 2
  br i1 %.not6, label %._crit_edge, label %.lr.ph12, !llvm.loop !14

._crit_edge:                                      ; preds = %53, %21
  %60 = phi i64 [ 0, %21 ], [ %55, %53 ]
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %60)
  %62 = load i32, ptr %1, align 4, !tbaa !5
  %63 = add nsw i32 %62, -1
  store i32 %63, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %62, 0
  br i1 %.not, label %._crit_edge16, label %.lr.ph15, !llvm.loop !15

._crit_edge16:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7mod_mulxxx(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z7mod_addxxx(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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