; LLVM IR from tangjz/acm-icpc :: codeforces/complete (524C)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@a = external dso_local global [5010 x i32], align 16
@x = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@Hash = external dso_local global %"class.std::map", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %24, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %27

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr @a, i64 %17
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %18)
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [5010 x i32], ptr @a, i64 0, i64 %21
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(4) %22)
  store i32 1, ptr %23, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %15
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !9

27:                                               ; preds = %14
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @q)
  br label %29

29:                                               ; preds = %131, %27
  %30 = load i32, ptr @q, align 4, !tbaa !5
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr @q, align 4, !tbaa !5
  %32 = icmp ne i32 %30, 0
  br i1 %32, label %33, label %132

33:                                               ; preds = %29
  store i32 2147483647, ptr @ans, align 4, !tbaa !5
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @x)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %119, %33
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %122

40:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %114, %40
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr @k, align 4, !tbaa !5
  %44 = icmp sle i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 10, ptr %4, align 4
  br label %117

46:                                               ; preds = %41
  %47 = load i32, ptr @x, align 4, !tbaa !5
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [5010 x i32], ptr @a, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = mul nsw i32 %51, %52
  %54 = icmp eq i32 %47, %53
  br i1 %54, label %55, label %58

55:                                               ; preds = %46
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %57 = load i32, ptr %56, align 4, !tbaa !5
  store i32 %57, ptr @ans, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %55, %46
  %59 = load i32, ptr @x, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [5010 x i32], ptr @a, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = mul nsw i32 %63, %64
  %66 = icmp slt i32 %59, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %58
  store i32 10, ptr %4, align 4
  br label %117

68:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %110, %68
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = load i32, ptr @k, align 4, !tbaa !5
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sub nsw i32 %71, %72
  %74 = icmp sle i32 %70, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %69
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %113

76:                                               ; preds = %69
  %77 = load i32, ptr @x, align 4, !tbaa !5
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [5010 x i32], ptr @a, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr %5, align 4, !tbaa !5
  %83 = mul nsw i32 %81, %82
  %84 = sub nsw i32 %77, %83
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = srem i32 %84, %85
  %87 = icmp eq i32 %86, 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  br i1 %87, label %88, label %101

88:                                               ; preds = %76
  %89 = load i32, ptr @x, align 4, !tbaa !5
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [5010 x i32], ptr @a, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = mul nsw i32 %93, %94
  %96 = sub nsw i32 %89, %95
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = sdiv i32 %96, %97
  store i32 %98, ptr %7, align 4, !tbaa !5
  %99 = call noundef i64 @_ZNKSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %100 = icmp ne i64 %99, 0
  br label %101

101:                                              ; preds = %88, %76
  %102 = phi i1 [ false, %76 ], [ %100, %88 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br i1 %102, label %103, label %109

103:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = add nsw i32 %104, %105
  store i32 %106, ptr %8, align 4, !tbaa !5
  %107 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %108 = load i32, ptr %107, align 4, !tbaa !5
  store i32 %108, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %109

109:                                              ; preds = %103, %101
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %6, align 4, !tbaa !5
  br label %69, !llvm.loop !11

113:                                              ; preds = %75
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %5, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %5, align 4, !tbaa !5
  br label %41, !llvm.loop !12

117:                                              ; preds = %67, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %3, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %3, align 4, !tbaa !5
  br label %35, !llvm.loop !13

122:                                              ; preds = %39
  %123 = load i32, ptr @ans, align 4, !tbaa !5
  %124 = load i32, ptr @k, align 4, !tbaa !5
  %125 = icmp sgt i32 %123, %124
  br i1 %125, label %126, label %128

126:                                              ; preds = %122
  %127 = call i32 @puts(ptr noundef @.str.2)
  br label %131

128:                                              ; preds = %122
  %129 = load i32, ptr @ans, align 4, !tbaa !5
  %130 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %129)
  br label %131

131:                                              ; preds = %128, %126
  br label %29, !llvm.loop !14

132:                                              ; preds = %29
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

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

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

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

declare i32 @puts(ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #1

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@a = external dso_local global [5010 x i32], align 16
@x = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@Hash = external dso_local global %"class.std::map", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @k)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @q)
  %8 = load i32, ptr @q, align 4, !tbaa !5
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr @q, align 4, !tbaa !5
  %.not37 = icmp eq i32 %8, 0
  br i1 %.not37, label %._crit_edge40, label %.lr.ph39

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %10 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %10)
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(4) %10)
  store i32 1, ptr %12, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next, %14
  br i1 %15, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph39:                                         ; preds = %._crit_edge, %67
  store i32 2147483647, ptr @ans, align 4, !tbaa !5
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @x)
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp slt i32 %17, 1
  %.pre53 = load i32, ptr @k, align 4, !tbaa !5
  %19 = icmp slt i32 %.pre53, 0
  %or.cond = select i1 %18, i1 true, i1 %19
  br i1 %or.cond, label %._crit_edge36, label %.lr.ph35.split

._crit_edge36:                                    ; preds = %._crit_edge31, %.lr.ph39
  %20 = phi i32 [ %.pre53, %.lr.ph39 ], [ %.pr, %._crit_edge31 ]
  %21 = load i32, ptr @ans, align 4, !tbaa !5
  %22 = icmp sgt i32 %21, %20
  br i1 %22, label %63, label %65

.lr.ph35.split:                                   ; preds = %.lr.ph39, %._crit_edge31
  %23 = phi i32 [ %.pr, %._crit_edge31 ], [ %.pre53, %.lr.ph39 ]
  %24 = phi i32 [ %60, %._crit_edge31 ], [ %17, %.lr.ph39 ]
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %._crit_edge31 ], [ 0, %.lr.ph39 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  %.not1927 = icmp slt i32 %23, 0
  br i1 %.not1927, label %._crit_edge31, label %.lr.ph30

.lr.ph30:                                         ; preds = %.lr.ph35.split
  %25 = getelementptr inbounds [5010 x i32], ptr @a, i64 0, i64 %indvars.iv44
  br label %26

26:                                               ; preds = %.lr.ph30, %._crit_edge26
  %storemerge28 = phi i32 [ 0, %.lr.ph30 ], [ %40, %._crit_edge26 ]
  %27 = load i32, ptr @x, align 4, !tbaa !5
  %28 = load i32, ptr %25, align 4, !tbaa !5
  %29 = mul nsw i32 %28, %storemerge28
  %30 = icmp eq i32 %27, %29
  br i1 %30, label %31, label %34

31:                                               ; preds = %26
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %33 = load i32, ptr %32, align 4, !tbaa !5
  store i32 %33, ptr @ans, align 4, !tbaa !5
  %.pre = load i32, ptr @x, align 4, !tbaa !5
  %.pre47 = load i32, ptr %25, align 4, !tbaa !5
  %.pre48 = load i32, ptr %1, align 4, !tbaa !5
  %.pre54 = mul nsw i32 %.pre48, %.pre47
  br label %34

34:                                               ; preds = %31, %26
  %.pre-phi = phi i32 [ %.pre54, %31 ], [ %29, %26 ]
  %35 = phi i32 [ %.pre48, %31 ], [ %storemerge28, %26 ]
  %36 = phi i32 [ %.pre, %31 ], [ %27, %26 ]
  %37 = icmp slt i32 %36, %.pre-phi
  br i1 %37, label %._crit_edge31.loopexit, label %.preheader

.preheader:                                       ; preds = %34
  %38 = load i32, ptr @k, align 4, !tbaa !5
  %.not2023.not = icmp sgt i32 %38, %35
  br i1 %.not2023.not, label %.lr.ph25, label %._crit_edge26

._crit_edge26:                                    ; preds = %55, %.preheader
  %39 = phi i32 [ %38, %.preheader ], [ %58, %55 ]
  %.lcssa = phi i32 [ %35, %.preheader ], [ %56, %55 ]
  %40 = add nsw i32 %.lcssa, 1
  store i32 %40, ptr %1, align 4, !tbaa !5
  %.not19.not = icmp slt i32 %.lcssa, %39
  br i1 %.not19.not, label %26, label %._crit_edge31.loopexit, !llvm.loop !11

.lr.ph25:                                         ; preds = %.preheader, %55
  %41 = phi i32 [ %56, %55 ], [ %35, %.preheader ]
  %.024 = phi i32 [ %57, %55 ], [ 1, %.preheader ]
  %42 = load i32, ptr @x, align 4, !tbaa !5
  %43 = load i32, ptr %25, align 4, !tbaa !5
  %44 = mul nsw i32 %43, %41
  %45 = sub nsw i32 %42, %44
  %46 = srem i32 %45, %.024
  %47 = sdiv i32 %45, %.024
  %48 = icmp eq i32 %46, 0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  br i1 %48, label %49, label %.critedge

49:                                               ; preds = %.lr.ph25
  store i32 %47, ptr %2, align 4, !tbaa !5
  %50 = call noundef i64 @_ZNKSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @Hash, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %.not21 = icmp eq i64 %50, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %.pre50 = load i32, ptr %1, align 4, !tbaa !5
  br i1 %.not21, label %55, label %51

51:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %52 = add nsw i32 %.pre50, %.024
  store i32 %52, ptr %3, align 4, !tbaa !5
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %54 = load i32, ptr %53, align 4, !tbaa !5
  store i32 %54, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %.pre49 = load i32, ptr %1, align 4, !tbaa !5
  br label %55

.critedge:                                        ; preds = %.lr.ph25
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  br label %55

55:                                               ; preds = %49, %51, %.critedge
  %56 = phi i32 [ %.pre50, %49 ], [ %.pre49, %51 ], [ %41, %.critedge ]
  %57 = add nuw nsw i32 %.024, 1
  %58 = load i32, ptr @k, align 4, !tbaa !5
  %59 = sub nsw i32 %58, %56
  %.not20.not = icmp slt i32 %.024, %59
  br i1 %.not20.not, label %.lr.ph25, label %._crit_edge26, !llvm.loop !12

._crit_edge31.loopexit:                           ; preds = %34, %._crit_edge26
  %.pre51 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge31

._crit_edge31:                                    ; preds = %._crit_edge31.loopexit, %.lr.ph35.split
  %60 = phi i32 [ %.pre51, %._crit_edge31.loopexit ], [ %24, %.lr.ph35.split ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %61 = sext i32 %60 to i64
  %62 = icmp slt i64 %indvars.iv.next45, %61
  %.pr = load i32, ptr @k, align 4, !tbaa !5
  br i1 %62, label %.lr.ph35.split, label %._crit_edge36, !llvm.loop !13

63:                                               ; preds = %._crit_edge36
  %64 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %67

65:                                               ; preds = %._crit_edge36
  %66 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %21)
  br label %67

67:                                               ; preds = %65, %63
  %68 = load i32, ptr @q, align 4, !tbaa !5
  %69 = add nsw i32 %68, -1
  store i32 %69, ptr @q, align 4, !tbaa !5
  %.not = icmp eq i32 %68, 0
  br i1 %.not, label %._crit_edge40, label %.lr.ph39, !llvm.loop !15

._crit_edge40:                                    ; preds = %67, %._crit_edge
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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 = { nofree nounwind "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10, !14}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = distinct !{!15, !10}


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