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

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

@n = external dso_local global i32, align 4
@a = external dso_local global [50001 x i32], align 16
@L = external dso_local global [50001 x i32], align 16
@R = external dso_local global [50001 x i32], align 16
@idx = external dso_local global i32, align 4
@que = external dso_local global [50001 x i32], align 16
@ord = external dso_local global [50001 x i32], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updii(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 nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %22, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i32, ptr @a, i64 %15
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %16)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [50001 x i32], ptr @ord, i64 0, i64 %20
  store i32 %18, ptr %21, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %13
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !9

25:                                               ; preds = %12
  store i32 50001, ptr @a, align 16, !tbaa !5
  store i32 0, ptr @idx, align 4, !tbaa !5
  store i32 0, ptr @que, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %63, %25
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = icmp sle i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %66

31:                                               ; preds = %26
  br label %32

32:                                               ; preds = %46, %31
  %33 = load i32, ptr @idx, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp sle i32 %39, %43
  br i1 %44, label %45, label %49

45:                                               ; preds = %32
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr @idx, align 4, !tbaa !5
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr @idx, align 4, !tbaa !5
  br label %32, !llvm.loop !11

49:                                               ; preds = %32
  %50 = load i32, ptr @idx, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [50001 x i32], ptr @L, i64 0, i64 %56
  store i32 %54, ptr %57, align 4, !tbaa !5
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = load i32, ptr @idx, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr @idx, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %61
  store i32 %58, ptr %62, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %49
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %3, align 4, !tbaa !5
  br label %26, !llvm.loop !12

66:                                               ; preds = %30
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %69
  store i32 0, ptr %70, align 4, !tbaa !5
  %71 = load i32, ptr @n, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 0, ptr @idx, align 4, !tbaa !5
  store i32 %72, ptr @que, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %73 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %73, ptr %4, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %110, %66
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = icmp sge i32 %75, 1
  br i1 %76, label %78, label %77

77:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %113

78:                                               ; preds = %74
  br label %79

79:                                               ; preds = %93, %78
  %80 = load i32, ptr @idx, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = icmp sge i32 %86, %90
  br i1 %91, label %92, label %96

92:                                               ; preds = %79
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr @idx, align 4, !tbaa !5
  %95 = add nsw i32 %94, -1
  store i32 %95, ptr @idx, align 4, !tbaa !5
  br label %79, !llvm.loop !13

96:                                               ; preds = %79
  %97 = load i32, ptr @idx, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = sub nsw i32 %100, 1
  %102 = load i32, ptr %4, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [50001 x i32], ptr @R, i64 0, i64 %103
  store i32 %101, ptr %104, align 4, !tbaa !5
  %105 = load i32, ptr %4, align 4, !tbaa !5
  %106 = load i32, ptr @idx, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr @idx, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %108
  store i32 %105, ptr %109, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %96
  %111 = load i32, ptr %4, align 4, !tbaa !5
  %112 = add nsw i32 %111, -1
  store i32 %112, ptr %4, align 4, !tbaa !5
  br label %74, !llvm.loop !14

113:                                              ; preds = %77
  %114 = load i32, ptr @n, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds i32, ptr @ord, i64 %115
  %117 = getelementptr inbounds i32, ptr %116, i64 1
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef getelementptr inbounds (i32, ptr @ord, i64 1), ptr noundef %117, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %161, %113
  %119 = load i32, ptr %5, align 4, !tbaa !5
  %120 = load i32, ptr @n, align 4, !tbaa !5
  %121 = icmp sle i32 %119, %120
  br i1 %121, label %123, label %122

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

123:                                              ; preds = %118
  br label %124

124:                                              ; preds = %145, %123
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = load i32, ptr @n, align 4, !tbaa !5
  %127 = icmp sle i32 %125, %126
  br i1 %127, label %128, label %138

128:                                              ; preds = %124
  %129 = load i32, ptr %6, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [50001 x i32], ptr @ord, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [50001 x i32], ptr @L, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = load i32, ptr %5, align 4, !tbaa !5
  %137 = icmp sle i32 %135, %136
  br label %138

138:                                              ; preds = %128, %124
  %139 = phi i1 [ false, %124 ], [ %137, %128 ]
  br i1 %139, label %140, label %148

140:                                              ; preds = %138
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [50001 x i32], ptr @ord, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  call void @_Z3updii(i32 noundef %144, i32 noundef 1)
  br label %145

145:                                              ; preds = %140
  %146 = load i32, ptr %6, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %6, align 4, !tbaa !5
  br label %124, !llvm.loop !15

148:                                              ; preds = %138
  %149 = load i32, ptr %5, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [50001 x i32], ptr @R, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = call noundef i32 @_Z3sumi(i32 noundef %152)
  %154 = load i32, ptr %5, align 4, !tbaa !5
  %155 = sub nsw i32 %154, 1
  %156 = call noundef i32 @_Z3sumi(i32 noundef %155)
  %157 = sub nsw i32 %153, %156
  %158 = sext i32 %157 to i64
  %159 = load i64, ptr @ans, align 8, !tbaa !16
  %160 = add nsw i64 %159, %158
  store i64 %160, ptr @ans, align 8, !tbaa !16
  br label %161

161:                                              ; preds = %148
  %162 = load i32, ptr %5, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %5, align 4, !tbaa !5
  br label %118, !llvm.loop !18

164:                                              ; preds = %122
  %165 = load i64, ptr @ans, align 8, !tbaa !16
  %166 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %165)
  ret i32 0
}

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

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !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"

@n = external dso_local global i32, align 4
@a = external dso_local global [50001 x i32], align 16
@L = external dso_local local_unnamed_addr global [50001 x i32], align 16
@R = external dso_local local_unnamed_addr global [50001 x i32], align 16
@idx = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local local_unnamed_addr global [50001 x i32], align 16
@ord = external dso_local global [50001 x i32], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3updii(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 nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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
  %.not43 = icmp slt i32 %2, 1
  br i1 %.not43, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %0
  store i32 50001, ptr @a, align 16, !tbaa !5
  br label %.thread

._crit_edge:                                      ; preds = %.lr.ph
  store i32 50001, ptr @a, align 16, !tbaa !5
  store i32 0, ptr @que, align 16, !tbaa !5
  %.not2954 = icmp slt i32 %10, 1
  br i1 %.not2954, label %.thread, label %.preheader36.preheader

.thread:                                          ; preds = %._crit_edge, %._crit_edge.thread
  %.lcssa42111 = phi i32 [ %2, %._crit_edge.thread ], [ %10, %._crit_edge ]
  %.pre107 = add nsw i32 %.lcssa42111, 1
  %3 = sext i32 %.pre107 to i64
  %4 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %3
  store i32 0, ptr %4, align 4, !tbaa !5
  store i32 0, ptr @idx, align 4, !tbaa !5
  store i32 %.pre107, ptr @que, align 16, !tbaa !5
  br label %41

.preheader36.preheader:                           ; preds = %._crit_edge
  %5 = add nuw i32 %10, 1
  %wide.trip.count = zext i32 %5 to i64
  br label %.preheader36

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %6 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6)
  %8 = getelementptr inbounds [50001 x i32], ptr @ord, i64 0, i64 %indvars.iv
  %9 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %9, ptr %8, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %.not.not = icmp slt i64 %indvars.iv, %11
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader36:                                     ; preds = %.preheader36.preheader, %._crit_edge47
  %12 = phi i32 [ 0, %.preheader36.preheader ], [ %33, %._crit_edge47 ]
  %indvars.iv91 = phi i64 [ 1, %.preheader36.preheader ], [ %indvars.iv.next92, %._crit_edge47 ]
  %.lcssa515355 = phi i32 [ 0, %.preheader36.preheader ], [ %30, %._crit_edge47 ]
  %13 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv91
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %12 to i64
  %16 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %.not3445 = icmp sgt i32 %17, %14
  br i1 %.not3445, label %._crit_edge47, label %.lr.ph46.preheader

.lr.ph46.preheader:                               ; preds = %.preheader36
  %18 = sext i32 %.lcssa515355 to i64
  br label %.lr.ph46

.preheader35.preheader:                           ; preds = %._crit_edge47
  %19 = sext i32 %5 to i64
  %20 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %19
  store i32 0, ptr %20, align 4, !tbaa !5
  store i32 0, ptr @idx, align 4, !tbaa !5
  store i32 %5, ptr @que, align 16, !tbaa !5
  %21 = zext nneg i32 %10 to i64
  br label %.preheader35

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %.lr.ph46
  %indvars.iv88 = phi i64 [ %18, %.lr.ph46.preheader ], [ %indvars.iv.next89, %.lr.ph46 ]
  %indvars.iv.next89 = add nsw i64 %indvars.iv88, -1
  %22 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %indvars.iv.next89
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %.not34 = icmp sgt i32 %26, %14
  br i1 %.not34, label %._crit_edge47.loopexit, label %.lr.ph46, !llvm.loop !11

._crit_edge47.loopexit:                           ; preds = %.lr.ph46
  %27 = trunc nsw i64 %indvars.iv.next89 to i32
  br label %._crit_edge47

._crit_edge47:                                    ; preds = %._crit_edge47.loopexit, %.preheader36
  %.lcssa41 = phi i32 [ %.lcssa515355, %.preheader36 ], [ %27, %._crit_edge47.loopexit ]
  %.lcssa40 = phi i32 [ %12, %.preheader36 ], [ %23, %._crit_edge47.loopexit ]
  %28 = add nsw i32 %.lcssa40, 1
  %29 = getelementptr inbounds [50001 x i32], ptr @L, i64 0, i64 %indvars.iv91
  store i32 %28, ptr %29, align 4, !tbaa !5
  %30 = add nsw i32 %.lcssa41, 1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %31
  %33 = trunc nuw nsw i64 %indvars.iv91 to i32
  store i32 %33, ptr %32, align 4, !tbaa !5
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next92, %wide.trip.count
  br i1 %exitcond.not, label %.preheader35.preheader, label %.preheader36, !llvm.loop !12

.preheader35:                                     ; preds = %.preheader35.preheader, %._crit_edge61
  %34 = phi i32 [ %5, %.preheader35.preheader ], [ %57, %._crit_edge61 ]
  %indvars.iv97 = phi i64 [ %21, %.preheader35.preheader ], [ %indvars.iv.next98, %._crit_edge61 ]
  %.lcssa656768 = phi i32 [ 0, %.preheader35.preheader ], [ %54, %._crit_edge61 ]
  %35 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %indvars.iv97
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %34 to i64
  %38 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %.not3359 = icmp slt i32 %39, %36
  br i1 %.not3359, label %._crit_edge61, label %.lr.ph60.preheader

.lr.ph60.preheader:                               ; preds = %.preheader35
  %40 = sext i32 %.lcssa656768 to i64
  br label %.lr.ph60

._crit_edge70:                                    ; preds = %._crit_edge61
  store i32 %54, ptr @idx, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %.thread, %._crit_edge70
  %.lcssa42110114 = phi i32 [ %.lcssa42111, %.thread ], [ %10, %._crit_edge70 ]
  %42 = sext i32 %.lcssa42110114 to i64
  %43 = getelementptr inbounds i32, ptr @ord, i64 %42
  %44 = getelementptr inbounds i8, ptr %43, i64 4
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @ord, i64 4), ptr noundef nonnull %44, ptr noundef nonnull @_Z3cmpRKiS0_)
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %.not3077 = icmp slt i32 %45, 1
  br i1 %.not3077, label %.._crit_edge80_crit_edge, label %.preheader

.._crit_edge80_crit_edge:                         ; preds = %41
  %.pre = load i64, ptr @ans, align 8, !tbaa !13
  br label %._crit_edge80

.lr.ph60:                                         ; preds = %.lr.ph60.preheader, %.lr.ph60
  %indvars.iv94 = phi i64 [ %40, %.lr.ph60.preheader ], [ %indvars.iv.next95, %.lr.ph60 ]
  %indvars.iv.next95 = add nsw i64 %indvars.iv94, -1
  %46 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %indvars.iv.next95
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [50001 x i32], ptr @a, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %.not33 = icmp slt i32 %50, %36
  br i1 %.not33, label %._crit_edge61.loopexit, label %.lr.ph60, !llvm.loop !15

._crit_edge61.loopexit:                           ; preds = %.lr.ph60
  %51 = trunc nsw i64 %indvars.iv.next95 to i32
  br label %._crit_edge61

._crit_edge61:                                    ; preds = %._crit_edge61.loopexit, %.preheader35
  %.lcssa38 = phi i32 [ %.lcssa656768, %.preheader35 ], [ %51, %._crit_edge61.loopexit ]
  %.lcssa37 = phi i32 [ %34, %.preheader35 ], [ %47, %._crit_edge61.loopexit ]
  %52 = add nsw i32 %.lcssa37, -1
  %53 = getelementptr inbounds [50001 x i32], ptr @R, i64 0, i64 %indvars.iv97
  store i32 %52, ptr %53, align 4, !tbaa !5
  %54 = add nsw i32 %.lcssa38, 1
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %55
  %57 = trunc nuw nsw i64 %indvars.iv97 to i32
  store i32 %57, ptr %56, align 4, !tbaa !5
  %indvars.iv.next98 = add nsw i64 %indvars.iv97, -1
  %58 = icmp sgt i64 %indvars.iv97, 1
  br i1 %58, label %.preheader35, label %._crit_edge70, !llvm.loop !16

.preheader:                                       ; preds = %41, %.critedge
  %59 = phi i32 [ %82, %.critedge ], [ %45, %41 ]
  %indvars.iv103 = phi i64 [ %indvars.iv.next104, %.critedge ], [ 1, %41 ]
  %.079 = phi i32 [ %.1.lcssa, %.critedge ], [ 1, %41 ]
  %.not3171 = icmp sgt i32 %.079, %59
  br i1 %.not3171, label %.critedge, label %.lr.ph73.preheader

.lr.ph73.preheader:                               ; preds = %.preheader
  %60 = sext i32 %.079 to i64
  br label %.lr.ph73

._crit_edge80:                                    ; preds = %.critedge, %.._crit_edge80_crit_edge
  %61 = phi i64 [ %.pre, %.._crit_edge80_crit_edge ], [ %81, %.critedge ]
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %61)
  ret i32 0

.lr.ph73:                                         ; preds = %.lr.ph73.preheader, %69
  %indvars.iv100 = phi i64 [ %60, %.lr.ph73.preheader ], [ %indvars.iv.next101, %69 ]
  %63 = getelementptr inbounds [50001 x i32], ptr @ord, i64 0, i64 %indvars.iv100
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [50001 x i32], ptr @L, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %.not32 = icmp slt i64 %indvars.iv103, %68
  br i1 %.not32, label %.critedge.loopexit, label %69

69:                                               ; preds = %.lr.ph73
  tail call void @_Z3updii(i32 noundef %64, i32 noundef 1)
  %indvars.iv.next101 = add nsw i64 %indvars.iv100, 1
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %.not31.not = icmp slt i64 %indvars.iv100, %71
  br i1 %.not31.not, label %.lr.ph73, label %.critedge.loopexit, !llvm.loop !17

.critedge.loopexit:                               ; preds = %69, %.lr.ph73
  %.1.lcssa.ph.in = phi i64 [ %indvars.iv100, %.lr.ph73 ], [ %indvars.iv.next101, %69 ]
  %.1.lcssa.ph = trunc i64 %.1.lcssa.ph.in to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader
  %.1.lcssa = phi i32 [ %.079, %.preheader ], [ %.1.lcssa.ph, %.critedge.loopexit ]
  %72 = getelementptr inbounds [50001 x i32], ptr @R, i64 0, i64 %indvars.iv103
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = tail call noundef i32 @_Z3sumi(i32 noundef %73)
  %75 = trunc i64 %indvars.iv103 to i32
  %76 = add i32 %75, -1
  %77 = tail call noundef i32 @_Z3sumi(i32 noundef %76)
  %78 = sub nsw i32 %74, %77
  %79 = sext i32 %78 to i64
  %80 = load i64, ptr @ans, align 8, !tbaa !13
  %81 = add nsw i64 %80, %79
  store i64 %81, ptr @ans, align 8, !tbaa !13
  %indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %.not30.not = icmp slt i64 %indvars.iv103, %83
  br i1 %.not30.not, label %.preheader, label %._crit_edge80, !llvm.loop !18
}

; 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 @_ZSt4sortIPiPFbRKiS2_EEvT_S5_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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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