; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/Manthan 2016/Problem E (E)

; 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.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@v = external dso_local global [1048576 x i32], align 16
@c = external dso_local global [1048576 x i32], align 16
@maxv = external dso_local global [20 x [1048576 x i32]], align 16
@minc = external dso_local global [20 x [1048576 x i32]], align 16
@p = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11sparseTablev() #0

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

; 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)) #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
declare dso_local noundef i32 @_Z11maxVisitorsii(i32 noundef, i32 noundef) #0

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

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

; 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
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @K)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %40, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp sle i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1048576 x i32], ptr @v, i64 0, i64 %25
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %26)
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1048576 x i32], ptr @v, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = mul nsw i32 %31, 100
  store i32 %32, ptr %30, align 4, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1048576 x i32], ptr @v, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1048576 x i32], ptr @maxv, i64 0, i64 %38
  store i32 %36, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %23
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !9

43:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %61, %43
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %44
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1048576 x i32], ptr @c, i64 0, i64 %51
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %52)
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1048576 x i32], ptr @c, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [1048576 x i32], ptr @minc, i64 0, i64 %59
  store i32 %57, ptr %60, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %49
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %3, align 4, !tbaa !5
  br label %44, !llvm.loop !11

64:                                               ; preds = %48
  call void @_Z11sparseTablev()
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %120, %64
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = icmp sle i32 %66, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %123

70:                                               ; preds = %65
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1048576 x i32], ptr @c, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1048576 x i32], ptr @v, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = icmp sle i32 %74, %78
  br i1 %79, label %80, label %84

80:                                               ; preds = %70
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1048576 x i32], ptr @c, i64 0, i64 %82
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 4 dereferenceable(4) %83)
  br label %120

84:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  %85 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %85, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  br label %88

88:                                               ; preds = %111, %84
  %89 = load i32, ptr %5, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = icmp slt i32 %90, %91
  br i1 %92, label %93, label %112

93:                                               ; preds = %88
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = load i32, ptr %6, align 4, !tbaa !5
  %96 = add nsw i32 %94, %95
  %97 = ashr i32 %96, 1
  store i32 %97, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %98 = load i32, ptr %4, align 4, !tbaa !5
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = call noundef i32 @_Z11maxVisitorsii(i32 noundef %98, i32 noundef %99)
  store i32 %100, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %101 = load i32, ptr %4, align 4, !tbaa !5
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = call noundef i32 @_Z10minRevenueii(i32 noundef %101, i32 noundef %102)
  store i32 %103, ptr %9, align 4, !tbaa !5
  %104 = load i32, ptr %8, align 4, !tbaa !5
  %105 = load i32, ptr %9, align 4, !tbaa !5
  %106 = icmp slt i32 %104, %105
  br i1 %106, label %107, label %109

107:                                              ; preds = %93
  %108 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %108, ptr %5, align 4, !tbaa !5
  br label %111

109:                                              ; preds = %93
  %110 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %110, ptr %6, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %109, %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %88, !llvm.loop !12

112:                                              ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = load i32, ptr %5, align 4, !tbaa !5
  %115 = call noundef i32 @_Z3getii(i32 noundef %113, i32 noundef %114)
  store i32 %115, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  %116 = load i32, ptr %4, align 4, !tbaa !5
  %117 = load i32, ptr %6, align 4, !tbaa !5
  %118 = call noundef i32 @_Z3getii(i32 noundef %116, i32 noundef %117)
  store i32 %118, ptr %11, align 4, !tbaa !5
  %119 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 4 dereferenceable(4) %119)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %120

120:                                              ; preds = %112, %80
  %121 = load i32, ptr %4, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %4, align 4, !tbaa !5
  br label %65, !llvm.loop !13

123:                                              ; preds = %69
  %124 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %125 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %124, ptr %125, align 8
  %126 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %127 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %126, ptr %127, align 8
  %128 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  %129 = load ptr, ptr %128, align 8
  %130 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr %129, ptr %131)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  store double 0.000000e+00, ptr %14, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %132 = load i32, ptr @K, align 4, !tbaa !5
  %133 = sitofp i32 %132 to double
  %134 = load i32, ptr @n, align 4, !tbaa !5
  %135 = sitofp i32 %134 to double
  %136 = fdiv double %133, %135
  store double %136, ptr %15, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %182, %123
  %138 = load i32, ptr %16, align 4, !tbaa !5
  %139 = load i32, ptr @K, align 4, !tbaa !5
  %140 = add nsw i32 %138, %139
  %141 = sub nsw i32 %140, 1
  %142 = load i32, ptr @n, align 4, !tbaa !5
  %143 = icmp slt i32 %141, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %137
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %185

145:                                              ; preds = %137
  %146 = load i32, ptr %16, align 4, !tbaa !5
  %147 = icmp eq i32 %146, 0
  br i1 %147, label %148, label %157

148:                                              ; preds = %145
  %149 = load double, ptr %15, align 8, !tbaa !14
  %150 = load i32, ptr %16, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %151) #8
  %153 = load i32, ptr %152, align 4, !tbaa !5
  %154 = sitofp i32 %153 to double
  %155 = load double, ptr %14, align 8, !tbaa !14
  %156 = call double @llvm.fmuladd.f64(double %149, double %154, double %155)
  store double %156, ptr %14, align 8, !tbaa !14
  br label %181

157:                                              ; preds = %145
  %158 = load i32, ptr @n, align 4, !tbaa !5
  %159 = load i32, ptr %16, align 4, !tbaa !5
  %160 = sub nsw i32 %158, %159
  %161 = load i32, ptr @K, align 4, !tbaa !5
  %162 = sub nsw i32 %160, %161
  %163 = add nsw i32 %162, 1
  %164 = sitofp i32 %163 to double
  %165 = load double, ptr %15, align 8, !tbaa !14
  %166 = fmul double %165, %164
  store double %166, ptr %15, align 8, !tbaa !14
  %167 = load i32, ptr @n, align 4, !tbaa !5
  %168 = load i32, ptr %16, align 4, !tbaa !5
  %169 = sub nsw i32 %167, %168
  %170 = sitofp i32 %169 to double
  %171 = load double, ptr %15, align 8, !tbaa !14
  %172 = fdiv double %171, %170
  store double %172, ptr %15, align 8, !tbaa !14
  %173 = load double, ptr %15, align 8, !tbaa !14
  %174 = load i32, ptr %16, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %175) #8
  %177 = load i32, ptr %176, align 4, !tbaa !5
  %178 = sitofp i32 %177 to double
  %179 = load double, ptr %14, align 8, !tbaa !14
  %180 = call double @llvm.fmuladd.f64(double %173, double %178, double %179)
  store double %180, ptr %14, align 8, !tbaa !14
  br label %181

181:                                              ; preds = %157, %148
  br label %182

182:                                              ; preds = %181
  %183 = load i32, ptr %16, align 4, !tbaa !5
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %16, align 4, !tbaa !5
  br label %137, !llvm.loop !16

185:                                              ; preds = %144
  %186 = load double, ptr %14, align 8, !tbaa !14
  %187 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %186)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  ret i32 0
}

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

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

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

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

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

; 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) #6 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #7

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

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 = { 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 #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 = { 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 nosync nounwind speculatable willreturn memory(none) }
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, !10}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !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 }

@n = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@v = external dso_local global [1048576 x i32], align 16
@c = external dso_local global [1048576 x i32], align 16
@maxv = external dso_local local_unnamed_addr global [20 x [1048576 x i32]], align 16
@minc = external dso_local local_unnamed_addr global [20 x [1048576 x i32]], align 16
@p = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z11sparseTablev() 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: 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 #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
declare dso_local noundef i32 @_Z11maxVisitorsii(i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @K)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not63 = icmp slt i32 %4, 1
  br i1 %.not63, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  %5 = icmp slt i32 %11, 1
  br i1 %5, label %._crit_edge, label %.lr.ph67

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

._crit_edge:                                      ; preds = %.lr.ph67, %0, %.preheader
  tail call void @_Z11sparseTablev()
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %.not6074 = icmp slt i32 %13, 1
  br i1 %.not6074, label %._crit_edge79, label %.lr.ph78

.lr.ph67:                                         ; preds = %.preheader, %.lr.ph67
  %indvars.iv89 = phi i64 [ %indvars.iv.next90, %.lr.ph67 ], [ 1, %.preheader ]
  %14 = getelementptr inbounds [1048576 x i32], ptr @c, i64 0, i64 %indvars.iv89
  %15 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %14)
  %16 = load i32, ptr %14, align 4, !tbaa !5
  %17 = getelementptr inbounds [1048576 x i32], ptr @minc, i64 0, i64 %indvars.iv89
  store i32 %16, ptr %17, align 4, !tbaa !5
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %.not59.not = icmp slt i64 %indvars.iv89, %19
  br i1 %.not59.not, label %.lr.ph67, label %._crit_edge, !llvm.loop !11

._crit_edge79:                                    ; preds = %53, %._crit_edge
  %20 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %21 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr %20, ptr %21)
  %22 = load i32, ptr @K, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %.not6180 = icmp sgt i32 %22, %23
  br i1 %.not6180, label %._crit_edge86, label %24

24:                                               ; preds = %._crit_edge79
  %25 = sitofp i32 %22 to double
  %26 = sitofp i32 %23 to double
  %27 = fdiv double %25, %26
  %28 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef 0) #8
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sitofp i32 %29 to double
  %31 = call double @llvm.fmuladd.f64(double %27, double %30, double 0.000000e+00)
  %.pre = load i32, ptr @K, align 4, !tbaa !5
  %.pre99 = load i32, ptr @n, align 4, !tbaa !5
  %.not61.peel.not = icmp slt i32 %.pre, %.pre99
  br i1 %.not61.peel.not, label %.lr.ph85.peel.next, label %._crit_edge86

.lr.ph78:                                         ; preds = %._crit_edge, %53
  %indvars.iv92 = phi i64 [ %indvars.iv.next93, %53 ], [ 1, %._crit_edge ]
  %32 = phi i32 [ %54, %53 ], [ %13, %._crit_edge ]
  %33 = getelementptr inbounds [1048576 x i32], ptr @c, i64 0, i64 %indvars.iv92
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = getelementptr inbounds [1048576 x i32], ptr @v, i64 0, i64 %indvars.iv92
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %.not62 = icmp sgt i32 %34, %36
  br i1 %.not62, label %38, label %37

37:                                               ; preds = %.lr.ph78
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 4 dereferenceable(4) %33)
  br label %53

38:                                               ; preds = %.lr.ph78
  %39 = add nsw i32 %32, 1
  %40 = sext i32 %32 to i64
  %41 = icmp slt i64 %indvars.iv92, %40
  %42 = trunc nuw nsw i64 %indvars.iv92 to i32
  br i1 %41, label %.lr.ph71, label %._crit_edge72

.lr.ph71:                                         ; preds = %38, %.lr.ph71
  %.05369 = phi i32 [ %..053, %.lr.ph71 ], [ %42, %38 ]
  %.05568 = phi i32 [ %.055., %.lr.ph71 ], [ %39, %38 ]
  %43 = add nsw i32 %.05369, %.05568
  %44 = ashr i32 %43, 1
  %45 = call noundef i32 @_Z11maxVisitorsii(i32 noundef %42, i32 noundef %44)
  %46 = call noundef i32 @_Z10minRevenueii(i32 noundef %42, i32 noundef %44)
  %47 = icmp slt i32 %45, %46
  %.055. = select i1 %47, i32 %.05568, i32 %44
  %..053 = select i1 %47, i32 %44, i32 %.05369
  %48 = add nsw i32 %..053, 1
  %49 = icmp slt i32 %48, %.055.
  br i1 %49, label %.lr.ph71, label %._crit_edge72, !llvm.loop !12

._crit_edge72:                                    ; preds = %.lr.ph71, %38
  %.055.lcssa = phi i32 [ %39, %38 ], [ %.055., %.lr.ph71 ]
  %.053.lcssa = phi i32 [ %42, %38 ], [ %..053, %.lr.ph71 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %50 = call noundef i32 @_Z3getii(i32 noundef %42, i32 noundef %.053.lcssa)
  store i32 %50, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  %51 = call noundef i32 @_Z3getii(i32 noundef %42, i32 noundef %.055.lcssa)
  store i32 %51, ptr %2, align 4, !tbaa !5
  %52 = 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) %2)
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 4 dereferenceable(4) %52)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  br label %53

53:                                               ; preds = %._crit_edge72, %37
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %.not60.not = icmp slt i64 %indvars.iv92, %55
  br i1 %.not60.not, label %.lr.ph78, label %._crit_edge79, !llvm.loop !13

._crit_edge86:                                    ; preds = %.lr.ph85.peel.next, %24, %._crit_edge79
  %.048.lcssa = phi double [ 0.000000e+00, %._crit_edge79 ], [ %31, %24 ], [ %69, %.lr.ph85.peel.next ]
  %56 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %.048.lcssa)
  ret i32 0

.lr.ph85.peel.next:                               ; preds = %24, %.lr.ph85.peel.next
  %indvars.iv95 = phi i64 [ %indvars.iv.next96, %.lr.ph85.peel.next ], [ 1, %24 ]
  %57 = phi i32 [ %.pre101, %.lr.ph85.peel.next ], [ %.pre99, %24 ]
  %58 = phi i32 [ %.pre100, %.lr.ph85.peel.next ], [ %.pre, %24 ]
  %.04782 = phi double [ %65, %.lr.ph85.peel.next ], [ %27, %24 ]
  %.04881 = phi double [ %69, %.lr.ph85.peel.next ], [ %31, %24 ]
  %59 = trunc nuw nsw i64 %indvars.iv95 to i32
  %60 = sub nsw i32 %57, %59
  %reass.sub = sub i32 %60, %58
  %61 = add i32 %reass.sub, 1
  %62 = sitofp i32 %61 to double
  %63 = fmul double %.04782, %62
  %64 = sitofp i32 %60 to double
  %65 = fdiv double %63, %64
  %66 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @p, i64 noundef %indvars.iv95) #8
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sitofp i32 %67 to double
  %69 = call double @llvm.fmuladd.f64(double %65, double %68, double %.04881)
  %.pre101 = load i32, ptr @n, align 4, !tbaa !5
  %.pre100 = load i32, ptr @K, align 4, !tbaa !5
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %70 = trunc nuw i64 %indvars.iv.next96 to i32
  %71 = add nsw i32 %.pre100, %70
  %.not61 = icmp sgt i32 %71, %.pre101
  br i1 %.not61, label %._crit_edge86, label %.lr.ph85.peel.next, !llvm.loop !14
}

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

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

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

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

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

; 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 #6 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #7

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

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 = { 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 #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 = { 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 nosync nounwind speculatable willreturn memory(none) }
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, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !15}
!15 = !{!"llvm.loop.peeled.count", i32 1}


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