; LLVM IR from eyangch/competitive-programming :: Codeforces/1550 (d)

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

@MOD = external dso_local global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@L = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@fact = external dso_local global [300000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3nCrxx(i64 noundef, i64 noundef) #1

; 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
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %20 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %21 = getelementptr i8, ptr %20, i64 -24
  %22 = load i64, ptr %21, align 8
  %23 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %22
  %24 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %23, ptr noundef null)
  %25 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  store i64 1, ptr @fact, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #7
  store i64 1, ptr %2, align 8, !tbaa !8
  br label %26

26:                                               ; preds = %41, %0
  %27 = load i64, ptr %2, align 8, !tbaa !8
  %28 = icmp slt i64 %27, 300000
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %44

30:                                               ; preds = %26
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = load i64, ptr %2, align 8, !tbaa !8
  %33 = sub nsw i64 %32, 1
  %34 = getelementptr inbounds [300000 x i64], ptr @fact, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !8
  %36 = mul nsw i64 %31, %35
  %37 = load i64, ptr @MOD, align 8, !tbaa !8
  %38 = srem i64 %36, %37
  %39 = load i64, ptr %2, align 8, !tbaa !8
  %40 = getelementptr inbounds [300000 x i64], ptr @fact, i64 0, i64 %39
  store i64 %38, ptr %40, align 8, !tbaa !8
  br label %41

41:                                               ; preds = %30
  %42 = load i64, ptr %2, align 8, !tbaa !8
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %2, align 8, !tbaa !8
  br label %26, !llvm.loop !11

44:                                               ; preds = %29
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  br label %46

46:                                               ; preds = %166, %44
  %47 = load i64, ptr @T, align 8, !tbaa !8
  %48 = add nsw i64 %47, -1
  store i64 %48, ptr @T, align 8, !tbaa !8
  %49 = icmp ne i64 %47, 0
  br i1 %49, label %50, label %170

50:                                               ; preds = %46
  %51 = 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)
  %52 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %51, ptr noundef nonnull align 8 dereferenceable(8) @L)
  %53 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %52, ptr noundef nonnull align 8 dereferenceable(8) @R)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  %54 = load i64, ptr @N, align 8, !tbaa !8
  %55 = sdiv i64 %54, 2
  store i64 %55, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %56 = load i64, ptr @R, align 8, !tbaa !8
  %57 = load i64, ptr @N, align 8, !tbaa !8
  %58 = sub nsw i64 %56, %57
  store i64 %58, ptr %5, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %59 = load i64, ptr @L, align 8, !tbaa !8
  %60 = sub nsw i64 1, %59
  store i64 %60, ptr %6, align 8, !tbaa !8
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = load i64, ptr @N, align 8, !tbaa !8
  %64 = load i64, ptr %3, align 8, !tbaa !8
  %65 = call noundef i64 @_Z3nCrxx(i64 noundef %63, i64 noundef %64)
  %66 = load i64, ptr @N, align 8, !tbaa !8
  %67 = srem i64 %66, 2
  %68 = load i64, ptr @N, align 8, !tbaa !8
  %69 = load i64, ptr %3, align 8, !tbaa !8
  %70 = add nsw i64 %69, 1
  %71 = call noundef i64 @_Z3nCrxx(i64 noundef %68, i64 noundef %70)
  %72 = mul nsw i64 %67, %71
  %73 = add nsw i64 %65, %72
  %74 = mul nsw i64 %62, %73
  %75 = load i64, ptr @MOD, align 8, !tbaa !8
  %76 = srem i64 %74, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  store i64 %76, ptr %4, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %77 = load i64, ptr @R, align 8, !tbaa !8
  %78 = load i64, ptr @N, align 8, !tbaa !8
  %79 = sub nsw i64 %77, %78
  store i64 %79, ptr %8, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %80 = load i64, ptr @L, align 8, !tbaa !8
  %81 = sub nsw i64 1, %80
  store i64 %81, ptr %9, align 8, !tbaa !8
  %82 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %83 = load i64, ptr %82, align 8, !tbaa !8
  %84 = add nsw i64 %83, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  store i64 %84, ptr %7, align 8, !tbaa !8
  br label %85

85:                                               ; preds = %162, %50
  br i1 true, label %87, label %86

86:                                               ; preds = %85
  store i32 7, ptr %10, align 4
  br label %165

87:                                               ; preds = %85
  %88 = load i64, ptr %7, align 8, !tbaa !8
  %89 = add nsw i64 %88, 1
  %90 = load i64, ptr @R, align 8, !tbaa !8
  %91 = icmp sgt i64 %89, %90
  br i1 %91, label %98, label %92

92:                                               ; preds = %87
  %93 = load i64, ptr @N, align 8, !tbaa !8
  %94 = load i64, ptr %7, align 8, !tbaa !8
  %95 = sub nsw i64 %93, %94
  %96 = load i64, ptr @L, align 8, !tbaa !8
  %97 = icmp slt i64 %95, %96
  br i1 %97, label %98, label %99

98:                                               ; preds = %92, %87
  store i32 7, ptr %10, align 4
  br label %165

99:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %100 = load i64, ptr @R, align 8, !tbaa !8
  %101 = load i64, ptr %7, align 8, !tbaa !8
  %102 = sub nsw i64 %100, %101
  store i64 %102, ptr %12, align 8, !tbaa !8
  %103 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %104 = load i64, ptr %103, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  store i64 %104, ptr %11, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store i64 1, ptr %14, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %105 = load i64, ptr @L, align 8, !tbaa !8
  %106 = load i64, ptr %7, align 8, !tbaa !8
  %107 = add nsw i64 %105, %106
  store i64 %107, ptr %15, align 8, !tbaa !8
  %108 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %15)
  %109 = load i64, ptr %108, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  store i64 %109, ptr %13, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %110 = load i64, ptr %11, align 8, !tbaa !8
  %111 = load i64, ptr %13, align 8, !tbaa !8
  %112 = sub nsw i64 %110, %111
  %113 = add nsw i64 %112, 1
  store i64 %113, ptr %16, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %114 = load i64, ptr @N, align 8, !tbaa !8
  %115 = load i64, ptr %11, align 8, !tbaa !8
  %116 = sub nsw i64 %114, %115
  store i64 %116, ptr %17, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %117 = load i64, ptr %3, align 8, !tbaa !8
  %118 = load i64, ptr %17, align 8, !tbaa !8
  %119 = sub nsw i64 %117, %118
  store i64 %119, ptr %18, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %120 = load i64, ptr %3, align 8, !tbaa !8
  %121 = load i64, ptr @N, align 8, !tbaa !8
  %122 = srem i64 %121, 2
  %123 = add nsw i64 %120, %122
  %124 = load i64, ptr %17, align 8, !tbaa !8
  %125 = sub nsw i64 %123, %124
  store i64 %125, ptr %19, align 8, !tbaa !8
  %126 = load i64, ptr %18, align 8, !tbaa !8
  %127 = load i64, ptr %16, align 8, !tbaa !8
  %128 = icmp sgt i64 %126, %127
  br i1 %128, label %129, label %130

129:                                              ; preds = %99
  store i32 7, ptr %10, align 4
  br label %159

130:                                              ; preds = %99
  %131 = load i64, ptr %19, align 8, !tbaa !8
  %132 = icmp slt i64 %131, 0
  br i1 %132, label %133, label %134

133:                                              ; preds = %130
  store i32 7, ptr %10, align 4
  br label %159

134:                                              ; preds = %130
  %135 = load i64, ptr %16, align 8, !tbaa !8
  %136 = load i64, ptr %18, align 8, !tbaa !8
  %137 = call noundef i64 @_Z3nCrxx(i64 noundef %135, i64 noundef %136)
  %138 = load i64, ptr %4, align 8, !tbaa !8
  %139 = add nsw i64 %138, %137
  store i64 %139, ptr %4, align 8, !tbaa !8
  %140 = load i64, ptr @N, align 8, !tbaa !8
  %141 = srem i64 %140, 2
  %142 = icmp ne i64 %141, 0
  br i1 %142, label %143, label %149

143:                                              ; preds = %134
  %144 = load i64, ptr %16, align 8, !tbaa !8
  %145 = load i64, ptr %19, align 8, !tbaa !8
  %146 = call noundef i64 @_Z3nCrxx(i64 noundef %144, i64 noundef %145)
  %147 = load i64, ptr %4, align 8, !tbaa !8
  %148 = add nsw i64 %147, %146
  store i64 %148, ptr %4, align 8, !tbaa !8
  br label %149

149:                                              ; preds = %143, %134
  br label %150

150:                                              ; preds = %154, %149
  %151 = load i64, ptr %4, align 8, !tbaa !8
  %152 = load i64, ptr @MOD, align 8, !tbaa !8
  %153 = icmp sge i64 %151, %152
  br i1 %153, label %154, label %158

154:                                              ; preds = %150
  %155 = load i64, ptr @MOD, align 8, !tbaa !8
  %156 = load i64, ptr %4, align 8, !tbaa !8
  %157 = sub nsw i64 %156, %155
  store i64 %157, ptr %4, align 8, !tbaa !8
  br label %150, !llvm.loop !13

158:                                              ; preds = %150
  store i32 0, ptr %10, align 4
  br label %159

159:                                              ; preds = %158, %133, %129
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  %160 = load i32, ptr %10, align 4
  switch i32 %160, label %165 [
    i32 0, label %161
  ]

161:                                              ; preds = %159
  br label %162

162:                                              ; preds = %161
  %163 = load i64, ptr %7, align 8, !tbaa !8
  %164 = add nsw i64 %163, 1
  store i64 %164, ptr %7, align 8, !tbaa !8
  br label %85, !llvm.loop !14

165:                                              ; preds = %159, %98, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %166

166:                                              ; preds = %165
  %167 = load i64, ptr %4, align 8, !tbaa !8
  %168 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %167)
  %169 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %168, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %46, !llvm.loop !15

170:                                              ; preds = %46
  %171 = load i32, ptr %1, align 4
  ret i32 %171
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #6

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 = { 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 = { 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 #6 = { 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 #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !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"

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

@MOD = external dso_local local_unnamed_addr global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@L = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@fact = external dso_local local_unnamed_addr global [300000 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3nCrxx(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %10
  %12 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  %13 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  store i64 1, ptr @fact, align 16, !tbaa !8
  %14 = load i64, ptr @MOD, align 8, !tbaa !8
  br label %19

15:                                               ; preds = %19
  %16 = 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) @T)
  %17 = load i64, ptr @T, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr @T, align 8, !tbaa !8
  %.not55 = icmp eq i64 %17, 0
  br i1 %.not55, label %._crit_edge, label %.lr.ph56

19:                                               ; preds = %25, %0
  %20 = phi i64 [ 1, %0 ], [ %27, %25 ]
  %.046 = phi i64 [ 1, %0 ], [ %29, %25 ]
  %21 = mul nsw i64 %20, %.046
  %22 = srem i64 %21, %14
  %23 = getelementptr inbounds [300000 x i64], ptr @fact, i64 0, i64 %.046
  store i64 %22, ptr %23, align 8, !tbaa !8
  %24 = add nuw nsw i64 %.046, 1
  %exitcond.not = icmp eq i64 %24, 300000
  br i1 %exitcond.not, label %15, label %25, !llvm.loop !11

25:                                               ; preds = %19
  %26 = mul nsw i64 %22, %24
  %27 = srem i64 %26, %14
  %28 = getelementptr inbounds [300000 x i64], ptr @fact, i64 0, i64 %24
  store i64 %27, ptr %28, align 8, !tbaa !8
  %29 = add nuw nsw i64 %.046, 2
  br label %19

.lr.ph56:                                         ; preds = %15, %.thread
  %30 = 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)
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 8 dereferenceable(8) @L)
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %31, ptr noundef nonnull align 8 dereferenceable(8) @R)
  %33 = load i64, ptr @N, align 8, !tbaa !8
  %34 = sdiv i64 %33, 2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %35 = load i64, ptr @R, align 8, !tbaa !8
  %36 = sub nsw i64 %35, %33
  store i64 %36, ptr %1, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %37 = load i64, ptr @L, align 8, !tbaa !8
  %38 = sub nsw i64 1, %37
  store i64 %38, ptr %2, align 8, !tbaa !8
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = load i64, ptr @N, align 8, !tbaa !8
  %42 = call noundef i64 @_Z3nCrxx(i64 noundef %41, i64 noundef %34)
  %43 = load i64, ptr @N, align 8, !tbaa !8
  %44 = srem i64 %43, 2
  %45 = add nsw i64 %34, 1
  %46 = call noundef i64 @_Z3nCrxx(i64 noundef %43, i64 noundef %45)
  %47 = mul nsw i64 %44, %46
  %48 = add nsw i64 %47, %42
  %49 = mul nsw i64 %48, %40
  %50 = load i64, ptr @MOD, align 8, !tbaa !8
  %51 = srem i64 %49, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %52 = load i64, ptr @R, align 8, !tbaa !8
  %53 = load i64, ptr @N, align 8, !tbaa !8
  %54 = sub nsw i64 %52, %53
  store i64 %54, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %55 = load i64, ptr @L, align 8, !tbaa !8
  %56 = sub nsw i64 1, %55
  store i64 %56, ptr %4, align 8, !tbaa !8
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %58 = load i64, ptr %57, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %.03447 = add nsw i64 %58, 1
  %59 = load i64, ptr @R, align 8, !tbaa !8
  %.not4148 = icmp slt i64 %.03447, %59
  br i1 %.not4148, label %.lr.ph.preheader, label %.thread

.lr.ph.preheader:                                 ; preds = %.lr.ph56
  %.pre57 = load i64, ptr @N, align 8, !tbaa !8
  br label %.lr.ph

.loopexit:                                        ; preds = %95
  %.034 = add nsw i64 %.03450, 1
  %60 = load i64, ptr @R, align 8, !tbaa !8
  %.not41 = icmp slt i64 %.034, %60
  br i1 %.not41, label %.lr.ph, label %.thread, !llvm.loop !13

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.loopexit
  %61 = phi i64 [ %93, %.loopexit ], [ %.pre57, %.lr.ph.preheader ]
  %62 = phi i64 [ %60, %.loopexit ], [ %59, %.lr.ph.preheader ]
  %.03450 = phi i64 [ %.034, %.loopexit ], [ %.03447, %.lr.ph.preheader ]
  %.03349 = phi i64 [ %.2, %.loopexit ], [ %51, %.lr.ph.preheader ]
  %63 = sub nsw i64 %61, %.03450
  %64 = load i64, ptr @L, align 8, !tbaa !8
  %65 = icmp slt i64 %63, %64
  br i1 %65, label %.thread, label %66

66:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %67 = sub nsw i64 %62, %.03450
  store i64 %67, ptr %5, align 8, !tbaa !8
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %69 = load i64, ptr %68, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i64 1, ptr %6, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  %70 = load i64, ptr @L, align 8, !tbaa !8
  %71 = add nsw i64 %70, %.03450
  store i64 %71, ptr %7, align 8, !tbaa !8
  %72 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %73 = load i64, ptr %72, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  %74 = sub nsw i64 %69, %73
  %75 = add nsw i64 %74, 1
  %76 = load i64, ptr @N, align 8, !tbaa !8
  %77 = sub nsw i64 %76, %69
  %78 = sub nsw i64 %34, %77
  %79 = srem i64 %76, 2
  %80 = add nsw i64 %79, %34
  %81 = sub i64 %80, %77
  %82 = icmp sgt i64 %78, %75
  %83 = icmp slt i64 %81, 0
  %or.cond = select i1 %82, i1 true, i1 %83
  br i1 %or.cond, label %.thread, label %84

84:                                               ; preds = %66
  %85 = call noundef i64 @_Z3nCrxx(i64 noundef %75, i64 noundef %78)
  %86 = add nsw i64 %85, %.03349
  %87 = load i64, ptr @N, align 8, !tbaa !8
  %88 = and i64 %87, 1
  %.not42 = icmp eq i64 %88, 0
  br i1 %.not42, label %92, label %89

89:                                               ; preds = %84
  %90 = call noundef i64 @_Z3nCrxx(i64 noundef %75, i64 noundef %81)
  %91 = add nsw i64 %90, %86
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  br label %92

92:                                               ; preds = %89, %84
  %93 = phi i64 [ %.pre, %89 ], [ %87, %84 ]
  %.1 = phi i64 [ %91, %89 ], [ %86, %84 ]
  %94 = load i64, ptr @MOD, align 8, !tbaa !8
  br label %95

95:                                               ; preds = %95, %92
  %.2 = phi i64 [ %.1, %92 ], [ %96, %95 ]
  %.not43 = icmp slt i64 %.2, %94
  %96 = sub nsw i64 %.2, %94
  br i1 %.not43, label %.loopexit, label %95, !llvm.loop !14

.thread:                                          ; preds = %.lr.ph, %.loopexit, %66, %.lr.ph56
  %.033.lcssa = phi i64 [ %51, %.lr.ph56 ], [ %.03349, %66 ], [ %.2, %.loopexit ], [ %.03349, %.lr.ph ]
  %97 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.033.lcssa)
  %98 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %97, i8 noundef signext 10)
  %99 = load i64, ptr @T, align 8, !tbaa !8
  %100 = add nsw i64 %99, -1
  store i64 %100, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %99, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph56, !llvm.loop !15

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

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #6

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 = { 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 = { 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 #6 = { 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 #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !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: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass