; LLVM IR from tangjz/acm-icpc :: codeforces/complete (529B)

; 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.Person = type { i32, i32 }

@n = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@a = external dso_local global [1001 x %struct.Person], align 16
@b = external dso_local global [1001 x %struct.Person], 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 norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %27, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1001 x %struct.Person], ptr @a, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.Person, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1001 x %struct.Person], ptr @a, i64 0, i64 %23
  %25 = getelementptr inbounds %struct.Person, ptr %24, i32 0, i32 1
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %21, ptr noundef %25)
  br label %27

27:                                               ; preds = %17
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

30:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %167, %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 1010
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %170

35:                                               ; preds = %31
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @b, ptr align 16 @a, i64 8008, i1 false)
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #6
  store i8 0, ptr %5, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %71, %35
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 8, ptr %4, align 4
  br label %74

41:                                               ; preds = %36
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.Person, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !13
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = icmp sgt i32 %46, %47
  br i1 %48, label %49, label %70

49:                                               ; preds = %41
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.Person, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !15
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = icmp sgt i32 %54, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %49
  store i8 1, ptr %5, align 1, !tbaa !11
  store i32 8, ptr %4, align 4
  br label %74

58:                                               ; preds = %49
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.Person, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %64
  %66 = getelementptr inbounds %struct.Person, ptr %65, i32 0, i32 1
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %62, ptr noundef nonnull align 4 dereferenceable(4) %66) #6
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %58
  br label %70

70:                                               ; preds = %69, %41
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %7, align 4, !tbaa !5
  br label %36, !llvm.loop !16

74:                                               ; preds = %57, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %75

75:                                               ; preds = %74
  %76 = load i8, ptr %5, align 1, !tbaa !11, !range !17, !noundef !18
  %77 = trunc i8 %76 to i1
  br i1 %77, label %83, label %78

78:                                               ; preds = %75
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = mul nsw i32 %79, 2
  %81 = load i32, ptr @n, align 4, !tbaa !5
  %82 = icmp sgt i32 %80, %81
  br i1 %82, label %83, label %84

83:                                               ; preds = %78, %75
  store i32 7, ptr %4, align 4
  br label %164

84:                                               ; preds = %78
  %85 = load i32, ptr @n, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds %struct.Person, ptr @b, i64 %86
  call void @_ZSt4sortIP6PersonEvT_S2_(ptr noundef @b, ptr noundef %87)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %133, %84
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %92, label %98

92:                                               ; preds = %88
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  %95 = mul nsw i32 %94, 2
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = icmp sle i32 %95, %96
  br label %98

98:                                               ; preds = %92, %88
  %99 = phi i1 [ false, %88 ], [ %97, %92 ]
  br i1 %99, label %101, label %100

100:                                              ; preds = %98
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %136

101:                                              ; preds = %98
  %102 = load i32, ptr %8, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %103
  %105 = getelementptr inbounds %struct.Person, ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 8, !tbaa !15
  %107 = load i32, ptr %3, align 4, !tbaa !5
  %108 = icmp sle i32 %106, %107
  br i1 %108, label %109, label %132

109:                                              ; preds = %101
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %111
  %113 = getelementptr inbounds %struct.Person, ptr %112, i32 0, i32 1
  %114 = load i32, ptr %113, align 4, !tbaa !13
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %116
  %118 = getelementptr inbounds %struct.Person, ptr %117, i32 0, i32 0
  %119 = load i32, ptr %118, align 8, !tbaa !15
  %120 = icmp slt i32 %114, %119
  br i1 %120, label %121, label %132

121:                                              ; preds = %109
  %122 = load i32, ptr %8, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %123
  %125 = getelementptr inbounds %struct.Person, ptr %124, i32 0, i32 0
  %126 = load i32, ptr %8, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %127
  %129 = getelementptr inbounds %struct.Person, ptr %128, i32 0, i32 1
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %125, ptr noundef nonnull align 4 dereferenceable(4) %129) #6
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %6, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %121, %109, %101
  br label %133

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

136:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %150, %136
  %138 = load i32, ptr %10, align 4, !tbaa !5
  %139 = load i32, ptr @n, align 4, !tbaa !5
  %140 = icmp slt i32 %138, %139
  br i1 %140, label %142, label %141

141:                                              ; preds = %137
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %153

142:                                              ; preds = %137
  %143 = load i32, ptr %10, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %144
  %146 = getelementptr inbounds %struct.Person, ptr %145, i32 0, i32 0
  %147 = load i32, ptr %146, align 8, !tbaa !15
  %148 = load i32, ptr %9, align 4, !tbaa !5
  %149 = add nsw i32 %148, %147
  store i32 %149, ptr %9, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %142
  %151 = load i32, ptr %10, align 4, !tbaa !5
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %10, align 4, !tbaa !5
  br label %137, !llvm.loop !20

153:                                              ; preds = %141
  %154 = load i32, ptr @ans, align 4, !tbaa !5
  %155 = load i32, ptr %9, align 4, !tbaa !5
  %156 = load i32, ptr %3, align 4, !tbaa !5
  %157 = mul nsw i32 %155, %156
  %158 = icmp sgt i32 %154, %157
  br i1 %158, label %159, label %163

159:                                              ; preds = %153
  %160 = load i32, ptr %9, align 4, !tbaa !5
  %161 = load i32, ptr %3, align 4, !tbaa !5
  %162 = mul nsw i32 %160, %161
  store i32 %162, ptr @ans, align 4, !tbaa !5
  br label %163

163:                                              ; preds = %159, %153
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  store i32 0, ptr %4, align 4
  br label %164

164:                                              ; preds = %163, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #6
  %165 = load i32, ptr %4, align 4
  switch i32 %165, label %173 [
    i32 0, label %166
    i32 7, label %167
  ]

166:                                              ; preds = %164
  br label %167

167:                                              ; preds = %166, %164
  %168 = load i32, ptr %3, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !21

170:                                              ; preds = %34
  %171 = load i32, ptr @ans, align 4, !tbaa !5
  %172 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %171)
  ret i32 0

173:                                              ; preds = %164
  unreachable
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: 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) #3

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

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

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

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

%struct.Person = type { i32, i32 }

@n = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local global [1001 x %struct.Person], align 16
@b = external dso_local global [1001 x %struct.Person], 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.lr.ph, %0
  %.ph101 = phi i32 [ %2, %0 ], [ %7, %.lr.ph ]
  br label %.preheader

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

10:                                               ; preds = %.loopexit
  %11 = load i32, ptr @ans, align 4, !tbaa !5
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %11)
  ret i32 0

.preheader:                                       ; preds = %.preheader.preheader, %.loopexit
  %13 = phi i32 [ %72, %.loopexit ], [ %.ph101, %.preheader.preheader ]
  %14 = phi i32 [ %73, %.loopexit ], [ %.ph101, %.preheader.preheader ]
  %.04067 = phi i32 [ %74, %.loopexit ], [ 1, %.preheader.preheader ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(8008) @b, ptr noundef nonnull align 16 dereferenceable(8008) @a, i64 8008, i1 false)
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph55, label %.critedge48

.lr.ph55:                                         ; preds = %.preheader, %27
  %16 = phi i32 [ %28, %27 ], [ %13, %.preheader ]
  %17 = phi i32 [ %28, %27 ], [ %14, %.preheader ]
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %27 ], [ 0, %.preheader ]
  %.03853 = phi i32 [ %.1, %27 ], [ 0, %.preheader ]
  %18 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %indvars.iv72
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = icmp sgt i32 %20, %.04067
  br i1 %21, label %22, label %27

22:                                               ; preds = %.lr.ph55
  %23 = load i32, ptr %18, align 8, !tbaa !13
  %24 = icmp sgt i32 %23, %.04067
  br i1 %24, label %.loopexit, label %25

25:                                               ; preds = %22
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %19) #6
  %26 = add nsw i32 %.03853, 1
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %.lr.ph55, %25
  %28 = phi i32 [ %.pre, %25 ], [ %16, %.lr.ph55 ]
  %.1 = phi i32 [ %26, %25 ], [ %.03853, %.lr.ph55 ]
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next73, %29
  br i1 %30, label %.lr.ph55, label %.critedge48, !llvm.loop !14

.critedge48:                                      ; preds = %27, %.preheader
  %31 = phi i32 [ %13, %.preheader ], [ %28, %27 ]
  %32 = phi i32 [ %14, %.preheader ], [ %28, %27 ]
  %.038.lcssa = phi i32 [ 0, %.preheader ], [ %.1, %27 ]
  %33 = shl nsw i32 %.038.lcssa, 1
  %34 = icmp sgt i32 %33, %32
  br i1 %34, label %.loopexit, label %35

35:                                               ; preds = %.critedge48
  %36 = sext i32 %32 to i64
  %37 = getelementptr inbounds %struct.Person, ptr @b, i64 %36
  tail call void @_ZSt4sortIP6PersonEvT_S2_(ptr noundef nonnull @b, ptr noundef nonnull %37)
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %.lr.ph59, label %._crit_edge

.lr.ph59:                                         ; preds = %35, %61
  %40 = phi i32 [ %62, %61 ], [ %38, %35 ]
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %61 ], [ 0, %35 ]
  %.257 = phi i32 [ %.3, %61 ], [ %.038.lcssa, %35 ]
  %41 = add nsw i32 %.257, 1
  %42 = shl nsw i32 %41, 1
  %.not = icmp sgt i32 %42, %40
  br i1 %.not, label %.critedge, label %53

.critedge:                                        ; preds = %.lr.ph59, %61
  %.lcssa51 = phi i32 [ %40, %.lr.ph59 ], [ %62, %61 ]
  %43 = icmp sgt i32 %.lcssa51, 0
  br i1 %43, label %.lr.ph65.preheader, label %._crit_edge

.lr.ph65.preheader:                               ; preds = %.critedge
  %wide.trip.count = zext nneg i32 %.lcssa51 to i64
  %min.iters.check = icmp ult i32 %.lcssa51, 9
  br i1 %min.iters.check, label %.lr.ph65.preheader100, label %vector.ph

.lr.ph65.preheader100:                            ; preds = %middle.block, %.lr.ph65.preheader
  %indvars.iv78.ph = phi i64 [ 0, %.lr.ph65.preheader ], [ %n.vec, %middle.block ]
  %.03563.ph = phi i32 [ 0, %.lr.ph65.preheader ], [ %52, %middle.block ]
  br label %.lr.ph65

vector.ph:                                        ; preds = %.lr.ph65.preheader
  %n.mod.vf = and i64 %wide.trip.count, 7
  %44 = icmp eq i64 %n.mod.vf, 0
  %45 = select i1 %44, i64 8, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count, %45
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %49, %vector.body ]
  %vec.phi97 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %50, %vector.body ]
  %46 = or disjoint i64 %index, 4
  %47 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %index
  %48 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %46
  %wide.vec = load <8 x i32>, ptr %47, align 16, !tbaa !13
  %wide.vec98 = load <8 x i32>, ptr %48, align 16, !tbaa !13
  %strided.vec = shufflevector <8 x i32> %wide.vec, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %strided.vec99 = shufflevector <8 x i32> %wide.vec98, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %49 = add <4 x i32> %strided.vec, %vec.phi
  %50 = add <4 x i32> %strided.vec99, %vec.phi97
  %index.next = add nuw i64 %index, 8
  %51 = icmp eq i64 %index.next, %n.vec
  br i1 %51, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %50, %49
  %52 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  br label %.lr.ph65.preheader100

53:                                               ; preds = %.lr.ph59
  %54 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %indvars.iv75
  %55 = load i32, ptr %54, align 8, !tbaa !13
  %.not46 = icmp sgt i32 %55, %.04067
  br i1 %.not46, label %61, label %56

56:                                               ; preds = %53
  %57 = getelementptr inbounds i8, ptr %54, i64 4
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = icmp slt i32 %58, %55
  br i1 %59, label %60, label %61

60:                                               ; preds = %56
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %54, ptr noundef nonnull align 4 dereferenceable(4) %57) #6
  %.pre82 = load i32, ptr @n, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %53, %56, %60
  %62 = phi i32 [ %.pre82, %60 ], [ %40, %56 ], [ %40, %53 ]
  %.3 = phi i32 [ %41, %60 ], [ %.257, %56 ], [ %.257, %53 ]
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %63 = sext i32 %62 to i64
  %64 = icmp slt i64 %indvars.iv.next76, %63
  br i1 %64, label %.lr.ph59, label %.critedge, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph65, %35, %.critedge
  %.lcssa5184 = phi i32 [ %.lcssa51, %.critedge ], [ %38, %35 ], [ %.lcssa51, %.lr.ph65 ]
  %.035.lcssa = phi i32 [ 0, %.critedge ], [ 0, %35 ], [ %70, %.lr.ph65 ]
  %65 = load i32, ptr @ans, align 4, !tbaa !5
  %66 = mul nsw i32 %.035.lcssa, %.04067
  %67 = icmp sgt i32 %65, %66
  br i1 %67, label %71, label %.loopexit

.lr.ph65:                                         ; preds = %.lr.ph65.preheader100, %.lr.ph65
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.lr.ph65 ], [ %indvars.iv78.ph, %.lr.ph65.preheader100 ]
  %.03563 = phi i32 [ %70, %.lr.ph65 ], [ %.03563.ph, %.lr.ph65.preheader100 ]
  %68 = getelementptr inbounds [1001 x %struct.Person], ptr @b, i64 0, i64 %indvars.iv78
  %69 = load i32, ptr %68, align 8, !tbaa !13
  %70 = add nsw i32 %69, %.03563
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next79, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph65, !llvm.loop !19

71:                                               ; preds = %._crit_edge
  store i32 %66, ptr @ans, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %22, %._crit_edge, %71, %.critedge48
  %72 = phi i32 [ %.lcssa5184, %._crit_edge ], [ %.lcssa5184, %71 ], [ %31, %.critedge48 ], [ %16, %22 ]
  %73 = phi i32 [ %.lcssa5184, %._crit_edge ], [ %.lcssa5184, %71 ], [ %32, %.critedge48 ], [ %17, %22 ]
  %74 = add nuw nsw i32 %.04067, 1
  %exitcond81.not = icmp eq i32 %74, 1010
  br i1 %exitcond81.not, label %10, label %.preheader, !llvm.loop !20
}

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

; Function Attrs: mustprogress 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) #2

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #5

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 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, !6, i64 4}
!12 = !{!"_ZTS6Person", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !16, !17}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !17, !16}
!20 = distinct !{!20, !10}


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