; LLVM IR from tangjz/acm-icpc :: self_training/2016-11-19/E.ll (Z5solvev)

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

@m = external dso_local global i32, align 4
@C = external dso_local global i32, align 4
@x = external dso_local global [100001 x i32], align 16
@y = external dso_local global [100001 x i32], align 16
@p = external dso_local global [100001 x i32], align 16
@ord = external dso_local global [100001 x i32], align 16
@ans = external dso_local global i32, align 4
@sz = external dso_local global i32, align 4
@bit = external dso_local global [100001 x i32], align 16
@que = external dso_local global [100001 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5queryi(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 uwtable
define dso_local void @_Z5solvev() #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 i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %198, %0
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = load i32, ptr @m, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %9
  store i32 0, ptr @sz, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100001 x i32], ptr @y, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sub nsw i32 %21, %28
  store i32 %29, ptr %4, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %86, %14
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %52

34:                                               ; preds = %30
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100001 x i32], ptr @y, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sub nsw i32 %41, %48
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = icmp eq i32 %49, %50
  br label %52

52:                                               ; preds = %34, %30
  %53 = phi i1 [ false, %30 ], [ %51, %34 ]
  br i1 %53, label %55, label %54

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

55:                                               ; preds = %52
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = mul nsw i64 %63, %71
  %73 = load i32, ptr %2, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = add nsw i64 %72, %80
  %82 = load i32, ptr @sz, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr @sz, align 4, !tbaa !5
  %84 = sext i32 %82 to i64
  %85 = getelementptr inbounds [100001 x i64], ptr @que, i64 0, i64 %84
  store i64 %81, ptr %85, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %55
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %2, align 4, !tbaa !5
  br label %30, !llvm.loop !11

89:                                               ; preds = %54
  %90 = load i32, ptr @sz, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i64, ptr @que, i64 %91
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @que, ptr noundef %92)
  %93 = load i32, ptr @sz, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i64, ptr @que, i64 %94
  %96 = call noundef ptr @_ZSt6uniqueIPxET_S1_S1_(ptr noundef @que, ptr noundef %95)
  %97 = ptrtoint ptr %96 to i64
  %98 = sub i64 %97, ptrtoint (ptr @que to i64)
  %99 = sdiv exact i64 %98, 8
  %100 = trunc i64 %99 to i32
  store i32 %100, ptr @sz, align 4, !tbaa !5
  %101 = load i32, ptr @sz, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = mul i64 %102, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @bit, i64 1), i8 0, i64 %103, i1 false)
  %104 = load i32, ptr @sz, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [100001 x i64], ptr @que, i64 0, i64 %105
  store i64 1000000000000000, ptr %106, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %107 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %107, ptr %5, align 4, !tbaa !5
  br label %108

108:                                              ; preds = %194, %89
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = load i32, ptr %2, align 4, !tbaa !5
  %111 = icmp slt i32 %109, %110
  br i1 %111, label %113, label %112

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

113:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = load i32, ptr %5, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = mul nsw i64 %129, %137
  %139 = sub nsw i64 %121, %138
  %140 = load i32, ptr @C, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = sub nsw i64 %139, %141
  %143 = add nsw i64 %142, 1
  store i64 %143, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %144 = load i32, ptr @sz, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds i64, ptr @que, i64 %145
  %147 = getelementptr inbounds i64, ptr %146, i64 1
  %148 = call noundef ptr @_ZSt11upper_boundIPxxET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %147, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %149 = ptrtoint ptr %148 to i64
  %150 = sub i64 %149, ptrtoint (ptr @que to i64)
  %151 = sdiv exact i64 %150, 8
  %152 = trunc i64 %151 to i32
  store i32 %152, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %153 = load i32, ptr %7, align 4, !tbaa !5
  %154 = call noundef i32 @_Z5queryi(i32 noundef %153)
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %8, align 4, !tbaa !5
  %156 = load i32, ptr %5, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %157
  %159 = load i32, ptr %158, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = load i32, ptr %5, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %165
  %167 = load i32, ptr %166, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = mul nsw i64 %163, %171
  %173 = load i32, ptr %5, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = add nsw i64 %172, %180
  store i64 %181, ptr %6, align 8, !tbaa !9
  %182 = load i32, ptr @sz, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds i64, ptr @que, i64 %183
  %185 = call noundef ptr @_ZSt11lower_boundIPxxET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %184, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %186 = ptrtoint ptr %185 to i64
  %187 = sub i64 %186, ptrtoint (ptr @que to i64)
  %188 = sdiv exact i64 %187, 8
  %189 = add nsw i64 %188, 1
  %190 = trunc i64 %189 to i32
  store i32 %190, ptr %7, align 4, !tbaa !5
  %191 = load i32, ptr %7, align 4, !tbaa !5
  %192 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z6updateii(i32 noundef %191, i32 noundef %192)
  %193 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) @ans, i32 noundef %193)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %194

194:                                              ; preds = %113
  %195 = load i32, ptr %5, align 4, !tbaa !5
  %196 = add nsw i32 %195, 1
  store i32 %196, ptr %5, align 4, !tbaa !5
  br label %108, !llvm.loop !13

197:                                              ; preds = %112
  br label %198

198:                                              ; preds = %197
  %199 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %199, ptr %1, align 4, !tbaa !5
  br label %9, !llvm.loop !14

200:                                              ; preds = %13
  ret void
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPxxET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) #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 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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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"

@m = external dso_local local_unnamed_addr global i32, align 4
@C = external dso_local local_unnamed_addr global i32, align 4
@x = external dso_local local_unnamed_addr global [100001 x i32], align 16
@y = external dso_local local_unnamed_addr global [100001 x i32], align 16
@p = external dso_local local_unnamed_addr global [100001 x i32], align 16
@ord = external dso_local local_unnamed_addr global [100001 x i32], align 16
@ans = external dso_local global i32, align 4
@sz = external dso_local local_unnamed_addr global i32, align 4
@bit = external dso_local local_unnamed_addr global [100001 x i32], align 16
@que = external dso_local global [100001 x i64], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5queryi(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 uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = load i32, ptr @m, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph34, label %._crit_edge

.loopexit:                                        ; preds = %.lr.ph, %.critedge
  %4 = load i32, ptr @m, align 4, !tbaa !5
  %5 = icmp slt i32 %.1.lcssa, %4
  br i1 %5, label %.lr.ph34, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.loopexit, %0
  ret void

.lr.ph34:                                         ; preds = %0, %.loopexit
  %6 = phi i32 [ %4, %.loopexit ], [ %2, %0 ]
  %.033 = phi i32 [ %.1.lcssa, %.loopexit ], [ 0, %0 ]
  store i32 0, ptr @sz, align 4, !tbaa !5
  %7 = sext i32 %.033 to i64
  %8 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds [100001 x i32], ptr @y, i64 0, i64 %10
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sub nsw i32 %12, %14
  %16 = sext i32 %6 to i64
  %17 = add nsw i32 %.033, 1
  %smax = call i32 @llvm.smax.i32(i32 %6, i32 %17)
  br label %18

18:                                               ; preds = %.lr.ph34, %45
  %indvars.iv35 = phi i64 [ 0, %.lr.ph34 ], [ %indvars.iv.next36, %45 ]
  %indvars.iv = phi i64 [ %7, %.lr.ph34 ], [ %indvars.iv.next, %45 ]
  %19 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds [100001 x i32], ptr @y, i64 0, i64 %21
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sub nsw i32 %23, %25
  %27 = icmp eq i32 %26, %15
  br i1 %27, label %45, label %.critedge.split.loop.exit44

.critedge.split.loop.exit44:                      ; preds = %18
  %28 = trunc nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge:                                        ; preds = %45, %.critedge.split.loop.exit44
  %29 = phi i64 [ %indvars.iv35, %.critedge.split.loop.exit44 ], [ %indvars.iv.next36, %45 ]
  %.1.lcssa = phi i32 [ %28, %.critedge.split.loop.exit44 ], [ %smax, %45 ]
  %sext43 = shl i64 %29, 32
  %30 = ashr exact i64 %sext43, 29
  %31 = getelementptr inbounds i8, ptr @que, i64 %30
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %31)
  %32 = load i32, ptr @sz, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i64, ptr @que, i64 %33
  %35 = call noundef ptr @_ZSt6uniqueIPxET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %34)
  %36 = ptrtoint ptr %35 to i64
  %37 = sub i64 %36, ptrtoint (ptr @que to i64)
  %38 = lshr exact i64 %37, 3
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr @sz, align 4, !tbaa !5
  %sext = shl i64 %37, 29
  %40 = ashr i64 %sext, 30
  %41 = and i64 %40, -4
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @bit, i64 4), i8 0, i64 %41, i1 false)
  %42 = ashr i64 %sext, 32
  %43 = getelementptr inbounds [100001 x i64], ptr @que, i64 0, i64 %42
  store i64 1000000000000000, ptr %43, align 8, !tbaa !11
  %44 = icmp slt i32 %.033, %.1.lcssa
  br i1 %44, label %.lr.ph, label %.loopexit

45:                                               ; preds = %18
  %46 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %21
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = mul nsw i64 %48, %48
  %50 = sext i32 %23 to i64
  %51 = add nsw i64 %49, %50
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %52 = trunc nsw i64 %indvars.iv.next36 to i32
  store i32 %52, ptr @sz, align 4, !tbaa !5
  %53 = getelementptr inbounds [100001 x i64], ptr @que, i64 0, i64 %indvars.iv35
  store i64 %51, ptr %53, align 8, !tbaa !11
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %54 = icmp slt i64 %indvars.iv.next, %16
  br i1 %54, label %18, label %.critedge, !llvm.loop !13

.lr.ph:                                           ; preds = %.critedge, %.lr.ph
  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %.lr.ph ], [ %7, %.critedge ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %55 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv40
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %57
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = mul nsw i64 %63, %63
  %65 = load i32, ptr @C, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %.neg30 = add nsw i64 %60, 1
  %67 = add nsw i64 %64, %66
  %68 = sub nsw i64 %.neg30, %67
  store i64 %68, ptr %1, align 8, !tbaa !11
  %69 = load i32, ptr @sz, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %gep = getelementptr i64, ptr getelementptr inbounds (i8, ptr @que, i64 8), i64 %70
  %71 = call noundef ptr @_ZSt11upper_boundIPxxET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %gep, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %72 = ptrtoint ptr %71 to i64
  %73 = sub i64 %72, ptrtoint (ptr @que to i64)
  %74 = lshr exact i64 %73, 3
  %75 = trunc i64 %74 to i32
  %76 = call noundef i32 @_Z5queryi(i32 noundef %75)
  %77 = add nsw i32 %76, 1
  %78 = load i32, ptr %55, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = mul nsw i64 %82, %82
  %84 = getelementptr inbounds [100001 x i32], ptr @x, i64 0, i64 %79
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = add nsw i64 %83, %86
  store i64 %87, ptr %1, align 8, !tbaa !11
  %88 = load i32, ptr @sz, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i64, ptr @que, i64 %89
  %91 = call noundef ptr @_ZSt11lower_boundIPxxET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %90, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %92 = ptrtoint ptr %91 to i64
  %93 = sub i64 %92, ptrtoint (ptr @que to i64)
  %94 = lshr exact i64 %93, 3
  %95 = trunc i64 %94 to i32
  %96 = add i32 %95, 1
  call void @_Z6updateii(i32 noundef %96, i32 noundef %77)
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) @ans, i32 noundef %77)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %indvars.iv.next41 = add nsw i64 %indvars.iv40, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next41 to i32
  %exitcond.not = icmp eq i32 %.1.lcssa, %lftr.wideiv
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !14
}

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #5

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 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 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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