; LLVM IR from tangjz/acm-icpc :: 51nod (1624)

; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, int, std::_Identity<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 }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@s = external dso_local global [3 x [100001 x i32]], align 16
@ans = external dso_local global i32, align 4
@e = external dso_local global %"class.std::set", 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 [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 %"struct.std::pair", align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %10 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store i32 0, ptr %1, align 4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @p)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %73, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 3
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %76

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

19:                                               ; preds = %69, %18
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %72

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 %26
  %28 = getelementptr inbounds [100001 x i32], ptr %27, i64 0, i64 0
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i32, ptr %28, i64 %30
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %31)
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 %34
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100001 x i32], ptr %35, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 %42
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100001 x i32], ptr %43, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = add nsw i32 %47, %40
  store i32 %48, ptr %46, align 4, !tbaa !5
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 %50
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100001 x i32], ptr %51, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = load i32, ptr @p, align 4, !tbaa !5
  %57 = icmp sge i32 %55, %56
  br i1 %57, label %58, label %68

58:                                               ; preds = %24
  %59 = load i32, ptr @p, align 4, !tbaa !5
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 %61
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100001 x i32], ptr %62, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = sub nsw i32 %66, %59
  store i32 %67, ptr %65, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %58, %24
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %4, align 4, !tbaa !5
  br label %19, !llvm.loop !9

72:                                               ; preds = %23
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !11

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

77:                                               ; preds = %178, %76
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = icmp sle i32 %78, %79
  br i1 %80, label %82, label %81

81:                                               ; preds = %77
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %181

82:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100001 x i32], ptr @s, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = sub nsw i32 %87, 1
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @s, i64 0, i64 1), i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sub nsw i32 %86, %91
  store i32 %92, ptr %6, align 4, !tbaa !5
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = icmp slt i32 %93, 0
  br i1 %94, label %95, label %99

95:                                               ; preds = %82
  %96 = load i32, ptr @p, align 4, !tbaa !5
  %97 = load i32, ptr %6, align 4, !tbaa !5
  %98 = add nsw i32 %97, %96
  store i32 %98, ptr %6, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %95, %82
  %100 = call { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @e, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %101 = getelementptr inbounds { ptr, i8 }, ptr %7, i32 0, i32 0
  %102 = extractvalue { ptr, i8 } %100, 0
  store ptr %102, ptr %101, align 8
  %103 = getelementptr inbounds { ptr, i8 }, ptr %7, i32 0, i32 1
  %104 = extractvalue { ptr, i8 } %100, 1
  store i8 %104, ptr %103, align 8
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @s, i64 0, i64 1), i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = load i32, ptr @n, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @s, i64 0, i64 2), i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = add nsw i32 %108, %112
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = sub nsw i32 %114, 1
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([3 x [100001 x i32]], ptr @s, i64 0, i64 2), i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = sub nsw i32 %113, %118
  store i32 %119, ptr %6, align 4, !tbaa !5
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = icmp slt i32 %120, 0
  br i1 %121, label %122, label %126

122:                                              ; preds = %99
  %123 = load i32, ptr @p, align 4, !tbaa !5
  %124 = load i32, ptr %6, align 4, !tbaa !5
  %125 = add nsw i32 %124, %123
  store i32 %125, ptr %6, align 4, !tbaa !5
  br label %135

126:                                              ; preds = %99
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = load i32, ptr @p, align 4, !tbaa !5
  %129 = icmp sge i32 %127, %128
  br i1 %129, label %130, label %134

130:                                              ; preds = %126
  %131 = load i32, ptr @p, align 4, !tbaa !5
  %132 = load i32, ptr %6, align 4, !tbaa !5
  %133 = sub nsw i32 %132, %131
  store i32 %133, ptr %6, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %130, %126
  br label %135

135:                                              ; preds = %134, %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %136 = load i32, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %137 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @e) #5
  %138 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %9, i32 0, i32 0
  store ptr %137, ptr %138, align 8
  %139 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  %140 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %139) #5
  %141 = load i32, ptr %140, align 4, !tbaa !5
  %142 = add nsw i32 %136, %141
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  store i32 %142, ptr %8, align 4, !tbaa !5
  %143 = load i32, ptr %8, align 4, !tbaa !5
  %144 = load i32, ptr @p, align 4, !tbaa !5
  %145 = icmp sge i32 %143, %144
  br i1 %145, label %146, label %150

146:                                              ; preds = %135
  %147 = load i32, ptr @p, align 4, !tbaa !5
  %148 = load i32, ptr %8, align 4, !tbaa !5
  %149 = sub nsw i32 %148, %147
  store i32 %149, ptr %8, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %146, %135
  %151 = load i32, ptr @ans, align 4, !tbaa !5
  %152 = load i32, ptr %8, align 4, !tbaa !5
  %153 = icmp slt i32 %151, %152
  br i1 %153, label %154, label %156

154:                                              ; preds = %150
  %155 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %155, ptr @ans, align 4, !tbaa !5
  br label %156

156:                                              ; preds = %154, %150
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %157 = load i32, ptr @p, align 4, !tbaa !5
  %158 = load i32, ptr %6, align 4, !tbaa !5
  %159 = sub nsw i32 %157, %158
  store i32 %159, ptr %11, align 4, !tbaa !5
  %160 = call ptr @_ZNSt3setIiSt4lessIiESaIiEE11lower_boundERKi(ptr noundef nonnull align 8 dereferenceable(48) @e, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %161 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %10, i32 0, i32 0
  store ptr %160, ptr %161, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %162 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @e) #5
  %163 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %12, i32 0, i32 0
  store ptr %162, ptr %163, align 8
  %164 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br i1 %164, label %165, label %177

165:                                              ; preds = %156
  %166 = load i32, ptr %6, align 4, !tbaa !5
  %167 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  %168 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %167) #5
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = add nsw i32 %166, %169
  store i32 %170, ptr %8, align 4, !tbaa !5
  %171 = load i32, ptr @ans, align 4, !tbaa !5
  %172 = load i32, ptr %8, align 4, !tbaa !5
  %173 = icmp slt i32 %171, %172
  br i1 %173, label %174, label %176

174:                                              ; preds = %165
  %175 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %175, ptr @ans, align 4, !tbaa !5
  br label %176

176:                                              ; preds = %174, %165
  br label %177

177:                                              ; preds = %176, %156
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %178

178:                                              ; preds = %177
  %179 = load i32, ptr %5, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %5, align 4, !tbaa !5
  br label %77, !llvm.loop !12

181:                                              ; preds = %81
  %182 = load i32, ptr @ans, align 4, !tbaa !5
  %183 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %182)
  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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEv(ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

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

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


; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, int, std::_Identity<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 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@s = external dso_local global [3 x [100001 x i32]], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local global %"class.std::set", 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 [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 %"struct.std::_Rb_tree_const_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @p)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 1
  br i1 %8, label %._crit_edge49, label %.lr.ph

.preheader:                                       ; preds = %36
  %9 = icmp slt i32 %37, 1
  br i1 %9, label %._crit_edge49, label %.lr.ph48

._crit_edge:                                      ; preds = %49
  %.not4043.1 = icmp slt i32 %50, 1
  br i1 %.not4043.1, label %._crit_edge49, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %._crit_edge, %21
  %indvars.iv.1 = phi i64 [ %indvars.iv.next.1, %21 ], [ 1, %._crit_edge ]
  %10 = getelementptr inbounds i32, ptr getelementptr inbounds (i8, ptr @s, i64 400004), i64 %indvars.iv.1
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %10)
  %12 = add nsw i64 %indvars.iv.1, -1
  %13 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 1, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 1, i64 %indvars.iv.1
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = add nsw i32 %16, %14
  store i32 %17, ptr %15, align 4, !tbaa !5
  %18 = load i32, ptr @p, align 4, !tbaa !5
  %.not41.1 = icmp slt i32 %17, %18
  br i1 %.not41.1, label %21, label %19

19:                                               ; preds = %.lr.ph.1
  %20 = sub nsw i32 %17, %18
  store i32 %20, ptr %15, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %19, %.lr.ph.1
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.1, 1
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %.not40.not.1 = icmp slt i64 %indvars.iv.1, %23
  br i1 %.not40.not.1, label %.lr.ph.1, label %._crit_edge.1, !llvm.loop !9

._crit_edge.1:                                    ; preds = %21
  %24 = icmp slt i32 %22, 1
  br i1 %24, label %._crit_edge49, label %.lr.ph.2

.lr.ph.2:                                         ; preds = %._crit_edge.1, %36
  %indvars.iv.2 = phi i64 [ %indvars.iv.next.2, %36 ], [ 1, %._crit_edge.1 ]
  %25 = getelementptr inbounds i32, ptr getelementptr inbounds (i8, ptr @s, i64 800008), i64 %indvars.iv.2
  %26 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %25)
  %27 = add nsw i64 %indvars.iv.2, -1
  %28 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 2, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 2, i64 %indvars.iv.2
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = add nsw i32 %31, %29
  store i32 %32, ptr %30, align 4, !tbaa !5
  %33 = load i32, ptr @p, align 4, !tbaa !5
  %.not41.2 = icmp slt i32 %32, %33
  br i1 %.not41.2, label %36, label %34

34:                                               ; preds = %.lr.ph.2
  %35 = sub nsw i32 %32, %33
  store i32 %35, ptr %30, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %34, %.lr.ph.2
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.2, 1
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %.not40.not.2 = icmp slt i64 %indvars.iv.2, %38
  br i1 %.not40.not.2, label %.lr.ph.2, label %.preheader, !llvm.loop !9

.lr.ph:                                           ; preds = %0, %49
  %indvars.iv = phi i64 [ %indvars.iv.next, %49 ], [ 1, %0 ]
  %39 = getelementptr inbounds i32, ptr @s, i64 %indvars.iv
  %40 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %39)
  %41 = add nsw i64 %indvars.iv, -1
  %42 = getelementptr inbounds [3 x [100001 x i32]], ptr @s, i64 0, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = load i32, ptr %39, align 4, !tbaa !5
  %45 = add nsw i32 %44, %43
  store i32 %45, ptr %39, align 4, !tbaa !5
  %46 = load i32, ptr @p, align 4, !tbaa !5
  %.not41 = icmp slt i32 %45, %46
  br i1 %.not41, label %49, label %47

47:                                               ; preds = %.lr.ph
  %48 = sub nsw i32 %45, %46
  store i32 %48, ptr %39, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %.lr.ph, %47
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %.not40.not = icmp slt i64 %indvars.iv, %51
  br i1 %.not40.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge49:                                    ; preds = %110, %._crit_edge, %0, %._crit_edge.1, %.preheader
  %52 = load i32, ptr @ans, align 4, !tbaa !5
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %52)
  ret i32 0

.lr.ph48:                                         ; preds = %.preheader, %110
  %indvars.iv55 = phi i64 [ %indvars.iv.next56, %110 ], [ 1, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %54 = getelementptr inbounds [100001 x i32], ptr @s, i64 0, i64 %indvars.iv55
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add nsw i64 %indvars.iv55, -1
  %57 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @s, i64 400004), i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = sub nsw i32 %55, %58
  store i32 %59, ptr %1, align 4, !tbaa !5
  %60 = icmp slt i32 %59, 0
  br i1 %60, label %61, label %64

61:                                               ; preds = %.lr.ph48
  %62 = load i32, ptr @p, align 4, !tbaa !5
  %63 = add nsw i32 %62, %59
  store i32 %63, ptr %1, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %61, %.lr.ph48
  %65 = call { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @e, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %66 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @s, i64 400004), i64 0, i64 %indvars.iv55
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @s, i64 800008), i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = add nsw i32 %71, %67
  %73 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @s, i64 800008), i64 0, i64 %56
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sub i32 %72, %74
  store i32 %75, ptr %1, align 4, !tbaa !5
  %76 = icmp slt i32 %75, 0
  %77 = load i32, ptr @p, align 4, !tbaa !5
  br i1 %76, label %78, label %80

78:                                               ; preds = %64
  %79 = add nsw i32 %77, %75
  store i32 %79, ptr %1, align 4, !tbaa !5
  br label %83

80:                                               ; preds = %64
  %.not38 = icmp slt i32 %75, %77
  br i1 %.not38, label %83, label %81

81:                                               ; preds = %80
  %82 = sub nsw i32 %75, %77
  store i32 %82, ptr %1, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %80, %81, %78
  %84 = phi i32 [ %75, %80 ], [ %82, %81 ], [ %79, %78 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %85 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @e) #5
  store ptr %85, ptr %2, align 8
  %86 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %87 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %86) #5
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = add nsw i32 %88, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  %90 = load i32, ptr @p, align 4, !tbaa !5
  %.not39 = icmp slt i32 %89, %90
  %91 = select i1 %.not39, i32 0, i32 %90
  %spec.select = sub nsw i32 %89, %91
  %92 = load i32, ptr @ans, align 4, !tbaa !5
  %93 = icmp slt i32 %92, %spec.select
  br i1 %93, label %94, label %95

94:                                               ; preds = %83
  store i32 %spec.select, ptr @ans, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %94, %83
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %96 = load i32, ptr %1, align 4, !tbaa !5
  %97 = sub nsw i32 %90, %96
  store i32 %97, ptr %4, align 4, !tbaa !5
  %98 = call ptr @_ZNSt3setIiSt4lessIiESaIiEE11lower_boundERKi(ptr noundef nonnull align 8 dereferenceable(48) @e, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store ptr %98, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %99 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @e) #5
  store ptr %99, ptr %5, align 8
  %100 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br i1 %100, label %101, label %110

101:                                              ; preds = %95
  %102 = load i32, ptr %1, align 4, !tbaa !5
  %103 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  %104 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %103) #5
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %105, %102
  %107 = load i32, ptr @ans, align 4, !tbaa !5
  %108 = icmp slt i32 %107, %106
  br i1 %108, label %109, label %110

109:                                              ; preds = %101
  store i32 %106, ptr @ans, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %101, %109, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %111 = load i32, ptr @n, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %.not.not = icmp slt i64 %indvars.iv55, %112
  br i1 %.not.not, label %.lr.ph48, label %._crit_edge49, !llvm.loop !11
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

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

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


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