; LLVM IR from kazunetakahashi/atcoder :: 2018/0428_AGC023 (C)

; 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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@fact = external dso_local global [2000010 x i64], align 16
@N = external dso_local global i64, align 8
@Ika = external dso_local global [2000010 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z1Cii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @_Z4initv()
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  store i64 0, ptr getelementptr inbounds ([2000010 x i64], ptr @Ika, i64 0, i64 1), align 8, !tbaa !5
  store i64 0, ptr @Ika, align 16, !tbaa !5
  %7 = load i64, ptr @N, align 8, !tbaa !5
  %8 = icmp eq i64 %7, 2
  br i1 %8, label %9, label %12

9:                                                ; preds = %0
  %10 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 1)
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  br label %87

12:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 2, ptr %2, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %52, %12
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = load i64, ptr @N, align 8, !tbaa !5
  %16 = sub nsw i64 %15, 1
  %17 = icmp sle i64 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  br label %55

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %20 = load i64, ptr @N, align 8, !tbaa !5
  %21 = sub nsw i64 %20, 1
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = sub nsw i64 %21, %22
  store i64 %23, ptr %3, align 8, !tbaa !5
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = icmp sge i64 %24, 0
  br i1 %25, label %26, label %51

26:                                               ; preds = %19
  %27 = load i64, ptr %2, align 8, !tbaa !5
  %28 = icmp sge i64 %27, 0
  br i1 %28, label %29, label %51

29:                                               ; preds = %26
  %30 = load i64, ptr %2, align 8, !tbaa !5
  %31 = sub nsw i64 %30, 1
  %32 = trunc i64 %31 to i32
  %33 = load i64, ptr @N, align 8, !tbaa !5
  %34 = sub nsw i64 %33, 1
  %35 = load i64, ptr %2, align 8, !tbaa !5
  %36 = sub nsw i64 %34, %35
  %37 = trunc i64 %36 to i32
  %38 = call noundef i64 @_Z1Cii(i32 noundef %32, i32 noundef %37)
  %39 = load i64, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds [2000010 x i64], ptr @fact, i64 0, i64 %39
  %41 = load i64, ptr %40, align 8, !tbaa !5
  %42 = mul nsw i64 %38, %41
  %43 = srem i64 %42, 1000000007
  %44 = load i64, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds [2000010 x i64], ptr @fact, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %47 = mul nsw i64 %43, %46
  %48 = srem i64 %47, 1000000007
  %49 = load i64, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds [2000010 x i64], ptr @Ika, i64 0, i64 %49
  store i64 %48, ptr %50, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %29, %26, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %52

52:                                               ; preds = %51
  %53 = load i64, ptr %2, align 8, !tbaa !5
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %2, align 8, !tbaa !5
  br label %13, !llvm.loop !9

55:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 1, ptr %5, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %80, %55
  %57 = load i64, ptr %5, align 8, !tbaa !5
  %58 = load i64, ptr @N, align 8, !tbaa !5
  %59 = sub nsw i64 %58, 1
  %60 = icmp sle i64 %57, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %83

62:                                               ; preds = %56
  %63 = load i64, ptr %5, align 8, !tbaa !5
  %64 = load i64, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds [2000010 x i64], ptr @Ika, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %67 = add nsw i64 %66, 1000000007
  %68 = load i64, ptr %5, align 8, !tbaa !5
  %69 = sub nsw i64 %68, 1
  %70 = getelementptr inbounds [2000010 x i64], ptr @Ika, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !5
  %72 = sub nsw i64 %67, %71
  %73 = srem i64 %72, 1000000007
  %74 = mul nsw i64 %63, %73
  %75 = srem i64 %74, 1000000007
  %76 = load i64, ptr %4, align 8, !tbaa !5
  %77 = add nsw i64 %76, %75
  store i64 %77, ptr %4, align 8, !tbaa !5
  %78 = load i64, ptr %4, align 8, !tbaa !5
  %79 = srem i64 %78, 1000000007
  store i64 %79, ptr %4, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %62
  %81 = load i64, ptr %5, align 8, !tbaa !5
  %82 = add nsw i64 %81, 1
  store i64 %82, ptr %5, align 8, !tbaa !5
  br label %56, !llvm.loop !11

83:                                               ; preds = %61
  %84 = load i64, ptr %4, align 8, !tbaa !5
  %85 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %84)
  %86 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %85, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %87

87:                                               ; preds = %83, %9
  %88 = load i32, ptr %1, align 4
  ret i32 %88
}

; 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)) #3 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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 #5 = { inlinehint 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 #6 = { 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 = !{!"long long", !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}


; 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 }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@fact = external dso_local local_unnamed_addr global [2000010 x i64], align 16
@N = external dso_local global i64, align 8
@Ika = external dso_local local_unnamed_addr global [2000010 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z1Cii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  tail call void @_Z4initv()
  %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) @N)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) @Ika, i8 0, i64 16, i1 false)
  %2 = load i64, ptr @N, align 8, !tbaa !5
  %3 = icmp eq i64 %2, 2
  br i1 %3, label %4, label %.preheader26

.preheader26:                                     ; preds = %0
  %.not.not27 = icmp sgt i64 %2, 2
  br i1 %.not.not27, label %.lr.ph, label %._crit_edge

4:                                                ; preds = %0
  %5 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 1)
  br label %39

.preheader:                                       ; preds = %24
  %.not.not2529 = icmp sgt i64 %25, 1
  br i1 %.not.not2529, label %.lr.ph32.preheader, label %._crit_edge

.lr.ph32.preheader:                               ; preds = %.preheader
  %.pre36 = load i64, ptr @Ika, align 16, !tbaa !5
  br label %.lr.ph32

.lr.ph:                                           ; preds = %.preheader26, %24
  %6 = phi i64 [ %25, %24 ], [ %2, %.preheader26 ]
  %.02228 = phi i64 [ %26, %24 ], [ 2, %.preheader26 ]
  %7 = xor i64 %.02228, -1
  %8 = add i64 %6, %7
  %9 = icmp sgt i64 %8, -1
  br i1 %9, label %10, label %24

10:                                               ; preds = %.lr.ph
  %11 = trunc i64 %.02228 to i32
  %12 = add i32 %11, -1
  %13 = trunc i64 %8 to i32
  %14 = tail call noundef i64 @_Z1Cii(i32 noundef %12, i32 noundef %13)
  %15 = getelementptr inbounds [2000010 x i64], ptr @fact, i64 0, i64 %8
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = mul nsw i64 %16, %14
  %18 = srem i64 %17, 1000000007
  %19 = getelementptr inbounds [2000010 x i64], ptr @fact, i64 0, i64 %.02228
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = mul nsw i64 %18, %20
  %22 = srem i64 %21, 1000000007
  %23 = getelementptr inbounds [2000010 x i64], ptr @Ika, i64 0, i64 %.02228
  store i64 %22, ptr %23, align 8, !tbaa !5
  %.pre = load i64, ptr @N, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %10, %.lr.ph
  %25 = phi i64 [ %.pre, %10 ], [ %6, %.lr.ph ]
  %26 = add nuw nsw i64 %.02228, 1
  %.not.not = icmp slt i64 %26, %25
  br i1 %.not.not, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph32, %.preheader26, %.preheader
  %.020.lcssa = phi i64 [ 0, %.preheader ], [ 0, %.preheader26 ], [ %37, %.lr.ph32 ]
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.020.lcssa)
  br label %39

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %.lr.ph32
  %28 = phi i64 [ %30, %.lr.ph32 ], [ %.pre36, %.lr.ph32.preheader ]
  %.031 = phi i64 [ %38, %.lr.ph32 ], [ 1, %.lr.ph32.preheader ]
  %.02030 = phi i64 [ %37, %.lr.ph32 ], [ 0, %.lr.ph32.preheader ]
  %29 = getelementptr inbounds [2000010 x i64], ptr @Ika, i64 0, i64 %.031
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = add nsw i64 %30, 1000000007
  %32 = sub i64 %31, %28
  %33 = srem i64 %32, 1000000007
  %34 = mul nsw i64 %33, %.031
  %35 = srem i64 %34, 1000000007
  %36 = add nsw i64 %35, %.02030
  %37 = srem i64 %36, 1000000007
  %38 = add nuw nsw i64 %.031, 1
  %exitcond.not = icmp eq i64 %38, %25
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph32, !llvm.loop !11

39:                                               ; preds = %._crit_edge, %4
  %.sink = phi ptr [ %27, %._crit_edge ], [ %5, %4 ]
  %40 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %.sink, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  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 #2 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { 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 #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" }
attributes #2 = { 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 #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 = { inlinehint 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass