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

; 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
@l = external dso_local global [5001 x i32], align 16
@r = external dso_local global [5001 x i32], align 16
@v = external dso_local global [5001 x i32], align 16
@ord = external dso_local global [5001 x i32], align 16
@b = external dso_local global [5001 x i32], align 16
@match = external dso_local global [5001 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 [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

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

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

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

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i32, ptr @l, i64 %16
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr @r, i64 %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr @v, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %17, ptr noundef %20, ptr noundef %23)
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %27
  store i32 %25, ptr %28, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %14
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !9

32:                                               ; preds = %13
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr @ord, i64 %34
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %35, ptr noundef @_Z4cmp1RKiS0_)
  %36 = load i32, ptr @ord, align 16, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [5001 x i32], ptr @l, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  store i32 %39, ptr @b, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %63, %32
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

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

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %4, align 4, !tbaa !5
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [5001 x i32], ptr @l, i64 0, i64 %56
  %58 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %57)
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %61
  store i32 %59, ptr %62, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %63

63:                                               ; preds = %45
  %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 %40, !llvm.loop !11

66:                                               ; preds = %44
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %68
  store i32 1061109567, ptr %69, align 4, !tbaa !5
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr @ord, i64 %71
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %72, ptr noundef @_Z4cmp2RKiS0_)
  %73 = load i32, ptr @n, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = mul i64 %74, 4
  call void @llvm.memset.p0.i64(ptr align 16 @match, i8 -1, i64 %75, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %76

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

80:                                               ; preds = %76
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %141

81:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %133, %81
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = load i32, ptr @n, align 4, !tbaa !5
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 11, ptr %6, align 4
  br label %136

87:                                               ; preds = %82
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [5001 x i32], ptr @l, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = icmp sle i32 %94, %98
  br i1 %99, label %100, label %132

100:                                              ; preds = %87
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [5001 x i32], ptr @r, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = icmp sle i32 %104, %111
  br i1 %112, label %113, label %132

113:                                              ; preds = %100
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = load i32, ptr %7, align 4, !tbaa !5
  %119 = call noundef zeroext i1 @_Z4findii(i32 noundef %117, i32 noundef %118)
  br i1 %119, label %120, label %131

120:                                              ; preds = %113
  %121 = load i32, ptr %5, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [5001 x i32], ptr @v, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = load i64, ptr @ans, align 8, !tbaa !12
  %130 = add nsw i64 %129, %128
  store i64 %130, ptr @ans, align 8, !tbaa !12
  br label %131

131:                                              ; preds = %120, %113
  store i32 11, ptr %6, align 4
  br label %136

132:                                              ; preds = %100, %87
  br label %133

133:                                              ; preds = %132
  %134 = load i32, ptr %7, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %7, align 4, !tbaa !5
  br label %82, !llvm.loop !14

136:                                              ; preds = %131, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %137

137:                                              ; preds = %136
  br label %138

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

141:                                              ; preds = %80
  %142 = load i64, ptr @ans, align 8, !tbaa !12
  %143 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %142)
  ret i32 0
}

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

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

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

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

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

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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { 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 #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { 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 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !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
@l = external dso_local global [5001 x i32], align 16
@r = external dso_local global [5001 x i32], align 16
@v = external dso_local global [5001 x i32], align 16
@ord = external dso_local global [5001 x i32], align 16
@b = external dso_local local_unnamed_addr global [5001 x i32], align 16
@match = external dso_local local_unnamed_addr global [5001 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 [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z4findii(i32 noundef, i32 noundef) 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = sext i32 %3 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %19, %.lr.ph ]
  %5 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %5, ptr noundef nonnull @_Z4cmp1RKiS0_)
  %6 = load i32, ptr @ord, align 16, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [5001 x i32], ptr @l, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %9, ptr @b, align 16, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 1
  br i1 %11, label %.lr.ph37, label %._crit_edge.._crit_edge38_crit_edge

._crit_edge.._crit_edge38_crit_edge:              ; preds = %._crit_edge
  %.pre58 = sext i32 %10 to i64
  br label %._crit_edge38

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %12 = getelementptr inbounds i32, ptr @l, i64 %indvars.iv
  %13 = getelementptr inbounds i32, ptr @r, i64 %indvars.iv
  %14 = getelementptr inbounds i32, ptr @v, i64 %indvars.iv
  %15 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull %14)
  %16 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %indvars.iv
  %17 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %17, ptr %16, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge38:                                    ; preds = %.lr.ph37, %._crit_edge.._crit_edge38_crit_edge
  %.pre-phi59 = phi i64 [ %.pre58, %._crit_edge.._crit_edge38_crit_edge ], [ %37, %.lr.ph37 ]
  %21 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %.pre-phi59
  store i32 1061109567, ptr %21, align 4, !tbaa !5
  %22 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi59
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %22, ptr noundef nonnull @_Z4cmp2RKiS0_)
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = shl nsw i64 %24, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @match, i8 -1, i64 %25, i1 false)
  %26 = icmp sgt i32 %23, 0
  br i1 %26, label %.preheader, label %._crit_edge45

.lr.ph37:                                         ; preds = %._crit_edge, %.lr.ph37
  %27 = phi i32 [ %34, %.lr.ph37 ], [ %9, %._crit_edge ]
  %indvars.iv49 = phi i64 [ %indvars.iv.next50, %.lr.ph37 ], [ 1, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %1, align 4, !tbaa !5
  %29 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %indvars.iv49
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [5001 x i32], ptr @l, i64 0, i64 %31
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %32)
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %indvars.iv49
  store i32 %34, ptr %35, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next50, %37
  br i1 %38, label %.lr.ph37, label %._crit_edge38, !llvm.loop !11

.preheader:                                       ; preds = %._crit_edge38, %.loopexit
  %indvars.iv55 = phi i64 [ %indvars.iv.next56, %.loopexit ], [ 0, %._crit_edge38 ]
  %39 = phi i32 [ %66, %.loopexit ], [ %23, %._crit_edge38 ]
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %.lr.ph42, label %.loopexit

.lr.ph42:                                         ; preds = %.preheader
  %41 = getelementptr inbounds [5001 x i32], ptr @ord, i64 0, i64 %indvars.iv55
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [5001 x i32], ptr @l, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = getelementptr inbounds [5001 x i32], ptr @r, i64 0, i64 %43
  %wide.trip.count = zext nneg i32 %39 to i64
  br label %49

._crit_edge45:                                    ; preds = %.loopexit, %._crit_edge38
  %47 = load i64, ptr @ans, align 8, !tbaa !12
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %47)
  ret i32 0

49:                                               ; preds = %.lr.ph42, %65
  %indvars.iv52 = phi i64 [ 0, %.lr.ph42 ], [ %indvars.iv.next53, %65 ]
  %50 = getelementptr inbounds [5001 x i32], ptr @b, i64 0, i64 %indvars.iv52
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %.not = icmp sgt i32 %45, %51
  br i1 %.not, label %65, label %52

52:                                               ; preds = %49
  %53 = load i32, ptr %46, align 4, !tbaa !5
  %.not29 = icmp sgt i32 %51, %53
  br i1 %.not29, label %65, label %54

54:                                               ; preds = %52
  %55 = trunc nuw nsw i64 %indvars.iv52 to i32
  %56 = call noundef zeroext i1 @_Z4findii(i32 noundef %42, i32 noundef %55)
  br i1 %56, label %57, label %.loopexit

57:                                               ; preds = %54
  %58 = load i32, ptr %41, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [5001 x i32], ptr @v, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = load i64, ptr @ans, align 8, !tbaa !12
  %64 = add nsw i64 %63, %62
  store i64 %64, ptr @ans, align 8, !tbaa !12
  br label %.loopexit

65:                                               ; preds = %49, %52
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next53, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %49, !llvm.loop !14

.loopexit:                                        ; preds = %65, %.preheader, %54, %57
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = icmp slt i64 %indvars.iv.next56, %67
  br i1 %68, label %.preheader, label %._crit_edge45, !llvm.loop !15
}

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

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

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

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

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

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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { 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 #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { 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 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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