; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/257 Division 2/Problem B (B)

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

@x = external dso_local global i64, align 8
@y = external dso_local global i64, align 8
@n = external dso_local global i64, align 8
@MOD = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3outx(i64 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %2 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) @y)
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %5 = load i64, ptr @n, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  store i64 %6, ptr @n, align 8, !tbaa !5
  %7 = load i64, ptr @n, align 8, !tbaa !5
  %8 = srem i64 %7, 6
  store i64 %8, ptr @n, align 8, !tbaa !5
  %9 = load i64, ptr @n, align 8, !tbaa !5
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %0
  %12 = load i64, ptr @x, align 8, !tbaa !5
  call void @_Z3outx(i64 noundef %12)
  br label %13

13:                                               ; preds = %11, %0
  %14 = load i64, ptr @n, align 8, !tbaa !5
  %15 = icmp eq i64 %14, 1
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = load i64, ptr @y, align 8, !tbaa !5
  call void @_Z3outx(i64 noundef %17)
  br label %18

18:                                               ; preds = %16, %13
  %19 = load i64, ptr @n, align 8, !tbaa !5
  %20 = icmp eq i64 %19, 2
  br i1 %20, label %21, label %27

21:                                               ; preds = %18
  %22 = load i64, ptr @y, align 8, !tbaa !5
  %23 = load i64, ptr @x, align 8, !tbaa !5
  %24 = sub nsw i64 %22, %23
  %25 = load i64, ptr @MOD, align 8, !tbaa !5
  %26 = add nsw i64 %24, %25
  call void @_Z3outx(i64 noundef %26)
  br label %27

27:                                               ; preds = %21, %18
  %28 = load i64, ptr @n, align 8, !tbaa !5
  %29 = icmp eq i64 %28, 3
  br i1 %29, label %30, label %34

30:                                               ; preds = %27
  %31 = load i64, ptr @MOD, align 8, !tbaa !5
  %32 = load i64, ptr @x, align 8, !tbaa !5
  %33 = sub nsw i64 %31, %32
  call void @_Z3outx(i64 noundef %33)
  br label %34

34:                                               ; preds = %30, %27
  %35 = load i64, ptr @n, align 8, !tbaa !5
  %36 = icmp eq i64 %35, 4
  br i1 %36, label %37, label %41

37:                                               ; preds = %34
  %38 = load i64, ptr @MOD, align 8, !tbaa !5
  %39 = load i64, ptr @y, align 8, !tbaa !5
  %40 = sub nsw i64 %38, %39
  call void @_Z3outx(i64 noundef %40)
  br label %41

41:                                               ; preds = %37, %34
  %42 = load i64, ptr @n, align 8, !tbaa !5
  %43 = icmp eq i64 %42, 5
  br i1 %43, label %44, label %50

44:                                               ; preds = %41
  %45 = load i64, ptr @x, align 8, !tbaa !5
  %46 = load i64, ptr @y, align 8, !tbaa !5
  %47 = sub nsw i64 %45, %46
  %48 = load i64, ptr @MOD, align 8, !tbaa !5
  %49 = add nsw i64 %47, %48
  call void @_Z3outx(i64 noundef %49)
  br label %50

50:                                               ; preds = %44, %41
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

attributes #0 = { 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 #1 = { 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" }

!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 = !{!"long long", !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"

%"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 }

@x = external dso_local global i64, align 8
@y = external dso_local global i64, align 8
@n = external dso_local global i64, align 8
@MOD = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3outx(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) @y)
  %3 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %4 = load i64, ptr @n, align 8, !tbaa !5
  %5 = add nsw i64 %4, -1
  %6 = srem i64 %5, 6
  store i64 %6, ptr @n, align 8, !tbaa !5
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %0
  %9 = load i64, ptr @x, align 8, !tbaa !5
  tail call void @_Z3outx(i64 noundef %9)
  %.pr = load i64, ptr @n, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %8, %0
  %11 = phi i64 [ %.pr, %8 ], [ %6, %0 ]
  %12 = icmp eq i64 %11, 1
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  %14 = load i64, ptr @y, align 8, !tbaa !5
  tail call void @_Z3outx(i64 noundef %14)
  %.pre = load i64, ptr @n, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %13, %10
  %16 = phi i64 [ %.pre, %13 ], [ %11, %10 ]
  %17 = icmp eq i64 %16, 2
  br i1 %17, label %18, label %24

18:                                               ; preds = %15
  %19 = load i64, ptr @y, align 8, !tbaa !5
  %20 = load i64, ptr @x, align 8, !tbaa !5
  %21 = sub i64 %19, %20
  %22 = load i64, ptr @MOD, align 8, !tbaa !5
  %23 = add nsw i64 %21, %22
  tail call void @_Z3outx(i64 noundef %23)
  %.pr1 = load i64, ptr @n, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %18, %15
  %25 = phi i64 [ %.pr1, %18 ], [ %16, %15 ]
  %26 = icmp eq i64 %25, 3
  br i1 %26, label %27, label %31

27:                                               ; preds = %24
  %28 = load i64, ptr @MOD, align 8, !tbaa !5
  %29 = load i64, ptr @x, align 8, !tbaa !5
  %30 = sub nsw i64 %28, %29
  tail call void @_Z3outx(i64 noundef %30)
  %.pre4 = load i64, ptr @n, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %27, %24
  %32 = phi i64 [ %.pre4, %27 ], [ %25, %24 ]
  %33 = icmp eq i64 %32, 4
  br i1 %33, label %34, label %38

34:                                               ; preds = %31
  %35 = load i64, ptr @MOD, align 8, !tbaa !5
  %36 = load i64, ptr @y, align 8, !tbaa !5
  %37 = sub nsw i64 %35, %36
  tail call void @_Z3outx(i64 noundef %37)
  %.pr2 = load i64, ptr @n, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %34, %31
  %39 = phi i64 [ %.pr2, %34 ], [ %32, %31 ]
  %40 = icmp eq i64 %39, 5
  br i1 %40, label %41, label %47

41:                                               ; preds = %38
  %42 = load i64, ptr @x, align 8, !tbaa !5
  %43 = load i64, ptr @y, align 8, !tbaa !5
  %44 = sub i64 %42, %43
  %45 = load i64, ptr @MOD, align 8, !tbaa !5
  %46 = add nsw i64 %44, %45
  tail call void @_Z3outx(i64 noundef %46)
  br label %47

47:                                               ; preds = %41, %38
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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" }

!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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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