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

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

%struct.Point = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@que = external dso_local global [100001 x i32], align 16
@ans = external dso_local global i32, align 4
@p = external dso_local global [300003 x %struct.Point], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 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 zeroext i1 @_Z4cmp1RK5PointS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sumi(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 %struct.Point, align 4
  %6 = alloca %struct.Point, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %9 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %9, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %34, %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) #6
  br label %37

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %17
  %19 = getelementptr inbounds %struct.Point, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %21
  %23 = getelementptr inbounds %struct.Point, ptr %22, i32 0, i32 1
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %19, ptr noundef %23)
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Point, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = load i32, ptr @tot, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %30 to i64
  %33 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %32
  store i32 %29, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %15
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !11

37:                                               ; preds = %14
  %38 = load i32, ptr @tot, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr @que, i64 %39
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %40)
  %41 = load i32, ptr @tot, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr @que, i64 %42
  %44 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %43)
  %45 = ptrtoint ptr %44 to i64
  %46 = sub i64 %45, ptrtoint (ptr @que to i64)
  %47 = sdiv exact i64 %46, 4
  %48 = trunc i64 %47 to i32
  store i32 %48, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %72, %37
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = load i32, ptr @n, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %49
  %55 = load i32, ptr @tot, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr @que, i64 %56
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %59
  %61 = getelementptr inbounds %struct.Point, ptr %60, i32 0, i32 1
  %62 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %57, ptr noundef nonnull align 4 dereferenceable(4) %61)
  %63 = ptrtoint ptr %62 to i64
  %64 = sub i64 %63, ptrtoint (ptr @que to i64)
  %65 = sdiv exact i64 %64, 4
  %66 = add nsw i64 %65, 1
  %67 = trunc i64 %66 to i32
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.Point, ptr %70, i32 0, i32 1
  store i32 %67, ptr %71, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %54
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %3, align 4, !tbaa !5
  br label %49, !llvm.loop !13

75:                                               ; preds = %53
  %76 = load i32, ptr @n, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.Point, ptr @p, i64 %77
  call void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef @p, ptr noundef %78, ptr noundef @_Z4cmp1RK5PointS1_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %139, %75
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = icmp slt i32 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %142

84:                                               ; preds = %79
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = sub nsw i32 %85, 1
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %87
  %89 = getelementptr inbounds %struct.Point, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !9
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.Point, ptr %93, i32 0, i32 1
  %95 = load i32, ptr %94, align 4, !tbaa !9
  %96 = icmp eq i32 %90, %95
  br i1 %96, label %97, label %138

97:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #6
  %98 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 0
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = sub nsw i32 %99, 1
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %101
  %103 = getelementptr inbounds %struct.Point, ptr %102, i32 0, i32 0
  %104 = load i32, ptr %103, align 4, !tbaa !14
  store i32 %104, ptr %98, align 4, !tbaa !14
  %105 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 1
  %106 = load i32, ptr %4, align 4, !tbaa !5
  %107 = sub nsw i32 %106, 1
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %108
  %110 = getelementptr inbounds %struct.Point, ptr %109, i32 0, i32 1
  %111 = load i32, ptr %110, align 4, !tbaa !9
  store i32 %111, ptr %105, align 4, !tbaa !9
  %112 = getelementptr inbounds %struct.Point, ptr %5, i32 0, i32 2
  store i32 1, ptr %112, align 4, !tbaa !15
  %113 = load i32, ptr @n, align 4, !tbaa !5
  %114 = load i32, ptr @m, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr @m, align 4, !tbaa !5
  %116 = add nsw i32 %113, %114
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %117
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %118, ptr align 4 %5, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #6
  %119 = getelementptr inbounds %struct.Point, ptr %6, i32 0, i32 0
  %120 = load i32, ptr %4, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %121
  %123 = getelementptr inbounds %struct.Point, ptr %122, i32 0, i32 0
  %124 = load i32, ptr %123, align 4, !tbaa !14
  store i32 %124, ptr %119, align 4, !tbaa !14
  %125 = getelementptr inbounds %struct.Point, ptr %6, i32 0, i32 1
  %126 = load i32, ptr %4, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %127
  %129 = getelementptr inbounds %struct.Point, ptr %128, i32 0, i32 1
  %130 = load i32, ptr %129, align 4, !tbaa !9
  store i32 %130, ptr %125, align 4, !tbaa !9
  %131 = getelementptr inbounds %struct.Point, ptr %6, i32 0, i32 2
  store i32 -1, ptr %131, align 4, !tbaa !15
  %132 = load i32, ptr @n, align 4, !tbaa !5
  %133 = load i32, ptr @m, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr @m, align 4, !tbaa !5
  %135 = add nsw i32 %132, %133
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %136
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %137, ptr align 4 %6, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #6
  br label %138

138:                                              ; preds = %97, %84
  br label %139

139:                                              ; preds = %138
  %140 = load i32, ptr %4, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %4, align 4, !tbaa !5
  br label %79, !llvm.loop !17

142:                                              ; preds = %83
  %143 = load i32, ptr @m, align 4, !tbaa !5
  %144 = load i32, ptr @n, align 4, !tbaa !5
  %145 = add nsw i32 %144, %143
  store i32 %145, ptr @n, align 4, !tbaa !5
  %146 = load i32, ptr @n, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds %struct.Point, ptr @p, i64 %147
  call void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef @p, ptr noundef %148, ptr noundef @_Z4cmp2RK5PointS1_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %149

149:                                              ; preds = %221, %142
  %150 = load i32, ptr %7, align 4, !tbaa !5
  %151 = load i32, ptr @n, align 4, !tbaa !5
  %152 = icmp slt i32 %150, %151
  br i1 %152, label %154, label %153

153:                                              ; preds = %149
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %224

154:                                              ; preds = %149
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %156
  %158 = getelementptr inbounds %struct.Point, ptr %157, i32 0, i32 2
  %159 = load i32, ptr %158, align 4, !tbaa !15
  %160 = icmp ne i32 %159, 0
  br i1 %160, label %161, label %172

161:                                              ; preds = %154
  %162 = load i32, ptr %7, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %163
  %165 = getelementptr inbounds %struct.Point, ptr %164, i32 0, i32 1
  %166 = load i32, ptr %165, align 4, !tbaa !9
  %167 = load i32, ptr %7, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %168
  %170 = getelementptr inbounds %struct.Point, ptr %169, i32 0, i32 2
  %171 = load i32, ptr %170, align 4, !tbaa !15
  call void @_Z3addii(i32 noundef %166, i32 noundef %171)
  br label %220

172:                                              ; preds = %154
  %173 = load i32, ptr %7, align 4, !tbaa !5
  %174 = icmp ne i32 %173, 0
  br i1 %174, label %175, label %219

175:                                              ; preds = %172
  %176 = load i32, ptr %7, align 4, !tbaa !5
  %177 = sub nsw i32 %176, 1
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %178
  %180 = getelementptr inbounds %struct.Point, ptr %179, i32 0, i32 0
  %181 = load i32, ptr %180, align 4, !tbaa !14
  %182 = load i32, ptr %7, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %183
  %185 = getelementptr inbounds %struct.Point, ptr %184, i32 0, i32 0
  %186 = load i32, ptr %185, align 4, !tbaa !14
  %187 = icmp eq i32 %181, %186
  br i1 %187, label %188, label %219

188:                                              ; preds = %175
  %189 = load i32, ptr %7, align 4, !tbaa !5
  %190 = sub nsw i32 %189, 1
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %191
  %193 = getelementptr inbounds %struct.Point, ptr %192, i32 0, i32 2
  %194 = load i32, ptr %193, align 4, !tbaa !15
  %195 = load i32, ptr %7, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %196
  %198 = getelementptr inbounds %struct.Point, ptr %197, i32 0, i32 2
  %199 = load i32, ptr %198, align 4, !tbaa !15
  %200 = icmp eq i32 %194, %199
  br i1 %200, label %201, label %219

201:                                              ; preds = %188
  %202 = load i32, ptr %7, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %203
  %205 = getelementptr inbounds %struct.Point, ptr %204, i32 0, i32 1
  %206 = load i32, ptr %205, align 4, !tbaa !9
  %207 = sub nsw i32 %206, 1
  %208 = call noundef i32 @_Z3sumi(i32 noundef %207)
  %209 = load i32, ptr %7, align 4, !tbaa !5
  %210 = sub nsw i32 %209, 1
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %211
  %213 = getelementptr inbounds %struct.Point, ptr %212, i32 0, i32 1
  %214 = load i32, ptr %213, align 4, !tbaa !9
  %215 = call noundef i32 @_Z3sumi(i32 noundef %214)
  %216 = sub nsw i32 %208, %215
  %217 = load i32, ptr @ans, align 4, !tbaa !5
  %218 = add nsw i32 %217, %216
  store i32 %218, ptr @ans, align 4, !tbaa !5
  br label %219

219:                                              ; preds = %201, %188, %175, %172
  br label %220

220:                                              ; preds = %219, %161
  br label %221

221:                                              ; preds = %220
  %222 = load i32, ptr %7, align 4, !tbaa !5
  %223 = add nsw i32 %222, 1
  store i32 %223, ptr %7, align 4, !tbaa !5
  br label %149, !llvm.loop !18

224:                                              ; preds = %153
  %225 = load i32, ptr @ans, align 4, !tbaa !5
  %226 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %225)
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #4

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !6, i64 4}
!10 = !{!"_ZTS5Point", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!10, !6, i64 0}
!15 = !{!10, !6, i64 8}
!16 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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

%struct.Point = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [100001 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local global [300003 x %struct.Point], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 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 zeroext i1 @_Z4cmp1RK5PointS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sumi(i32 noundef) local_unnamed_addr #0

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

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

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %4 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %22, %.lr.ph ]
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds i32, ptr @que, i64 %5
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %6)
  %7 = load i32, ptr @tot, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds i32, ptr @que, i64 %8
  %10 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %9)
  %11 = ptrtoint ptr %10 to i64
  %12 = sub i64 %11, ptrtoint (ptr @que to i64)
  %13 = lshr exact i64 %12, 2
  %14 = trunc i64 %13 to i32
  store i32 %14, ptr @tot, align 4, !tbaa !5
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph45, label %._crit_edge.._crit_edge46_crit_edge

._crit_edge.._crit_edge46_crit_edge:              ; preds = %._crit_edge
  %.pre72 = sext i32 %15 to i64
  br label %._crit_edge46

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %17 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %indvars.iv
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  %19 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %17, ptr noundef nonnull %18)
  %20 = load i32, ptr %18, align 4, !tbaa !9
  %21 = load i32, ptr @tot, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr @tot, align 4, !tbaa !5
  %23 = sext i32 %21 to i64
  %24 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %23
  store i32 %20, ptr %24, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = icmp slt i64 %indvars.iv.next, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge46:                                    ; preds = %.lr.ph45, %._crit_edge.._crit_edge46_crit_edge
  %.pre-phi = phi i64 [ %.pre72, %._crit_edge.._crit_edge46_crit_edge ], [ %42, %.lr.ph45 ]
  %28 = getelementptr inbounds %struct.Point, ptr @p, i64 %.pre-phi
  tail call void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef nonnull @p, ptr noundef nonnull %28, ptr noundef nonnull @_Z4cmp1RK5PointS1_)
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %m.promoted = load i32, ptr @m, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 1
  br i1 %30, label %.lr.ph49.preheader, label %._crit_edge50

.lr.ph49.preheader:                               ; preds = %._crit_edge46
  %wide.trip.count = zext nneg i32 %29 to i64
  %.pre67 = load i32, ptr getelementptr inbounds (i8, ptr @p, i64 4), align 4, !tbaa !9
  br label %.lr.ph49

.lr.ph45:                                         ; preds = %._crit_edge, %.lr.ph45
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %.lr.ph45 ], [ 0, %._crit_edge ]
  %31 = load i32, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr @que, i64 %32
  %34 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %indvars.iv57, i32 1
  %35 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %33, ptr noundef nonnull align 4 dereferenceable(4) %34)
  %36 = ptrtoint ptr %35 to i64
  %37 = sub i64 %36, ptrtoint (ptr @que to i64)
  %38 = lshr exact i64 %37, 2
  %39 = trunc i64 %38 to i32
  %40 = add i32 %39, 1
  store i32 %40, ptr %34, align 4, !tbaa !9
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next58, %42
  br i1 %43, label %.lr.ph45, label %._crit_edge46, !llvm.loop !13

._crit_edge50:                                    ; preds = %76, %._crit_edge46
  %44 = phi i32 [ %m.promoted, %._crit_edge46 ], [ %78, %76 ]
  %45 = add nsw i32 %44, %29
  store i32 %45, ptr @n, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %struct.Point, ptr @p, i64 %46
  tail call void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef nonnull @p, ptr noundef nonnull %47, ptr noundef nonnull @_Z4cmp2RK5PointS1_)
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %.lr.ph54.preheader, label %._crit_edge55

.lr.ph54.preheader:                               ; preds = %._crit_edge50
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @p, i64 8), align 8, !tbaa !14
  %.not.peel = icmp eq i32 %50, 0
  br i1 %.not.peel, label %53, label %51

51:                                               ; preds = %.lr.ph54.preheader
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @p, i64 4), align 4, !tbaa !9
  tail call void @_Z3addii(i32 noundef %52, i32 noundef %50)
  %.pre70 = load i32, ptr @n, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %.lr.ph54.preheader, %51
  %54 = phi i32 [ %.pre70, %51 ], [ %48, %.lr.ph54.preheader ]
  %55 = icmp sgt i32 %54, 1
  br i1 %55, label %.lr.ph54, label %._crit_edge55

.lr.ph49:                                         ; preds = %.lr.ph49.preheader, %76
  %56 = phi i32 [ %.pre67, %.lr.ph49.preheader ], [ %77, %76 ]
  %indvars.iv60 = phi i64 [ 1, %.lr.ph49.preheader ], [ %indvars.iv.next61, %76 ]
  %57 = phi i32 [ %m.promoted, %.lr.ph49.preheader ], [ %78, %76 ]
  %58 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %indvars.iv60
  %59 = getelementptr inbounds i8, ptr %58, i64 4
  %60 = load i32, ptr %59, align 4, !tbaa !9
  %61 = icmp eq i32 %56, %60
  br i1 %61, label %62, label %76

62:                                               ; preds = %.lr.ph49
  %63 = add nsw i64 %indvars.iv60, -1
  %64 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !15
  %66 = add nsw i32 %57, 1
  %67 = add nsw i32 %57, %29
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %68
  store i32 %65, ptr %69, align 4, !tbaa !5
  %.sroa.413.0..sroa_idx = getelementptr inbounds i8, ptr %69, i64 4
  store i32 %56, ptr %.sroa.413.0..sroa_idx, align 4, !tbaa !5
  %.sroa.514.0..sroa_idx = getelementptr inbounds i8, ptr %69, i64 8
  store i32 1, ptr %.sroa.514.0..sroa_idx, align 4, !tbaa !5
  %70 = load i32, ptr %58, align 4, !tbaa !15
  %71 = load i32, ptr %59, align 4, !tbaa !9
  %72 = add nsw i32 %57, 2
  store i32 %72, ptr @m, align 4, !tbaa !5
  %73 = add nsw i32 %66, %29
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %74
  store i32 %70, ptr %75, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %75, i64 4
  store i32 %71, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %75, i64 8
  store i32 -1, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %.lr.ph49, %62
  %77 = phi i32 [ %60, %.lr.ph49 ], [ %71, %62 ]
  %78 = phi i32 [ %57, %.lr.ph49 ], [ %72, %62 ]
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next61, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge50, label %.lr.ph49, !llvm.loop !16

._crit_edge55:                                    ; preds = %108, %53, %._crit_edge50
  %79 = load i32, ptr @ans, align 4, !tbaa !5
  %80 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %79)
  ret i32 0

.lr.ph54:                                         ; preds = %53, %108
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %108 ], [ 1, %53 ]
  %81 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %indvars.iv63
  %82 = getelementptr inbounds i8, ptr %81, i64 8
  %83 = load i32, ptr %82, align 4, !tbaa !14
  %.not = icmp eq i32 %83, 0
  br i1 %.not, label %87, label %84

84:                                               ; preds = %.lr.ph54
  %85 = getelementptr inbounds i8, ptr %81, i64 4
  %86 = load i32, ptr %85, align 4, !tbaa !9
  tail call void @_Z3addii(i32 noundef %86, i32 noundef %83)
  br label %108

87:                                               ; preds = %.lr.ph54
  %88 = add nsw i64 %indvars.iv63, -1
  %89 = getelementptr inbounds [300003 x %struct.Point], ptr @p, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !15
  %91 = load i32, ptr %81, align 4, !tbaa !15
  %92 = icmp eq i32 %90, %91
  br i1 %92, label %93, label %108

93:                                               ; preds = %87
  %94 = getelementptr inbounds i8, ptr %89, i64 8
  %95 = load i32, ptr %94, align 4, !tbaa !14
  %96 = icmp eq i32 %95, 0
  br i1 %96, label %97, label %108

97:                                               ; preds = %93
  %98 = getelementptr inbounds i8, ptr %81, i64 4
  %99 = load i32, ptr %98, align 4, !tbaa !9
  %100 = add nsw i32 %99, -1
  %101 = tail call noundef i32 @_Z3sumi(i32 noundef %100)
  %102 = getelementptr inbounds i8, ptr %89, i64 4
  %103 = load i32, ptr %102, align 4, !tbaa !9
  %104 = tail call noundef i32 @_Z3sumi(i32 noundef %103)
  %105 = sub i32 %101, %104
  %106 = load i32, ptr @ans, align 4, !tbaa !5
  %107 = add nsw i32 %105, %106
  store i32 %107, ptr @ans, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %84, %97, %93, %87
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %109 = load i32, ptr @n, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = icmp slt i64 %indvars.iv.next64, %110
  br i1 %111, label %.lr.ph54, label %._crit_edge55, !llvm.loop !17
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointPFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

!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 = !{!10, !6, i64 4}
!10 = !{!"_ZTS5Point", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !6, i64 0}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12, !18}
!18 = !{!"llvm.loop.peeled.count", i32 1}


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