; LLVM IR from tangjz/acm-icpc :: lydsy (3285)

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

@A = external dso_local global i32, align 4
@B = external dso_local global i32, align 4
@P = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@q = external dso_local global %"class.std::map", align 8
@tmp = external dso_local global [4 x [1000010 x i8]], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3powii(i32 noundef, 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
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @tmp, ptr noundef getelementptr inbounds ([4 x [1000010 x i8]], ptr @tmp, i64 0, i64 1), ptr noundef getelementptr inbounds ([4 x [1000010 x i8]], ptr @tmp, i64 0, i64 2), ptr noundef getelementptr inbounds ([4 x [1000010 x i8]], ptr @tmp, i64 0, i64 3), ptr noundef @P)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  %17 = load i32, ptr @P, align 4, !tbaa !5
  %18 = sub nsw i32 %17, 1
  %19 = call noundef i32 @_Z4scanPci(ptr noundef @tmp, i32 noundef %18)
  store i32 %19, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %20 = load i32, ptr @P, align 4, !tbaa !5
  %21 = sub nsw i32 %20, 1
  %22 = call noundef i32 @_Z4scanPci(ptr noundef getelementptr inbounds ([4 x [1000010 x i8]], ptr @tmp, i64 0, i64 1), i32 noundef %21)
  store i32 %22, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %23 = load i32, ptr @P, align 4, !tbaa !5
  %24 = call noundef i32 @_Z4scanPci(ptr noundef getelementptr inbounds ([4 x [1000010 x i8]], ptr @tmp, i64 0, i64 2), i32 noundef %23)
  store i32 %24, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %25 = load i32, ptr @P, align 4, !tbaa !5
  %26 = call noundef i32 @_Z4scanPci(ptr noundef getelementptr inbounds ([4 x [1000010 x i8]], ptr @tmp, i64 0, i64 3), i32 noundef %25)
  store i32 %26, ptr %5, align 4, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = call noundef i32 @_Z3powii(i32 noundef %27, i32 noundef %28)
  store i32 %29, ptr @A, align 4, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = call noundef i32 @_Z3powii(i32 noundef %30, i32 noundef %31)
  %33 = load i32, ptr @P, align 4, !tbaa !5
  %34 = sub nsw i32 %33, 2
  %35 = call noundef i32 @_Z3powii(i32 noundef %32, i32 noundef %34)
  %36 = sext i32 %35 to i64
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = mul nsw i64 %36, %38
  %40 = load i32, ptr @P, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = srem i64 %39, %41
  %43 = trunc i64 %42 to i32
  store i32 %43, ptr @B, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %44 = load i32, ptr @P, align 4, !tbaa !5
  %45 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %44)
  %46 = fptosi double %45 to i32
  store i32 %46, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %64, %0
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %67

52:                                               ; preds = %47
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 4 dereferenceable(4) %8)
  store i32 %53, ptr %54, align 4, !tbaa !5
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = load i32, ptr @A, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = mul nsw i64 %56, %58
  %60 = load i32, ptr @P, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = srem i64 %59, %61
  %63 = trunc i64 %62 to i32
  store i32 %63, ptr %8, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %52
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %7, align 4, !tbaa !5
  br label %47, !llvm.loop !9

67:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %68 = load i32, ptr @P, align 4, !tbaa !5
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = sdiv i32 %68, %69
  store i32 %70, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %71 = load i32, ptr @A, align 4, !tbaa !5
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = call noundef i32 @_Z3powii(i32 noundef %71, i32 noundef %72)
  %74 = load i32, ptr @P, align 4, !tbaa !5
  %75 = sub nsw i32 %74, 2
  %76 = call noundef i32 @_Z3powii(i32 noundef %73, i32 noundef %75)
  store i32 %76, ptr %12, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %120, %67
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = icmp sle i32 %78, %79
  br i1 %80, label %82, label %81

81:                                               ; preds = %77
  store i32 5, ptr %13, align 4
  br label %123

82:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %83 = load i32, ptr %11, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = load i32, ptr @B, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = mul nsw i64 %84, %86
  %88 = load i32, ptr @P, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = srem i64 %87, %89
  %91 = trunc i64 %90 to i32
  store i32 %91, ptr %14, align 4, !tbaa !5
  %92 = call noundef i64 @_ZNKSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %93 = icmp ne i64 %92, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br i1 %93, label %94, label %110

94:                                               ; preds = %82
  %95 = load i32, ptr %9, align 4, !tbaa !5
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = mul nsw i32 %95, %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %98 = load i32, ptr %11, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = load i32, ptr @B, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = mul nsw i64 %99, %101
  %103 = load i32, ptr @P, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = srem i64 %102, %104
  %106 = trunc i64 %105 to i32
  store i32 %106, ptr %15, align 4, !tbaa !5
  %107 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixEOi(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = add nsw i32 %97, %108
  store i32 %109, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  store i32 5, ptr %13, align 4
  br label %123

110:                                              ; preds = %82
  %111 = load i32, ptr %11, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = load i32, ptr %12, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = mul nsw i64 %112, %114
  %116 = load i32, ptr @P, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = srem i64 %115, %117
  %119 = trunc i64 %118 to i32
  store i32 %119, ptr %11, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %110
  %121 = load i32, ptr %9, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %9, align 4, !tbaa !5
  br label %77, !llvm.loop !11

123:                                              ; preds = %94, %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %124

124:                                              ; preds = %123
  %125 = load i32, ptr @ans, align 4, !tbaa !5
  %126 = icmp eq i32 %125, 2147483647
  br i1 %126, label %127, label %129

127:                                              ; preds = %124
  %128 = call i32 @puts(ptr noundef @.str.1)
  br label %132

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

132:                                              ; preds = %129, %127
  %133 = phi i32 [ %128, %127 ], [ %131, %129 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %134 = load i32, ptr %1, align 4
  ret i32 %134
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4scanPci(ptr noundef, i32 noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) #4

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

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

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

declare i32 @puts(ptr noundef) #3

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

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 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 = { 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 = !{!"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}


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

@A = external dso_local local_unnamed_addr global i32, align 4
@B = external dso_local local_unnamed_addr global i32, align 4
@P = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@q = external dso_local global %"class.std::map", align 8
@tmp = external dso_local global [4 x [1000010 x i8]], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3powii(i32 noundef, 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 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @tmp, ptr noundef nonnull getelementptr inbounds (i8, ptr @tmp, i64 1000010), ptr noundef nonnull getelementptr inbounds (i8, ptr @tmp, i64 2000020), ptr noundef nonnull getelementptr inbounds (i8, ptr @tmp, i64 3000030), ptr noundef nonnull @P)
  %5 = load i32, ptr @P, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  %7 = tail call noundef i32 @_Z4scanPci(ptr noundef nonnull @tmp, i32 noundef %6)
  %8 = load i32, ptr @P, align 4, !tbaa !5
  %9 = add nsw i32 %8, -1
  %10 = tail call noundef i32 @_Z4scanPci(ptr noundef nonnull getelementptr inbounds (i8, ptr @tmp, i64 1000010), i32 noundef %9)
  %11 = load i32, ptr @P, align 4, !tbaa !5
  %12 = tail call noundef i32 @_Z4scanPci(ptr noundef nonnull getelementptr inbounds (i8, ptr @tmp, i64 2000020), i32 noundef %11)
  %13 = load i32, ptr @P, align 4, !tbaa !5
  %14 = tail call noundef i32 @_Z4scanPci(ptr noundef nonnull getelementptr inbounds (i8, ptr @tmp, i64 3000030), i32 noundef %13)
  %15 = tail call noundef i32 @_Z3powii(i32 noundef %14, i32 noundef %7)
  store i32 %15, ptr @A, align 4, !tbaa !5
  %16 = tail call noundef i32 @_Z3powii(i32 noundef %14, i32 noundef %10)
  %17 = load i32, ptr @P, align 4, !tbaa !5
  %18 = add nsw i32 %17, -2
  %19 = tail call noundef i32 @_Z3powii(i32 noundef %16, i32 noundef %18)
  %20 = sext i32 %19 to i64
  %21 = sext i32 %12 to i64
  %22 = mul nsw i64 %20, %21
  %23 = load i32, ptr @P, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = srem i64 %22, %24
  %26 = trunc nsw i64 %25 to i32
  store i32 %26, ptr @B, align 4, !tbaa !5
  %27 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %23)
  %28 = fptosi double %27 to i32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 1, ptr %1, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = load i32, ptr @P, align 4, !tbaa !5
  %.pre36 = load i32, ptr @A, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %30 = phi i32 [ %.pre36, %.._crit_edge_crit_edge ], [ %41, %.lr.ph ]
  %31 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %44, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %32 = sdiv i32 %31, %28
  %33 = call noundef i32 @_Z3powii(i32 noundef %30, i32 noundef %28)
  %34 = load i32, ptr @P, align 4, !tbaa !5
  %35 = add nsw i32 %34, -2
  %36 = call noundef i32 @_Z3powii(i32 noundef %33, i32 noundef %35)
  %.not28 = icmp slt i32 %32, 0
  br i1 %.not28, label %thread-pre-split, label %.lr.ph32

.lr.ph32:                                         ; preds = %._crit_edge
  %37 = sext i32 %36 to i64
  %.pre37 = load i32, ptr @P, align 4, !tbaa !5
  br label %49

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.027 = phi i32 [ %48, %.lr.ph ], [ 0, %0 ]
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 4 dereferenceable(4) %1)
  store i32 %.027, ptr %38, align 4, !tbaa !5
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = load i32, ptr @A, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = mul nsw i64 %42, %40
  %44 = load i32, ptr @P, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = srem i64 %43, %45
  %47 = trunc nsw i64 %46 to i32
  store i32 %47, ptr %1, align 4, !tbaa !5
  %48 = add nuw nsw i32 %.027, 1
  %exitcond.not = icmp eq i32 %48, %28
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

49:                                               ; preds = %.lr.ph32, %70
  %50 = phi i32 [ %.pre37, %.lr.ph32 ], [ %72, %70 ]
  %.02130 = phi i64 [ 1, %.lr.ph32 ], [ %74, %70 ]
  %.02229 = phi i32 [ 0, %.lr.ph32 ], [ %75, %70 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %51 = load i32, ptr @B, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = mul nsw i64 %.02130, %52
  %54 = sext i32 %50 to i64
  %55 = srem i64 %53, %54
  %56 = trunc nsw i64 %55 to i32
  store i32 %56, ptr %2, align 4, !tbaa !5
  %57 = call noundef i64 @_ZNKSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %.not25 = icmp eq i64 %57, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  br i1 %.not25, label %70, label %58

58:                                               ; preds = %49
  %59 = mul nsw i32 %.02229, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %60 = load i32, ptr @B, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = mul nsw i64 %.02130, %61
  %63 = load i32, ptr @P, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = srem i64 %62, %64
  %66 = trunc nsw i64 %65 to i32
  store i32 %66, ptr %3, align 4, !tbaa !5
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixEOi(ptr noundef nonnull align 8 dereferenceable(48) @q, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = add nsw i32 %68, %59
  store i32 %69, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  br label %76

70:                                               ; preds = %49
  %71 = mul nsw i64 %.02130, %37
  %72 = load i32, ptr @P, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = srem i64 %71, %73
  %75 = add nuw i32 %.02229, 1
  %exitcond35.not = icmp eq i32 %.02229, %32
  br i1 %exitcond35.not, label %thread-pre-split, label %49, !llvm.loop !11

thread-pre-split:                                 ; preds = %70, %._crit_edge
  %.pr = load i32, ptr @ans, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %thread-pre-split, %58
  %77 = phi i32 [ %.pr, %thread-pre-split ], [ %69, %58 ]
  %78 = icmp eq i32 %77, 2147483647
  br i1 %78, label %79, label %81

79:                                               ; preds = %76
  %80 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %83

81:                                               ; preds = %76
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %77)
  br label %83

83:                                               ; preds = %81, %79
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4scanPci(ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) local_unnamed_addr #4

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

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

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

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

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

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 = { 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 #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 = { 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 = !{!"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}


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