; LLVM IR from abeaumont/competitive-programming :: cses (1716)

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

@M = external dso_local global i64, align 8
@f = external dso_local global [2000000 x i64], align 16
@inv = external dso_local global [2000000 x i64], align 16
@invf = external dso_local global [2000000 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 norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %10 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %11 = getelementptr i8, ptr %10, i64 -24
  %12 = load i64, ptr %11, align 8
  %13 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %12
  %14 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %13, ptr noundef null)
  %15 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 1, ptr getelementptr inbounds ([2000000 x i64], ptr @f, i64 0, i64 1), align 8, !tbaa !8
  store i64 1, ptr @f, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 2, ptr %4, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %39, %0
  %19 = load i32, ptr %4, align 4, !tbaa !11
  %20 = load i32, ptr %2, align 4, !tbaa !11
  %21 = load i32, ptr %3, align 4, !tbaa !11
  %22 = add nsw i32 %20, %21
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %42

25:                                               ; preds = %18
  %26 = load i32, ptr %4, align 4, !tbaa !11
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2000000 x i64], ptr @f, i64 0, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !8
  %31 = load i32, ptr %4, align 4, !tbaa !11
  %32 = sext i32 %31 to i64
  %33 = mul nsw i64 %30, %32
  %34 = load i64, ptr @M, align 8, !tbaa !8
  %35 = srem i64 %33, %34
  %36 = load i32, ptr %4, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [2000000 x i64], ptr @f, i64 0, i64 %37
  store i64 %35, ptr %38, align 8, !tbaa !8
  br label %39

39:                                               ; preds = %25
  %40 = load i32, ptr %4, align 4, !tbaa !11
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %4, align 4, !tbaa !11
  br label %18, !llvm.loop !13

42:                                               ; preds = %24
  store i64 1, ptr getelementptr inbounds ([2000000 x i64], ptr @inv, i64 0, i64 1), align 8, !tbaa !8
  store i64 1, ptr @inv, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 2, ptr %5, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %70, %42
  %44 = load i32, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %45 = load i32, ptr %2, align 4, !tbaa !11
  %46 = sub nsw i32 %45, 1
  store i32 %46, ptr %6, align 4, !tbaa !11
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = icmp sle i32 %44, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br i1 %49, label %51, label %50

50:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %73

51:                                               ; preds = %43
  %52 = load i64, ptr @M, align 8, !tbaa !8
  %53 = load i64, ptr @M, align 8, !tbaa !8
  %54 = load i32, ptr %5, align 4, !tbaa !11
  %55 = sext i32 %54 to i64
  %56 = sdiv i64 %53, %55
  %57 = load i64, ptr @M, align 8, !tbaa !8
  %58 = load i32, ptr %5, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = srem i64 %57, %59
  %61 = getelementptr inbounds [2000000 x i64], ptr @inv, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = mul nsw i64 %56, %62
  %64 = load i64, ptr @M, align 8, !tbaa !8
  %65 = srem i64 %63, %64
  %66 = sub nsw i64 %52, %65
  %67 = load i32, ptr %5, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2000000 x i64], ptr @inv, i64 0, i64 %68
  store i64 %66, ptr %69, align 8, !tbaa !8
  br label %70

70:                                               ; preds = %51
  %71 = load i32, ptr %5, align 4, !tbaa !11
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %5, align 4, !tbaa !11
  br label %43, !llvm.loop !15

73:                                               ; preds = %50
  store i64 1, ptr @invf, align 16, !tbaa !8
  store i64 1, ptr getelementptr inbounds ([2000000 x i64], ptr @invf, i64 0, i64 1), align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 2, ptr %7, align 4, !tbaa !11
  br label %74

74:                                               ; preds = %98, %73
  %75 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %76 = load i32, ptr %2, align 4, !tbaa !11
  %77 = sub nsw i32 %76, 1
  store i32 %77, ptr %8, align 4, !tbaa !11
  %78 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %79 = load i32, ptr %78, align 4, !tbaa !11
  %80 = icmp sle i32 %75, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br i1 %80, label %82, label %81

81:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %101

82:                                               ; preds = %74
  %83 = load i32, ptr %7, align 4, !tbaa !11
  %84 = sub nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !8
  %88 = load i32, ptr %7, align 4, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [2000000 x i64], ptr @inv, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !8
  %92 = mul nsw i64 %87, %91
  %93 = load i64, ptr @M, align 8, !tbaa !8
  %94 = srem i64 %92, %93
  %95 = load i32, ptr %7, align 4, !tbaa !11
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %96
  store i64 %94, ptr %97, align 8, !tbaa !8
  br label %98

98:                                               ; preds = %82
  %99 = load i32, ptr %7, align 4, !tbaa !11
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %7, align 4, !tbaa !11
  br label %74, !llvm.loop !16

101:                                              ; preds = %81
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %102 = load i32, ptr %2, align 4, !tbaa !11
  %103 = load i32, ptr %3, align 4, !tbaa !11
  %104 = add nsw i32 %102, %103
  %105 = sub nsw i32 %104, 1
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [2000000 x i64], ptr @f, i64 0, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !8
  %109 = load i32, ptr %3, align 4, !tbaa !11
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !8
  %113 = mul nsw i64 %108, %112
  %114 = load i64, ptr @M, align 8, !tbaa !8
  %115 = srem i64 %113, %114
  %116 = load i32, ptr %2, align 4, !tbaa !11
  %117 = sub nsw i32 %116, 1
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !8
  %121 = mul nsw i64 %115, %120
  %122 = load i64, ptr @M, align 8, !tbaa !8
  %123 = srem i64 %121, %122
  store i64 %123, ptr %9, align 8, !tbaa !8
  %124 = load i64, ptr %9, align 8, !tbaa !8
  %125 = icmp slt i64 %124, 0
  br i1 %125, label %126, label %130

126:                                              ; preds = %101
  %127 = load i64, ptr @M, align 8, !tbaa !8
  %128 = load i64, ptr %9, align 8, !tbaa !8
  %129 = add nsw i64 %128, %127
  store i64 %129, ptr %9, align 8, !tbaa !8
  br label %130

130:                                              ; preds = %126, %101
  %131 = load i64, ptr %9, align 8, !tbaa !8
  %132 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %131)
  %133 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %132, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %134 = load i32, ptr %1, align 4
  ret i32 %134
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), 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)) #4

; 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) #5

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 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 #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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

@M = external dso_local local_unnamed_addr global i64, align 8
@f = external dso_local local_unnamed_addr global [2000000 x i64], align 16
@inv = external dso_local local_unnamed_addr global [2000000 x i64], align 16
@invf = external dso_local local_unnamed_addr global [2000000 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %6 = getelementptr i8, ptr %5, i64 -24
  %7 = load i64, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %7
  %9 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %8, ptr noundef null)
  %10 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store i64 1, ptr getelementptr inbounds (i8, ptr @f, i64 8), align 8, !tbaa !8
  store i64 1, ptr @f, align 16, !tbaa !8
  %13 = load i32, ptr %1, align 4, !tbaa !11
  %14 = load i32, ptr %2, align 4, !tbaa !11
  %15 = add nsw i32 %14, %13
  %16 = icmp sgt i32 %15, 2
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %17 = load i64, ptr @M, align 8, !tbaa !8
  %wide.trip.count = zext nneg i32 %15 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %18 = icmp eq i32 %15, 3
  br i1 %18, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %19 = and i64 %wide.trip.count, 2147483646
  %20 = add nsw i64 %19, -4
  br label %27

._crit_edge.loopexit.unr-lcssa:                   ; preds = %27, %.lr.ph
  %.unr = phi i64 [ 1, %.lr.ph ], [ %33, %27 ]
  %indvars.iv.unr = phi i64 [ 2, %.lr.ph ], [ %indvars.iv.next.1, %27 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %21 = mul nsw i64 %.unr, %indvars.iv.unr
  %22 = srem i64 %21, %17
  %23 = getelementptr inbounds [2000000 x i64], ptr @f, i64 0, i64 %indvars.iv.unr
  store i64 %22, ptr %23, align 8, !tbaa !8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %0
  store i64 1, ptr getelementptr inbounds (i8, ptr @inv, i64 8), align 8, !tbaa !8
  store i64 1, ptr @inv, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %24 = add nsw i32 %13, -1
  store i32 %24, ptr %3, align 4, !tbaa !11
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %.not25 = icmp slt i32 %26, 2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  br i1 %.not25, label %._crit_edge29, label %.lr.ph28

27:                                               ; preds = %27, %.lr.ph.new
  %28 = phi i64 [ 1, %.lr.ph.new ], [ %33, %27 ]
  %indvars.iv = phi i64 [ 2, %.lr.ph.new ], [ %indvars.iv.next.1, %27 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %27 ]
  %29 = mul nsw i64 %28, %indvars.iv
  %30 = srem i64 %29, %17
  %31 = getelementptr inbounds [2000000 x i64], ptr @f, i64 0, i64 %indvars.iv
  store i64 %30, ptr %31, align 16, !tbaa !8
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %32 = mul nsw i64 %30, %indvars.iv.next
  %33 = srem i64 %32, %17
  %34 = getelementptr inbounds [2000000 x i64], ptr @f, i64 0, i64 %indvars.iv.next
  store i64 %33, ptr %34, align 8, !tbaa !8
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %20
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %27, !llvm.loop !13

._crit_edge29:                                    ; preds = %.lr.ph28, %._crit_edge
  store i64 1, ptr @invf, align 16, !tbaa !8
  store i64 1, ptr getelementptr inbounds (i8, ptr @invf, i64 8), align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %35 = load i32, ptr %1, align 4, !tbaa !11
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr %4, align 4, !tbaa !11
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %.not2330 = icmp slt i32 %38, 2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  br i1 %.not2330, label %._crit_edge34, label %.lr.ph33

.lr.ph28:                                         ; preds = %._crit_edge, %.lr.ph28
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %.lr.ph28 ], [ 2, %._crit_edge ]
  %39 = load i64, ptr @M, align 8, !tbaa !8
  %40 = sdiv i64 %39, %indvars.iv36
  %41 = srem i64 %39, %indvars.iv36
  %42 = getelementptr inbounds [2000000 x i64], ptr @inv, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !8
  %44 = mul nsw i64 %43, %40
  %45 = srem i64 %44, %39
  %46 = sub nsw i64 %39, %45
  %47 = getelementptr inbounds [2000000 x i64], ptr @inv, i64 0, i64 %indvars.iv36
  store i64 %46, ptr %47, align 8, !tbaa !8
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %48 = load i32, ptr %1, align 4, !tbaa !11
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %3, align 4, !tbaa !11
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = sext i32 %51 to i64
  %.not.not = icmp slt i64 %indvars.iv36, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  br i1 %.not.not, label %.lr.ph28, label %._crit_edge29, !llvm.loop !15

._crit_edge34:                                    ; preds = %.lr.ph33, %._crit_edge29
  %53 = load i32, ptr %1, align 4, !tbaa !11
  %54 = load i32, ptr %2, align 4, !tbaa !11
  %55 = add i32 %53, -1
  %56 = add i32 %55, %54
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [2000000 x i64], ptr @f, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !8
  %60 = sext i32 %54 to i64
  %61 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = mul nsw i64 %62, %59
  %64 = load i64, ptr @M, align 8, !tbaa !8
  %65 = srem i64 %63, %64
  %66 = sext i32 %55 to i64
  %67 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !8
  %69 = mul nsw i64 %68, %65
  %70 = srem i64 %69, %64
  %71 = icmp slt i64 %70, 0
  %72 = select i1 %71, i64 %64, i64 0
  %spec.select = add nsw i64 %72, %70
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %spec.select)
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %73, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

.lr.ph33:                                         ; preds = %._crit_edge29, %.lr.ph33
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %.lr.ph33 ], [ 2, %._crit_edge29 ]
  %75 = add nsw i64 %indvars.iv39, -1
  %76 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !8
  %78 = getelementptr inbounds [2000000 x i64], ptr @inv, i64 0, i64 %indvars.iv39
  %79 = load i64, ptr %78, align 8, !tbaa !8
  %80 = mul nsw i64 %79, %77
  %81 = load i64, ptr @M, align 8, !tbaa !8
  %82 = srem i64 %80, %81
  %83 = getelementptr inbounds [2000000 x i64], ptr @invf, i64 0, i64 %indvars.iv39
  store i64 %82, ptr %83, align 8, !tbaa !8
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %84 = load i32, ptr %1, align 4, !tbaa !11
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr %4, align 4, !tbaa !11
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %87 = load i32, ptr %86, align 4, !tbaa !11
  %88 = sext i32 %87 to i64
  %.not23.not = icmp slt i64 %indvars.iv39, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  br i1 %.not23.not, label %.lr.ph33, label %._crit_edge34, !llvm.loop !16
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #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)) local_unnamed_addr #4

; 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 #5

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 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 #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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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