; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/143 Division 2/Problem C (C)

; 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@a = external dso_local global [100000 x i64], align 16
@mx = external dso_local global i64, align 8
@res = external dso_local global i64, align 8
@cnt = external dso_local global [100001 x i64], align 16
@tot = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 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 i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %15 = getelementptr i8, ptr %14, i64 -24
  %16 = load i64, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %16
  %18 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %17, ptr noundef null)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 8 dereferenceable(8) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %21

21:                                               ; preds = %32, %0
  %22 = load i32, ptr %2, align 4, !tbaa !8
  %23 = sext i32 %22 to i64
  %24 = load i64, ptr @n, align 8, !tbaa !11
  %25 = icmp slt i64 %23, %24
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %21
  %28 = load i32, ptr %2, align 4, !tbaa !8
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %29
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %30)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %2, align 4, !tbaa !8
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !8
  br label %21, !llvm.loop !13

35:                                               ; preds = %26
  %36 = load i64, ptr @n, align 8, !tbaa !11
  %37 = getelementptr inbounds i64, ptr @a, i64 %36
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef @a, ptr noundef %37)
  store i64 1, ptr @tot, align 8, !tbaa !11
  store i64 0, ptr @cnt, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !8
  br label %38

38:                                               ; preds = %90, %35
  %39 = load i32, ptr %3, align 4, !tbaa !8
  %40 = sext i32 %39 to i64
  %41 = load i64, ptr @n, align 8, !tbaa !11
  %42 = icmp slt i64 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %93

44:                                               ; preds = %38
  %45 = load i32, ptr %3, align 4, !tbaa !8
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !11
  %49 = load i32, ptr %3, align 4, !tbaa !8
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !11
  %54 = icmp eq i64 %48, %53
  br i1 %54, label %55, label %66

55:                                               ; preds = %44
  %56 = load i32, ptr %3, align 4, !tbaa !8
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !11
  %60 = load i32, ptr %3, align 4, !tbaa !8
  %61 = add nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %62
  store i64 %59, ptr %63, align 8, !tbaa !11
  %64 = load i64, ptr @tot, align 8, !tbaa !11
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr @tot, align 8, !tbaa !11
  br label %90

66:                                               ; preds = %44
  %67 = load i32, ptr %3, align 4, !tbaa !8
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !11
  %71 = load i64, ptr @tot, align 8, !tbaa !11
  %72 = load i32, ptr %3, align 4, !tbaa !8
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %73
  %75 = load i64, ptr %74, align 8, !tbaa !11
  %76 = load i32, ptr %3, align 4, !tbaa !8
  %77 = sub nsw i32 %76, 1
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %78
  %80 = load i64, ptr %79, align 8, !tbaa !11
  %81 = sub nsw i64 %75, %80
  %82 = mul nsw i64 %71, %81
  %83 = add nsw i64 %70, %82
  %84 = load i32, ptr %3, align 4, !tbaa !8
  %85 = add nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %86
  store i64 %83, ptr %87, align 8, !tbaa !11
  %88 = load i64, ptr @tot, align 8, !tbaa !11
  %89 = add nsw i64 %88, 1
  store i64 %89, ptr @tot, align 8, !tbaa !11
  br label %90

90:                                               ; preds = %66, %55
  %91 = load i32, ptr %3, align 4, !tbaa !8
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %3, align 4, !tbaa !8
  br label %38, !llvm.loop !15

93:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !8
  br label %94

94:                                               ; preds = %164, %93
  %95 = load i32, ptr %4, align 4, !tbaa !8
  %96 = sext i32 %95 to i64
  %97 = load i64, ptr @n, align 8, !tbaa !11
  %98 = icmp slt i64 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %167

100:                                              ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %101 = load i32, ptr %4, align 4, !tbaa !8
  %102 = add nsw i32 %101, 2
  store i32 %102, ptr %6, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  br label %103

103:                                              ; preds = %150, %100
  %104 = load i32, ptr %5, align 4, !tbaa !8
  %105 = add nsw i32 %104, 1
  %106 = load i32, ptr %6, align 4, !tbaa !8
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %108, label %151

108:                                              ; preds = %103
  %109 = load i32, ptr %5, align 4, !tbaa !8
  %110 = load i32, ptr %6, align 4, !tbaa !8
  %111 = add nsw i32 %109, %110
  %112 = sdiv i32 %111, 2
  store i32 %112, ptr %7, align 4, !tbaa !8
  %113 = load i32, ptr %4, align 4, !tbaa !8
  %114 = add nsw i32 %113, 1
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !11
  %118 = load i32, ptr %4, align 4, !tbaa !8
  %119 = load i32, ptr %7, align 4, !tbaa !8
  %120 = sub nsw i32 %118, %119
  %121 = add nsw i32 %120, 1
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %122
  %124 = load i64, ptr %123, align 8, !tbaa !11
  %125 = sub nsw i64 %117, %124
  %126 = load i32, ptr %4, align 4, !tbaa !8
  %127 = add nsw i32 %126, 1
  %128 = load i32, ptr %7, align 4, !tbaa !8
  %129 = sub nsw i32 %127, %128
  %130 = sext i32 %129 to i64
  %131 = load i32, ptr %4, align 4, !tbaa !8
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %132
  %134 = load i64, ptr %133, align 8, !tbaa !11
  %135 = load i32, ptr %4, align 4, !tbaa !8
  %136 = load i32, ptr %7, align 4, !tbaa !8
  %137 = sub nsw i32 %135, %136
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %138
  %140 = load i64, ptr %139, align 8, !tbaa !11
  %141 = sub nsw i64 %134, %140
  %142 = mul nsw i64 %130, %141
  %143 = sub nsw i64 %125, %142
  %144 = load i64, ptr @k, align 8, !tbaa !11
  %145 = icmp sle i64 %143, %144
  br i1 %145, label %146, label %148

146:                                              ; preds = %108
  %147 = load i32, ptr %7, align 4, !tbaa !8
  store i32 %147, ptr %5, align 4, !tbaa !8
  br label %150

148:                                              ; preds = %108
  %149 = load i32, ptr %7, align 4, !tbaa !8
  store i32 %149, ptr %6, align 4, !tbaa !8
  br label %150

150:                                              ; preds = %148, %146
  br label %103, !llvm.loop !16

151:                                              ; preds = %103
  %152 = load i32, ptr %5, align 4, !tbaa !8
  %153 = sext i32 %152 to i64
  %154 = load i64, ptr @mx, align 8, !tbaa !11
  %155 = icmp sgt i64 %153, %154
  br i1 %155, label %156, label %163

156:                                              ; preds = %151
  %157 = load i32, ptr %5, align 4, !tbaa !8
  %158 = sext i32 %157 to i64
  store i64 %158, ptr @mx, align 8, !tbaa !11
  %159 = load i32, ptr %4, align 4, !tbaa !8
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %160
  %162 = load i64, ptr %161, align 8, !tbaa !11
  store i64 %162, ptr @res, align 8, !tbaa !11
  br label %163

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

164:                                              ; preds = %163
  %165 = load i32, ptr %4, align 4, !tbaa !8
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %4, align 4, !tbaa !8
  br label %94, !llvm.loop !17

167:                                              ; preds = %99
  %168 = load i64, ptr @mx, align 8, !tbaa !11
  %169 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %168)
  %170 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %169, ptr noundef @.str)
  %171 = load i64, ptr @res, align 8, !tbaa !11
  %172 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %170, i64 noundef %171)
  %173 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %172, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #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 = { "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 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


; 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@a = external dso_local global [100000 x i64], align 16
@mx = external dso_local local_unnamed_addr global i64, align 8
@res = external dso_local local_unnamed_addr global i64, align 8
@cnt = external dso_local local_unnamed_addr global [100001 x i64], align 16
@tot = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %3 = getelementptr i8, ptr %2, i64 -24
  %4 = load i64, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %4
  %6 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %5, ptr noundef null)
  %7 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %9
  %11 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @n)
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(8) @k)
  %14 = load i64, ptr @n, align 8, !tbaa !8
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa47 = phi i64 [ %14, %0 ], [ %23, %.lr.ph ]
  %16 = getelementptr inbounds i64, ptr @a, i64 %.lcssa47
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %16)
  store i64 1, ptr @tot, align 8, !tbaa !8
  store i64 0, ptr @cnt, align 16, !tbaa !8
  %17 = load i64, ptr @n, align 8, !tbaa !8
  %18 = icmp sgt i64 %17, 1
  br i1 %18, label %.lr.ph53.preheader, label %.preheader

.lr.ph53.preheader:                               ; preds = %._crit_edge
  %.pre = load i64, ptr @a, align 16, !tbaa !8
  %load_initial = load i64, ptr getelementptr inbounds (i8, ptr @cnt, i64 8), align 8
  %19 = add nsw i64 %17, -1
  %xtraiter = and i64 %19, 1
  %20 = icmp eq i64 %17, 2
  br i1 %20, label %..preheader_crit_edge.unr-lcssa, label %.lr.ph53.preheader.new

.lr.ph53.preheader.new:                           ; preds = %.lr.ph53.preheader
  %unroll_iter = and i64 %19, -2
  br label %.lr.ph53

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %21 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %indvars.iv
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i64, ptr @n, align 8, !tbaa !8
  %24 = icmp sgt i64 %23, %indvars.iv.next
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !11

..preheader_crit_edge.unr-lcssa:                  ; preds = %.lr.ph53, %.lr.ph53.preheader
  %store_forwarded.unr = phi i64 [ %load_initial, %.lr.ph53.preheader ], [ %.sink.1, %.lr.ph53 ]
  %.unr = phi i64 [ %.pre, %.lr.ph53.preheader ], [ %45, %.lr.ph53 ]
  %storemerge.in4950.unr = phi i64 [ 1, %.lr.ph53.preheader ], [ %50, %.lr.ph53 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %..preheader_crit_edge, label %.lr.ph53.epil

.lr.ph53.epil:                                    ; preds = %..preheader_crit_edge.unr-lcssa
  %25 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %storemerge.in4950.unr
  %26 = load i64, ptr %25, align 8, !tbaa !8
  %27 = icmp eq i64 %26, %.unr
  %28 = sub nsw i64 %26, %.unr
  %29 = mul nsw i64 %storemerge.in4950.unr, %28
  %30 = select i1 %27, i64 0, i64 %29
  %.sink.epil = add nsw i64 %store_forwarded.unr, %30
  %31 = add nuw nsw i64 %storemerge.in4950.unr, 1
  %32 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %31
  store i64 %.sink.epil, ptr %32, align 8, !tbaa !8
  br label %..preheader_crit_edge

..preheader_crit_edge:                            ; preds = %..preheader_crit_edge.unr-lcssa, %.lr.ph53.epil
  store i64 %17, ptr @tot, align 8, !tbaa !8
  br label %.preheader

.preheader:                                       ; preds = %..preheader_crit_edge, %._crit_edge
  %33 = icmp sgt i64 %17, 0
  %mx.promoted = load i64, ptr @mx, align 8, !tbaa !8
  br i1 %33, label %.lr.ph62, label %._crit_edge63

.lr.ph62:                                         ; preds = %.preheader
  %34 = load i64, ptr @k, align 8
  br label %58

.lr.ph53:                                         ; preds = %.lr.ph53, %.lr.ph53.preheader.new
  %store_forwarded = phi i64 [ %load_initial, %.lr.ph53.preheader.new ], [ %.sink.1, %.lr.ph53 ]
  %35 = phi i64 [ %.pre, %.lr.ph53.preheader.new ], [ %45, %.lr.ph53 ]
  %storemerge.in4950 = phi i64 [ 1, %.lr.ph53.preheader.new ], [ %50, %.lr.ph53 ]
  %niter = phi i64 [ 0, %.lr.ph53.preheader.new ], [ %niter.next.1, %.lr.ph53 ]
  %36 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %storemerge.in4950
  %37 = load i64, ptr %36, align 8, !tbaa !8
  %38 = icmp eq i64 %37, %35
  %39 = sub nsw i64 %37, %35
  %40 = mul nsw i64 %storemerge.in4950, %39
  %41 = select i1 %38, i64 0, i64 %40
  %.sink = add nsw i64 %store_forwarded, %41
  %42 = add nuw nsw i64 %storemerge.in4950, 1
  %43 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %42
  store i64 %.sink, ptr %43, align 8, !tbaa !8
  %44 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %42
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %46 = icmp eq i64 %45, %37
  %47 = sub nsw i64 %45, %37
  %48 = mul nsw i64 %42, %47
  %49 = select i1 %46, i64 0, i64 %48
  %.sink.1 = add nsw i64 %.sink, %49
  %50 = add nuw nsw i64 %storemerge.in4950, 2
  %51 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %50
  store i64 %.sink.1, ptr %51, align 8, !tbaa !8
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %..preheader_crit_edge.unr-lcssa, label %.lr.ph53, !llvm.loop !13

._crit_edge63:                                    ; preds = %91, %.preheader
  %52 = phi i64 [ %mx.promoted, %.preheader ], [ %92, %91 ]
  %53 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %52)
  %54 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef nonnull @.str)
  %55 = load i64, ptr @res, align 8, !tbaa !8
  %56 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %54, i64 noundef %55)
  %57 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %56, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

58:                                               ; preds = %.lr.ph62, %91
  %indvars.iv67 = phi i64 [ 0, %.lr.ph62 ], [ %indvars.iv.next68, %91 ]
  %59 = phi i64 [ %mx.promoted, %.lr.ph62 ], [ %92, %91 ]
  %.not64 = icmp eq i64 %indvars.iv67, 0
  br i1 %.not64, label %._crit_edge59, label %.lr.ph58

.lr.ph58:                                         ; preds = %58
  %60 = add nuw nsw i64 %indvars.iv67, 1
  %61 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %indvars.iv67
  %64 = load i64, ptr %63, align 8, !tbaa !8
  %65 = trunc i64 %indvars.iv67 to i32
  %66 = add i32 %65, 2
  %67 = trunc nuw nsw i64 %indvars.iv67 to i32
  %68 = trunc nuw nsw i64 %60 to i32
  br label %69

69:                                               ; preds = %.lr.ph58, %69
  %.03356 = phi i32 [ %66, %.lr.ph58 ], [ %..033, %69 ]
  %.03455 = phi i32 [ 1, %.lr.ph58 ], [ %.034., %69 ]
  %70 = add nuw nsw i32 %.03356, %.03455
  %71 = lshr i32 %70, 1
  %72 = sub nsw i32 %67, %71
  %73 = add nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100001 x i64], ptr @cnt, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !8
  %77 = sub i64 %62, %76
  %78 = sub nsw i32 %68, %71
  %79 = sext i32 %78 to i64
  %80 = sext i32 %72 to i64
  %81 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %80
  %82 = load i64, ptr %81, align 8, !tbaa !8
  %.neg = sub i64 %82, %64
  %.neg45 = mul i64 %.neg, %79
  %83 = add i64 %77, %.neg45
  %.not = icmp sgt i64 %83, %34
  %.034. = select i1 %.not, i32 %.03455, i32 %71
  %..033 = select i1 %.not, i32 %71, i32 %.03356
  %84 = add nuw nsw i32 %.034., 1
  %85 = icmp slt i32 %84, %..033
  br i1 %85, label %69, label %._crit_edge59, !llvm.loop !14

._crit_edge59:                                    ; preds = %69, %58
  %.034.lcssa = phi i32 [ 1, %58 ], [ %.034., %69 ]
  %86 = zext nneg i32 %.034.lcssa to i64
  %87 = icmp slt i64 %59, %86
  br i1 %87, label %88, label %91

88:                                               ; preds = %._crit_edge59
  store i64 %86, ptr @mx, align 8, !tbaa !8
  %89 = getelementptr inbounds [100000 x i64], ptr @a, i64 0, i64 %indvars.iv67
  %90 = load i64, ptr %89, align 8, !tbaa !8
  store i64 %90, ptr @res, align 8, !tbaa !8
  br label %91

91:                                               ; preds = %88, %._crit_edge59
  %92 = phi i64 [ %86, %88 ], [ %59, %._crit_edge59 ]
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond70.not = icmp eq i64 %indvars.iv.next68, %17
  br i1 %exitcond70.not, label %._crit_edge63, label %58, !llvm.loop !15
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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