; LLVM IR from ravireddy07/cpp-book :: src/Code-Chef/JAN2021-Long/WIPL.ll (Z5harryv)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::allocator" = type { i8 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@dp = external dso_local global [4017 x [4017 x i32]], align 16
@posi = external dso_local global [4017 x i32], align 16
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z6tryBoxiiRSt6vectorIiSaIiEE(i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24)) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; 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 @_Z5harryv() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::vector", align 8
  %2 = alloca i32, align 4
  %3 = alloca %"class.std::allocator", align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @k)
  call void @llvm.lifetime.start.p0(i64 24, ptr %1) #6
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #6
  call void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #6
  invoke void @_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %16, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %17 unwind label %23

17:                                               ; preds = %0
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %33, %17
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %27, label %22

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

23:                                               ; preds = %0
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %4, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %5, align 4
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %153

27:                                               ; preds = %18
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %29) #6
  %31 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %30)
          to label %32 unwind label %36

32:                                               ; preds = %27
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %6, align 4, !tbaa !5
  br label %18, !llvm.loop !9

36:                                               ; preds = %27
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %4, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %152

40:                                               ; preds = %22
  %41 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #6
  %42 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %41, ptr %42, align 8
  %43 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #6
  %44 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  store ptr %43, ptr %44, align 8
  %45 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8
  %47 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8
  invoke void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr %46, ptr %48)
          to label %49 unwind label %63

49:                                               ; preds = %40
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = and i32 %50, 1
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %56, label %53

53:                                               ; preds = %49
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = icmp sgt i32 %54, 1
  br i1 %55, label %56, label %148

56:                                               ; preds = %53, %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %77, %56
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = load i32, ptr @n, align 4, !tbaa !5
  %60 = sdiv i32 %59, 2
  %61 = icmp slt i32 %58, %60
  br i1 %61, label %67, label %62

62:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %80

63:                                               ; preds = %148, %144, %135, %40
  %64 = landingpad { ptr, i32 }
          cleanup
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %4, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %5, align 4
  br label %152

67:                                               ; preds = %57
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %69) #6
  %71 = load i32, ptr @n, align 4, !tbaa !5
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = sub nsw i32 %71, %72
  %74 = sub nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %75) #6
  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) %70, ptr noundef nonnull align 4 dereferenceable(4) %76) #6
  br label %77

77:                                               ; preds = %67
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %9, align 4, !tbaa !5
  br label %57, !llvm.loop !11

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

81:                                               ; preds = %108, %80
  %82 = load i32, ptr %10, align 4, !tbaa !5
  %83 = load i32, ptr @n, align 4, !tbaa !5
  %84 = add nsw i32 %83, 10
  %85 = icmp sle i32 %82, %84
  br i1 %85, label %87, label %86

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

87:                                               ; preds = %81
  %88 = load i32, ptr %10, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [4017 x i32], ptr @posi, i64 0, i64 %89
  store i32 0, ptr %90, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %104, %87
  %92 = load i32, ptr %12, align 4, !tbaa !5
  %93 = load i32, ptr @k, align 4, !tbaa !5
  %94 = add nsw i32 %93, 10
  %95 = icmp sle i32 %92, %94
  br i1 %95, label %97, label %96

96:                                               ; preds = %91
  store i32 11, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %107

97:                                               ; preds = %91
  %98 = load i32, ptr %10, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [4017 x [4017 x i32]], ptr @dp, i64 0, i64 %99
  %101 = load i32, ptr %12, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [4017 x i32], ptr %100, i64 0, i64 %102
  store i32 -1, ptr %103, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %97
  %105 = load i32, ptr %12, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %12, align 4, !tbaa !5
  br label %91, !llvm.loop !12

107:                                              ; preds = %96
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %10, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %10, align 4, !tbaa !5
  br label %81, !llvm.loop !13

111:                                              ; preds = %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %132, %111
  %113 = load i32, ptr %13, align 4, !tbaa !5
  %114 = load i32, ptr @n, align 4, !tbaa !5
  %115 = icmp sle i32 %113, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %112
  store i32 14, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %135

117:                                              ; preds = %112
  %118 = load i32, ptr %13, align 4, !tbaa !5
  %119 = sub nsw i32 %118, 1
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [4017 x i32], ptr @posi, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  %123 = load i32, ptr %13, align 4, !tbaa !5
  %124 = sub nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %125) #6
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = add nsw i32 %122, %127
  %129 = load i32, ptr %13, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [4017 x i32], ptr @posi, i64 0, i64 %130
  store i32 %128, ptr %131, align 4, !tbaa !5
  br label %132

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

135:                                              ; preds = %116
  %136 = invoke noundef i32 @_Z6tryBoxiiRSt6vectorIiSaIiEE(i32 noundef 0, i32 noundef 0, ptr noundef nonnull align 8 dereferenceable(24) %1)
          to label %137 unwind label %63

137:                                              ; preds = %135
  store i32 %136, ptr @ans, align 4, !tbaa !5
  %138 = load i32, ptr @ans, align 4, !tbaa !5
  %139 = sitofp i32 %138 to double
  %140 = fcmp ogt double %139, 1.000000e+05
  br i1 %140, label %141, label %142

141:                                              ; preds = %137
  br label %144

142:                                              ; preds = %137
  %143 = load i32, ptr @ans, align 4, !tbaa !5
  br label %144

144:                                              ; preds = %142, %141
  %145 = phi i32 [ -1, %141 ], [ %143, %142 ]
  %146 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %145)
          to label %147 unwind label %63

147:                                              ; preds = %144
  br label %151

148:                                              ; preds = %53
  %149 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.3)
          to label %150 unwind label %63

150:                                              ; preds = %148
  br label %151

151:                                              ; preds = %150, %147
  store i32 1, ptr %11, align 4
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %1) #6
  ret void

152:                                              ; preds = %63, %36
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #6
  br label %153

153:                                              ; preds = %152, %23
  call void @llvm.lifetime.end.p0(i64 24, ptr %1) #6
  br label %154

154:                                              ; preds = %153
  %155 = load ptr, ptr %4, align 8
  %156 = load i32, ptr %5, align 4
  %157 = insertvalue { ptr, i32 } poison, ptr %155, 0
  %158 = insertvalue { ptr, i32 } %157, i32 %156, 1
  resume { ptr, i32 } %158
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 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)) #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::allocator" = type { i8 }

@dp = external dso_local local_unnamed_addr global [4017 x [4017 x i32]], align 16
@posi = external dso_local local_unnamed_addr global [4017 x i32], align 16
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z6tryBoxiiRSt6vectorIiSaIiEE(i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24)) 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 nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; 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 @_Z5harryv() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::vector", align 8
  %2 = alloca i32, align 4
  %3 = alloca %"class.std::allocator", align 1
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @k)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #8
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #8
  call void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #8
  invoke void @_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %6, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %7 unwind label %12

7:                                                ; preds = %0
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %7
  %10 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #8
  %11 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #8
  invoke void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr %10, ptr %11)
          to label %19 unwind label %39

12:                                               ; preds = %0
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  br label %77

.lr.ph:                                           ; preds = %7, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %7 ]
  %14 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv) #8
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !9

19:                                               ; preds = %._crit_edge
  %20 = load i32, ptr @n, align 4
  %21 = and i32 %20, 1
  %22 = icmp ne i32 %21, 0
  %23 = icmp sgt i32 %20, 1
  %or.cond = or i1 %23, %22
  br i1 %or.cond, label %.preheader32, label %74

.preheader32:                                     ; preds = %19
  br i1 %23, label %.lr.ph35, label %.preheader31

.preheader31:                                     ; preds = %.lr.ph35, %.preheader32
  %24 = phi i32 [ %20, %.preheader32 ], [ %48, %.lr.ph35 ]
  %25 = add i32 %24, 10
  %.not41 = icmp slt i32 %24, -10
  br i1 %.not41, label %._crit_edge47, label %.lr.ph43

.lr.ph43:                                         ; preds = %.preheader31
  %26 = load i32, ptr @k, align 4, !tbaa !5
  %.not3036 = icmp slt i32 %26, -10
  br i1 %.not3036, label %.lr.ph43.split.us.preheader, label %.lr.ph39.preheader

.lr.ph39.preheader:                               ; preds = %.lr.ph43
  %27 = add i32 %26, 10
  %smax = call i32 @llvm.smax.i32(i32 %27, i32 0)
  %28 = zext nneg i32 %smax to i64
  %29 = shl nuw nsw i64 %28, 2
  %30 = add nuw nsw i64 %29, 4
  %smax57 = call i32 @llvm.smax.i32(i32 %25, i32 0)
  %31 = zext nneg i32 %smax57 to i64
  %32 = shl nuw nsw i64 %31, 2
  %33 = add nuw nsw i64 %32, 4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) @posi, i8 0, i64 %33, i1 false), !tbaa !5
  %34 = add nuw i32 %smax57, 1
  %wide.trip.count = zext i32 %34 to i64
  %xtraiter = and i64 %wide.trip.count, 7
  %35 = icmp slt i32 %25, 7
  br i1 %35, label %.preheader.loopexit.unr-lcssa, label %.lr.ph39.preheader.new

.lr.ph39.preheader.new:                           ; preds = %.lr.ph39.preheader
  %unroll_iter = and i64 %wide.trip.count, 4294967288
  br label %.lr.ph39

.lr.ph43.split.us.preheader:                      ; preds = %.lr.ph43
  %smax60 = call i32 @llvm.smax.i32(i32 %25, i32 0)
  %36 = zext nneg i32 %smax60 to i64
  %37 = shl nuw nsw i64 %36, 2
  %38 = add nuw nsw i64 %37, 4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) @posi, i8 0, i64 %38, i1 false), !tbaa !5
  br label %.preheader

39:                                               ; preds = %._crit_edge47, %._crit_edge
  %40 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #8
  br label %77

.lr.ph35:                                         ; preds = %.preheader32, %.lr.ph35
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %.lr.ph35 ], [ 0, %.preheader32 ]
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %indvars.iv51) #8
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = trunc nuw nsw i64 %indvars.iv51 to i32
  %44 = xor i32 %43, -1
  %45 = add i32 %42, %44
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %46) #8
  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) %41, ptr noundef nonnull align 4 dereferenceable(4) %47) #8
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = sdiv i32 %48, 2
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next52, %50
  br i1 %51, label %.lr.ph35, label %.preheader31, !llvm.loop !11

.preheader.loopexit.unr-lcssa:                    ; preds = %.lr.ph39, %.lr.ph39.preheader
  %indvar.unr = phi i64 [ 0, %.lr.ph39.preheader ], [ %indvar.next.7, %.lr.ph39 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph39.epil

.lr.ph39.epil:                                    ; preds = %.preheader.loopexit.unr-lcssa, %.lr.ph39.epil
  %indvar.epil = phi i64 [ %indvar.next.epil, %.lr.ph39.epil ], [ %indvar.unr, %.preheader.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph39.epil ], [ 0, %.preheader.loopexit.unr-lcssa ]
  %52 = mul nuw nsw i64 %indvar.epil, 16068
  %scevgep.epil = getelementptr i8, ptr @dp, i64 %52
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %scevgep.epil, i8 -1, i64 %30, i1 false), !tbaa !5
  %indvar.next.epil = add nuw nsw i64 %indvar.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.lr.ph39.epil, !llvm.loop !12

.preheader:                                       ; preds = %.preheader.loopexit.unr-lcssa, %.lr.ph39.epil, %.lr.ph43.split.us.preheader
  %.not2844 = icmp slt i32 %24, 1
  br i1 %.not2844, label %._crit_edge47, label %.lr.ph46.preheader

.lr.ph46.preheader:                               ; preds = %.preheader
  %.pre = load i32, ptr @posi, align 16, !tbaa !5
  br label %.lr.ph46

.lr.ph39:                                         ; preds = %.lr.ph39, %.lr.ph39.preheader.new
  %indvar = phi i64 [ 0, %.lr.ph39.preheader.new ], [ %indvar.next.7, %.lr.ph39 ]
  %niter = phi i64 [ 0, %.lr.ph39.preheader.new ], [ %niter.next.7, %.lr.ph39 ]
  %53 = mul nuw nsw i64 %indvar, 16068
  %scevgep = getelementptr i8, ptr @dp, i64 %53
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %scevgep, i8 -1, i64 %30, i1 false), !tbaa !5
  %54 = mul nuw i64 %indvar, 16068
  %gep = getelementptr i8, ptr getelementptr (i8, ptr @dp, i64 16068), i64 %54
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %gep, i8 -1, i64 %30, i1 false), !tbaa !5
  %55 = mul nuw i64 %indvar, 16068
  %gep68 = getelementptr i8, ptr getelementptr (i8, ptr @dp, i64 32136), i64 %55
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep68, i8 -1, i64 %30, i1 false), !tbaa !5
  %56 = mul nuw i64 %indvar, 16068
  %gep69 = getelementptr i8, ptr getelementptr (i8, ptr @dp, i64 48204), i64 %56
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %gep69, i8 -1, i64 %30, i1 false), !tbaa !5
  %57 = mul nuw i64 %indvar, 16068
  %gep70 = getelementptr i8, ptr getelementptr (i8, ptr @dp, i64 64272), i64 %57
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %gep70, i8 -1, i64 %30, i1 false), !tbaa !5
  %58 = mul nuw i64 %indvar, 16068
  %gep71 = getelementptr i8, ptr getelementptr (i8, ptr @dp, i64 80340), i64 %58
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %gep71, i8 -1, i64 %30, i1 false), !tbaa !5
  %59 = mul nuw i64 %indvar, 16068
  %gep72 = getelementptr i8, ptr getelementptr (i8, ptr @dp, i64 96408), i64 %59
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep72, i8 -1, i64 %30, i1 false), !tbaa !5
  %60 = mul nuw i64 %indvar, 16068
  %gep73 = getelementptr i8, ptr getelementptr (i8, ptr @dp, i64 112476), i64 %60
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %gep73, i8 -1, i64 %30, i1 false), !tbaa !5
  %indvar.next.7 = add nuw nsw i64 %indvar, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.preheader.loopexit.unr-lcssa, label %.lr.ph39, !llvm.loop !14

._crit_edge47:                                    ; preds = %.lr.ph46, %.preheader31, %.preheader
  %61 = invoke noundef i32 @_Z6tryBoxiiRSt6vectorIiSaIiEE(i32 noundef 0, i32 noundef 0, ptr noundef nonnull align 8 dereferenceable(24) %1)
          to label %70 unwind label %39

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %.lr.ph46
  %62 = phi i32 [ %.pre, %.lr.ph46.preheader ], [ %66, %.lr.ph46 ]
  %indvars.iv64 = phi i64 [ 1, %.lr.ph46.preheader ], [ %indvars.iv.next65, %.lr.ph46 ]
  %63 = add nsw i64 %indvars.iv64, -1
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %63) #8
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = add nsw i32 %65, %62
  %67 = getelementptr inbounds [4017 x i32], ptr @posi, i64 0, i64 %indvars.iv64
  store i32 %66, ptr %67, align 4, !tbaa !5
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %.not28.not = icmp slt i64 %indvars.iv64, %69
  br i1 %.not28.not, label %.lr.ph46, label %._crit_edge47, !llvm.loop !15

70:                                               ; preds = %._crit_edge47
  store i32 %61, ptr @ans, align 4, !tbaa !5
  %71 = icmp sgt i32 %61, 100000
  %72 = select i1 %71, i32 -1, i32 %61
  %73 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %72)
  br label %76

74:                                               ; preds = %19
  %75 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %76

76:                                               ; preds = %74, %70
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #8
  ret void

77:                                               ; preds = %39, %12
  %.pn = phi { ptr, i32 } [ %40, %39 ], [ %13, %12 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #8
  resume { ptr, i32 } %.pn
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2EmRKiRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 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 #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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