; LLVM IR from eyangch/competitive-programming :: Codeforces/1717 (b)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@C = external dso_local global i64, align 8
@G = external dso_local global [500 x [500 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 norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %15 = 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 %16

16:                                               ; preds = %131, %0
  %17 = load i64, ptr @T, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr @T, align 8, !tbaa !8
  %19 = icmp ne i64 %17, 0
  br i1 %19, label %20, label %132

20:                                               ; preds = %16
  %21 = 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)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(8) @K)
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 8 dereferenceable(8) @R)
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 8 dereferenceable(8) @C)
  %25 = load i64, ptr @R, align 8, !tbaa !8
  %26 = add nsw i64 %25, -1
  store i64 %26, ptr @R, align 8, !tbaa !8
  %27 = load i64, ptr @C, align 8, !tbaa !8
  %28 = add nsw i64 %27, -1
  store i64 %28, ptr @C, align 8, !tbaa !8
  %29 = load i64, ptr @K, align 8, !tbaa !8
  %30 = load i64, ptr @R, align 8, !tbaa !8
  %31 = srem i64 %30, %29
  store i64 %31, ptr @R, align 8, !tbaa !8
  %32 = load i64, ptr @K, align 8, !tbaa !8
  %33 = load i64, ptr @C, align 8, !tbaa !8
  %34 = srem i64 %33, %32
  store i64 %34, ptr @C, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %35

35:                                               ; preds = %49, %20
  %36 = load i64, ptr %2, align 8, !tbaa !8
  %37 = load i64, ptr @K, align 8, !tbaa !8
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %35
  %41 = load i64, ptr %2, align 8, !tbaa !8
  %42 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %41
  %43 = getelementptr inbounds [500 x i64], ptr %42, i64 0, i64 0
  %44 = load i64, ptr %2, align 8, !tbaa !8
  %45 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %44
  %46 = getelementptr inbounds [500 x i64], ptr %45, i64 0, i64 0
  %47 = load i64, ptr @K, align 8, !tbaa !8
  %48 = getelementptr inbounds i64, ptr %46, i64 %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !11
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef %43, ptr noundef %48, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %49

49:                                               ; preds = %40
  %50 = load i64, ptr %2, align 8, !tbaa !8
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %2, align 8, !tbaa !8
  br label %35, !llvm.loop !13

52:                                               ; preds = %39
  br label %53

53:                                               ; preds = %76, %52
  %54 = load i64, ptr @R, align 8, !tbaa !8
  %55 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %54
  %56 = load i64, ptr @C, align 8, !tbaa !8
  %57 = getelementptr inbounds [500 x i64], ptr %55, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !8
  %59 = icmp eq i64 %58, 0
  br i1 %59, label %60, label %77

60:                                               ; preds = %53
  %61 = load i64, ptr @R, align 8, !tbaa !8
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr @R, align 8, !tbaa !8
  %63 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %61
  %64 = load i64, ptr @C, align 8, !tbaa !8
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr @C, align 8, !tbaa !8
  %66 = getelementptr inbounds [500 x i64], ptr %63, i64 0, i64 %64
  store i64 1, ptr %66, align 8, !tbaa !8
  %67 = load i64, ptr @R, align 8, !tbaa !8
  %68 = load i64, ptr @K, align 8, !tbaa !8
  %69 = icmp eq i64 %67, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %60
  store i64 0, ptr @R, align 8, !tbaa !8
  br label %71

71:                                               ; preds = %70, %60
  %72 = load i64, ptr @C, align 8, !tbaa !8
  %73 = load i64, ptr @K, align 8, !tbaa !8
  %74 = icmp eq i64 %72, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %71
  store i64 0, ptr @C, align 8, !tbaa !8
  br label %76

76:                                               ; preds = %75, %71
  br label %53, !llvm.loop !15

77:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !8
  br label %78

78:                                               ; preds = %128, %77
  %79 = load i64, ptr %4, align 8, !tbaa !8
  %80 = load i64, ptr @N, align 8, !tbaa !8
  %81 = load i64, ptr @K, align 8, !tbaa !8
  %82 = sdiv i64 %80, %81
  %83 = icmp slt i64 %79, %82
  br i1 %83, label %85, label %84

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

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

86:                                               ; preds = %124, %85
  %87 = load i64, ptr %6, align 8, !tbaa !8
  %88 = load i64, ptr @K, align 8, !tbaa !8
  %89 = icmp slt i64 %87, %88
  br i1 %89, label %91, label %90

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

91:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !8
  br label %92

92:                                               ; preds = %119, %91
  %93 = load i64, ptr %7, align 8, !tbaa !8
  %94 = load i64, ptr @N, align 8, !tbaa !8
  %95 = load i64, ptr @K, align 8, !tbaa !8
  %96 = sdiv i64 %94, %95
  %97 = icmp slt i64 %93, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %92
  store i32 15, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %122

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

100:                                              ; preds = %115, %99
  %101 = load i64, ptr %8, align 8, !tbaa !8
  %102 = load i64, ptr @K, align 8, !tbaa !8
  %103 = icmp slt i64 %101, %102
  br i1 %103, label %105, label %104

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

105:                                              ; preds = %100
  %106 = load i64, ptr %6, align 8, !tbaa !8
  %107 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %106
  %108 = load i64, ptr %8, align 8, !tbaa !8
  %109 = getelementptr inbounds [500 x i64], ptr %107, i64 0, i64 %108
  %110 = load i64, ptr %109, align 8, !tbaa !8
  %111 = icmp ne i64 %110, 0
  %112 = zext i1 %111 to i64
  %113 = select i1 %111, i8 88, i8 46
  %114 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext %113)
  br label %115

115:                                              ; preds = %105
  %116 = load i64, ptr %8, align 8, !tbaa !8
  %117 = add nsw i64 %116, 1
  store i64 %117, ptr %8, align 8, !tbaa !8
  br label %100, !llvm.loop !16

118:                                              ; preds = %104
  br label %119

119:                                              ; preds = %118
  %120 = load i64, ptr %7, align 8, !tbaa !8
  %121 = add nsw i64 %120, 1
  store i64 %121, ptr %7, align 8, !tbaa !8
  br label %92, !llvm.loop !17

122:                                              ; preds = %98
  %123 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  br label %124

124:                                              ; preds = %122
  %125 = load i64, ptr %6, align 8, !tbaa !8
  %126 = add nsw i64 %125, 1
  store i64 %126, ptr %6, align 8, !tbaa !8
  br label %86, !llvm.loop !18

127:                                              ; preds = %90
  br label %128

128:                                              ; preds = %127
  %129 = load i64, ptr %4, align 8, !tbaa !8
  %130 = add nsw i64 %129, 1
  store i64 %130, ptr %4, align 8, !tbaa !8
  br label %78, !llvm.loop !19

131:                                              ; preds = %84
  br label %16, !llvm.loop !20

132:                                              ; preds = %16
  %133 = load i32, ptr %1, align 4
  ret i32 %133
}

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

; 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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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

attributes #0 = { 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 #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !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" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@C = external dso_local global i64, align 8
@G = external dso_local global [500 x [500 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %8 = 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)
  %9 = load i64, ptr @T, align 8, !tbaa !8
  %10 = add nsw i64 %9, -1
  store i64 %10, ptr @T, align 8, !tbaa !8
  %.not37 = icmp eq i64 %9, 0
  br i1 %.not37, label %._crit_edge40, label %.lr.ph39

.loopexit:                                        ; preds = %._crit_edge35, %.preheader23
  %11 = load i64, ptr @T, align 8, !tbaa !8
  %12 = add nsw i64 %11, -1
  store i64 %12, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %11, 0
  br i1 %.not, label %._crit_edge40, label %.lr.ph39, !llvm.loop !11

.lr.ph39:                                         ; preds = %0, %.loopexit
  %13 = 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)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(8) @K)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(8) @R)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(8) @C)
  %17 = load i64, ptr @R, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  %19 = load i64, ptr @C, align 8, !tbaa !8
  %20 = add nsw i64 %19, -1
  %21 = load i64, ptr @K, align 8, !tbaa !8
  %22 = srem i64 %18, %21
  store i64 %22, ptr @R, align 8, !tbaa !8
  %23 = srem i64 %20, %21
  store i64 %23, ptr @C, align 8, !tbaa !8
  %24 = icmp sgt i64 %21, 0
  br i1 %24, label %.lr.ph, label %.preheader24

.preheader24.loopexit:                            ; preds = %.lr.ph
  %R.promoted.pre = load i64, ptr @R, align 8, !tbaa !8
  %C.promoted.pre = load i64, ptr @C, align 8, !tbaa !8
  br label %.preheader24

.preheader24:                                     ; preds = %.preheader24.loopexit, %.lr.ph39
  %C.promoted = phi i64 [ %23, %.lr.ph39 ], [ %C.promoted.pre, %.preheader24.loopexit ]
  %R.promoted = phi i64 [ %22, %.lr.ph39 ], [ %R.promoted.pre, %.preheader24.loopexit ]
  %25 = phi i64 [ %21, %.lr.ph39 ], [ %33, %.preheader24.loopexit ]
  %26 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %R.promoted, i64 %C.promoted
  %27 = load i64, ptr %26, align 8, !tbaa !8
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %.lr.ph26, label %.preheader23

.lr.ph:                                           ; preds = %.lr.ph39, %.lr.ph
  %29 = phi i64 [ %33, %.lr.ph ], [ %21, %.lr.ph39 ]
  %.01825 = phi i64 [ %32, %.lr.ph ], [ 0, %.lr.ph39 ]
  %30 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %.01825
  %31 = getelementptr inbounds i64, ptr %30, i64 %29
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !13
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull %30, ptr noundef nonnull %31, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %32 = add nuw nsw i64 %.01825, 1
  %33 = load i64, ptr @K, align 8, !tbaa !8
  %34 = icmp slt i64 %32, %33
  br i1 %34, label %.lr.ph, label %.preheader24.loopexit, !llvm.loop !15

..preheader23_crit_edge:                          ; preds = %.lr.ph26
  store i64 %spec.select, ptr @R, align 8, !tbaa !8
  store i64 %46, ptr @C, align 8, !tbaa !8
  br label %.preheader23

.preheader23:                                     ; preds = %..preheader23_crit_edge, %.preheader24
  %35 = load i64, ptr @N, align 8, !tbaa !8
  %36 = sdiv i64 %35, %25
  %37 = icmp sgt i64 %36, 0
  %38 = icmp sgt i64 %25, 0
  %or.cond = and i1 %37, %38
  br i1 %or.cond, label %.preheader22, label %.loopexit

.lr.ph26:                                         ; preds = %.preheader24, %.lr.ph26
  %39 = phi ptr [ %47, %.lr.ph26 ], [ %26, %.preheader24 ]
  %40 = phi i64 [ %spec.select, %.lr.ph26 ], [ %R.promoted, %.preheader24 ]
  %41 = phi i64 [ %46, %.lr.ph26 ], [ %C.promoted, %.preheader24 ]
  %42 = add nsw i64 %40, 1
  %43 = add nsw i64 %41, 1
  store i64 1, ptr %39, align 8, !tbaa !8
  %44 = icmp eq i64 %42, %25
  %spec.select = select i1 %44, i64 0, i64 %42
  %45 = icmp eq i64 %43, %25
  %46 = select i1 %45, i64 0, i64 %43
  %47 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %spec.select, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !8
  %49 = icmp eq i64 %48, 0
  br i1 %49, label %.lr.ph26, label %..preheader23_crit_edge, !llvm.loop !16

.preheader22:                                     ; preds = %.preheader23, %._crit_edge35
  %50 = phi i64 [ %58, %._crit_edge35 ], [ %25, %.preheader23 ]
  %51 = phi i64 [ %59, %._crit_edge35 ], [ %35, %.preheader23 ]
  %.01736 = phi i64 [ %60, %._crit_edge35 ], [ 0, %.preheader23 ]
  %52 = icmp sgt i64 %50, 0
  br i1 %52, label %.preheader21, label %._crit_edge35

.preheader21:                                     ; preds = %.preheader22, %._crit_edge32
  %53 = phi i64 [ %68, %._crit_edge32 ], [ %50, %.preheader22 ]
  %.01633 = phi i64 [ %67, %._crit_edge32 ], [ 0, %.preheader22 ]
  %54 = load i64, ptr @N, align 8, !tbaa !8
  %55 = sdiv i64 %54, %53
  %56 = icmp sgt i64 %55, 0
  %57 = icmp sgt i64 %53, 0
  %or.cond51 = and i1 %56, %57
  br i1 %or.cond51, label %.preheader, label %._crit_edge32

._crit_edge35.loopexit:                           ; preds = %._crit_edge32
  %.pre47 = load i64, ptr @N, align 8, !tbaa !8
  br label %._crit_edge35

._crit_edge35:                                    ; preds = %._crit_edge35.loopexit, %.preheader22
  %58 = phi i64 [ %68, %._crit_edge35.loopexit ], [ %50, %.preheader22 ]
  %59 = phi i64 [ %.pre47, %._crit_edge35.loopexit ], [ %51, %.preheader22 ]
  %60 = add nuw nsw i64 %.01736, 1
  %61 = sdiv i64 %59, %58
  %62 = icmp slt i64 %60, %61
  br i1 %62, label %.preheader22, label %.loopexit, !llvm.loop !17

.preheader:                                       ; preds = %.preheader21, %._crit_edge
  %63 = phi i64 [ %70, %._crit_edge ], [ %53, %.preheader21 ]
  %64 = phi i64 [ %71, %._crit_edge ], [ %54, %.preheader21 ]
  %.01531 = phi i64 [ %72, %._crit_edge ], [ 0, %.preheader21 ]
  %65 = icmp sgt i64 %63, 0
  br i1 %65, label %.lr.ph30, label %._crit_edge

._crit_edge32:                                    ; preds = %._crit_edge, %.preheader21
  %66 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  %67 = add nuw nsw i64 %.01633, 1
  %68 = load i64, ptr @K, align 8, !tbaa !8
  %69 = icmp slt i64 %67, %68
  br i1 %69, label %.preheader21, label %._crit_edge35.loopexit, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %.lr.ph30
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %70 = phi i64 [ %80, %._crit_edge.loopexit ], [ %63, %.preheader ]
  %71 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %64, %.preheader ]
  %72 = add nuw nsw i64 %.01531, 1
  %73 = sdiv i64 %71, %70
  %74 = icmp slt i64 %72, %73
  br i1 %74, label %.preheader, label %._crit_edge32, !llvm.loop !20

.lr.ph30:                                         ; preds = %.preheader, %.lr.ph30
  %.029 = phi i64 [ %79, %.lr.ph30 ], [ 0, %.preheader ]
  %75 = getelementptr inbounds [500 x [500 x i64]], ptr @G, i64 0, i64 %.01633, i64 %.029
  %76 = load i64, ptr %75, align 8, !tbaa !8
  %.not20 = icmp eq i64 %76, 0
  %77 = select i1 %.not20, i8 46, i8 88
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext %77)
  %79 = add nuw nsw i64 %.029, 1
  %80 = load i64, ptr @K, align 8, !tbaa !8
  %81 = icmp slt i64 %79, %80
  br i1 %81, label %.lr.ph30, label %._crit_edge.loopexit, !llvm.loop !21

._crit_edge40:                                    ; preds = %.loopexit, %0
  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 #2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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

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


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass