; LLVM IR from VastoLorde95/Competitive-Programming :: Timus/1554 (A)

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

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

23:                                               ; preds = %33, %0
  %24 = load i32, ptr %3, align 4, !tbaa !8
  %25 = load i32, ptr %2, align 4, !tbaa !8
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %36

28:                                               ; preds = %23
  %29 = load i32, ptr %3, align 4, !tbaa !8
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [10010 x i32], ptr @f, i64 0, i64 %30
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %31)
  br label %33

33:                                               ; preds = %28
  %34 = load i32, ptr %3, align 4, !tbaa !8
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !8
  br label %23, !llvm.loop !11

36:                                               ; preds = %27
  store i32 1, ptr getelementptr inbounds ([10010 x i32], ptr @g, i64 0, i64 1), align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 2, ptr %4, align 4, !tbaa !8
  br label %37

37:                                               ; preds = %131, %36
  %38 = load i32, ptr %4, align 4, !tbaa !8
  %39 = load i32, ptr %2, align 4, !tbaa !8
  %40 = icmp sle i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %134

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !8
  br label %43

43:                                               ; preds = %127, %42
  %44 = load i32, ptr %6, align 4, !tbaa !8
  %45 = load i32, ptr %6, align 4, !tbaa !8
  %46 = mul nsw i32 %44, %45
  %47 = load i32, ptr %4, align 4, !tbaa !8
  %48 = icmp sle i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %43
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %130

50:                                               ; preds = %43
  %51 = load i32, ptr %4, align 4, !tbaa !8
  %52 = load i32, ptr %6, align 4, !tbaa !8
  %53 = srem i32 %51, %52
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %50
  br label %127

56:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %57 = load i32, ptr %6, align 4, !tbaa !8
  store i32 %57, ptr %7, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %58 = load i32, ptr %4, align 4, !tbaa !8
  %59 = load i32, ptr %6, align 4, !tbaa !8
  %60 = sdiv i32 %58, %59
  store i32 %60, ptr %8, align 4, !tbaa !8
  %61 = load i32, ptr %7, align 4, !tbaa !8
  %62 = icmp sgt i32 %61, 1
  br i1 %62, label %63, label %91

63:                                               ; preds = %56
  %64 = load i32, ptr %7, align 4, !tbaa !8
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [10010 x i32], ptr @f, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !8
  %68 = load i32, ptr %8, align 4, !tbaa !8
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !8
  %72 = mul nsw i32 %67, %71
  %73 = srem i32 %72, 2007
  %74 = load i32, ptr %4, align 4, !tbaa !8
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !8
  %78 = sub nsw i32 %77, %73
  store i32 %78, ptr %76, align 4, !tbaa !8
  %79 = load i32, ptr %4, align 4, !tbaa !8
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !8
  %83 = icmp slt i32 %82, 0
  br i1 %83, label %84, label %90

84:                                               ; preds = %63
  %85 = load i32, ptr %4, align 4, !tbaa !8
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !8
  %89 = add nsw i32 %88, 2007
  store i32 %89, ptr %87, align 4, !tbaa !8
  br label %90

90:                                               ; preds = %84, %63
  br label %91

91:                                               ; preds = %90, %56
  %92 = load i32, ptr %8, align 4, !tbaa !8
  %93 = icmp sgt i32 %92, 1
  br i1 %93, label %94, label %126

94:                                               ; preds = %91
  %95 = load i32, ptr %8, align 4, !tbaa !8
  %96 = load i32, ptr %7, align 4, !tbaa !8
  %97 = icmp ne i32 %95, %96
  br i1 %97, label %98, label %126

98:                                               ; preds = %94
  %99 = load i32, ptr %8, align 4, !tbaa !8
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [10010 x i32], ptr @f, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !8
  %103 = load i32, ptr %7, align 4, !tbaa !8
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !8
  %107 = mul nsw i32 %102, %106
  %108 = srem i32 %107, 2007
  %109 = load i32, ptr %4, align 4, !tbaa !8
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !8
  %113 = sub nsw i32 %112, %108
  store i32 %113, ptr %111, align 4, !tbaa !8
  %114 = load i32, ptr %4, align 4, !tbaa !8
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !8
  %118 = icmp slt i32 %117, 0
  br i1 %118, label %119, label %125

119:                                              ; preds = %98
  %120 = load i32, ptr %4, align 4, !tbaa !8
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !8
  %124 = add nsw i32 %123, 2007
  store i32 %124, ptr %122, align 4, !tbaa !8
  br label %125

125:                                              ; preds = %119, %98
  br label %126

126:                                              ; preds = %125, %94, %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %127

127:                                              ; preds = %126, %55
  %128 = load i32, ptr %6, align 4, !tbaa !8
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %6, align 4, !tbaa !8
  br label %43, !llvm.loop !13

130:                                              ; preds = %49
  br label %131

131:                                              ; preds = %130
  %132 = load i32, ptr %4, align 4, !tbaa !8
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %4, align 4, !tbaa !8
  br label %37, !llvm.loop !14

134:                                              ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 1, ptr %9, align 4, !tbaa !8
  br label %135

135:                                              ; preds = %147, %134
  %136 = load i32, ptr %9, align 4, !tbaa !8
  %137 = load i32, ptr %2, align 4, !tbaa !8
  %138 = icmp sle i32 %136, %137
  br i1 %138, label %140, label %139

139:                                              ; preds = %135
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %150

140:                                              ; preds = %135
  %141 = load i32, ptr %9, align 4, !tbaa !8
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !8
  %145 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %144)
  %146 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %145, i8 noundef signext 32)
  br label %147

147:                                              ; preds = %140
  %148 = load i32, ptr %9, align 4, !tbaa !8
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %9, align 4, !tbaa !8
  br label %135, !llvm.loop !15

150:                                              ; preds = %139
  %151 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %152 = load i32, ptr %1, align 4
  ret i32 %152
}

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

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

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 uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #4

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5 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

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 = { "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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !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" }

@f = external dso_local global [10010 x i32], align 16
@g = external dso_local local_unnamed_addr global [10010 x i32], 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 @_Z3geti(i32 noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %3 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %5
  %7 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %6, ptr noundef null)
  %8 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %10
  %12 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %13 = 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)
  %14 = load i32, ptr %1, align 4, !tbaa !8
  call void @_Z3geti(i32 noundef %14)
  %15 = load i32, ptr %1, align 4, !tbaa !8
  %.not44 = icmp slt i32 %15, 1
  br i1 %.not44, label %.preheader.thread, label %.lr.ph

.preheader.thread:                                ; preds = %0
  store i32 1, ptr getelementptr inbounds (i8, ptr @g, i64 4), align 4, !tbaa !8
  br label %._crit_edge52

._crit_edge:                                      ; preds = %.lr.ph
  store i32 1, ptr getelementptr inbounds (i8, ptr @g, i64 4), align 4, !tbaa !8
  %.not3847 = icmp slt i32 %19, 2
  br i1 %.not3847, label %.preheader, label %.preheader43.preheader

.preheader43.preheader:                           ; preds = %._crit_edge
  %16 = add nuw i32 %19, 1
  %wide.trip.count = zext i32 %16 to i64
  br label %21

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %17 = getelementptr inbounds [10010 x i32], ptr @f, i64 0, i64 %indvars.iv
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %1, align 4, !tbaa !8
  %20 = sext i32 %19 to i64
  %.not.not = icmp slt i64 %indvars.iv, %20
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

21:                                               ; preds = %.loopexit, %.preheader43.preheader
  %indvars.iv59 = phi i64 [ 2, %.preheader43.preheader ], [ %indvars.iv.next60, %.loopexit ]
  %22 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %indvars.iv59
  %23 = getelementptr inbounds [10010 x i32], ptr @f, i64 0, i64 %indvars.iv59
  %24 = load i32, ptr %23, align 4, !tbaa !8
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @g, i64 4), align 4, !tbaa !8
  %26 = mul nsw i32 %25, %24
  %27 = srem i32 %26, 2007
  %28 = load i32, ptr %22, align 4, !tbaa !8
  %29 = sub nsw i32 %28, %27
  %30 = icmp slt i32 %29, 0
  %31 = add nsw i32 %29, 2007
  %spec.select = select i1 %30, i32 %31, i32 %29
  store i32 %spec.select, ptr %22, align 4, !tbaa !8
  %.not40.peel = icmp ult i64 %indvars.iv59, 4
  br i1 %.not40.peel, label %.loopexit, label %.peel.next

.peel.next:                                       ; preds = %21
  %32 = trunc nuw nsw i64 %indvars.iv59 to i32
  br label %33

.preheader:                                       ; preds = %.loopexit, %._crit_edge
  %.not3949 = icmp slt i32 %19, 1
  br i1 %.not3949, label %._crit_edge52, label %.lr.ph51

.loopexit:                                        ; preds = %62, %21
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %21, !llvm.loop !13

33:                                               ; preds = %.peel.next, %62
  %indvars.iv55 = phi i64 [ 2, %.peel.next ], [ %indvars.iv.next56, %62 ]
  %34 = trunc nuw nsw i64 %indvars.iv55 to i32
  %35 = urem i32 %32, %34
  %36 = udiv i32 %32, %34
  %.not41 = icmp eq i32 %35, 0
  br i1 %.not41, label %37, label %62

37:                                               ; preds = %33
  %38 = getelementptr inbounds [10010 x i32], ptr @f, i64 0, i64 %indvars.iv55
  %39 = load i32, ptr %38, align 4, !tbaa !8
  %40 = zext i32 %36 to i64
  %41 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !8
  %43 = mul nsw i32 %42, %39
  %44 = srem i32 %43, 2007
  %45 = load i32, ptr %22, align 4, !tbaa !8
  %46 = sub nsw i32 %45, %44
  %47 = icmp slt i32 %46, 0
  %48 = add nsw i32 %46, 2007
  %spec.select71 = select i1 %47, i32 %48, i32 %46
  store i32 %spec.select71, ptr %22, align 4, !tbaa !8
  %49 = icmp ult i32 %36, 2
  %.not42 = icmp eq i64 %indvars.iv55, %40
  %or.cond = or i1 %49, %.not42
  br i1 %or.cond, label %62, label %50

50:                                               ; preds = %37
  %51 = getelementptr inbounds [10010 x i32], ptr @f, i64 0, i64 %40
  %52 = load i32, ptr %51, align 4, !tbaa !8
  %53 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %indvars.iv55
  %54 = load i32, ptr %53, align 4, !tbaa !8
  %55 = mul nsw i32 %54, %52
  %56 = srem i32 %55, 2007
  %57 = load i32, ptr %22, align 4, !tbaa !8
  %58 = sub nsw i32 %57, %56
  store i32 %58, ptr %22, align 4, !tbaa !8
  %59 = icmp slt i32 %58, 0
  br i1 %59, label %60, label %62

60:                                               ; preds = %50
  %61 = add nsw i32 %58, 2007
  store i32 %61, ptr %22, align 4, !tbaa !8
  br label %62

62:                                               ; preds = %37, %60, %50, %33
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %63 = mul nuw nsw i64 %indvars.iv.next56, %indvars.iv.next56
  %.not40 = icmp ugt i64 %63, %indvars.iv59
  br i1 %.not40, label %.loopexit, label %33, !llvm.loop !14

._crit_edge52:                                    ; preds = %.lr.ph51, %.preheader.thread, %.preheader
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret i32 0

.lr.ph51:                                         ; preds = %.preheader, %.lr.ph51
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %.lr.ph51 ], [ 1, %.preheader ]
  %65 = getelementptr inbounds [10010 x i32], ptr @g, i64 0, i64 %indvars.iv62
  %66 = load i32, ptr %65, align 4, !tbaa !8
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %66)
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %67, i8 noundef signext 32)
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %69 = load i32, ptr %1, align 4, !tbaa !8
  %70 = sext i32 %69 to i64
  %.not39.not = icmp slt i64 %indvars.iv62, %70
  br i1 %.not39.not, label %.lr.ph51, label %._crit_edge52, !llvm.loop !16
}

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

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

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 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 #4

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

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 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 = { "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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !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}
!15 = !{!"llvm.loop.peeled.count", i32 1}
!16 = distinct !{!16, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,DivRemPairsPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass