; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/8 VC Elimination 2017/Problem D (D)

; 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 i32, align 4
@k = external dso_local global i32, align 4
@ans = 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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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 i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %18 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %20 = getelementptr i8, ptr %19, i64 -24
  %21 = load i64, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %21
  %23 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %22, ptr noundef null)
  %24 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %25 = getelementptr i8, ptr %24, i64 -24
  %26 = load i64, ptr %25, align 8
  %27 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %26
  %28 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %27, ptr noundef null)
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 4 dereferenceable(4) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %31 = load i32, ptr @n, align 4, !tbaa !8
  %32 = load i32, ptr @k, align 4, !tbaa !8
  %33 = sub nsw i32 %31, %32
  store i32 %33, ptr %2, align 4, !tbaa !8
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @k, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %35 = load i32, ptr %34, align 4, !tbaa !8
  store i32 %35, ptr @k, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 1, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %36

36:                                               ; preds = %181, %0
  %37 = load i32, ptr %4, align 4, !tbaa !8
  %38 = load i32, ptr @n, align 4, !tbaa !8
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %42 = load i32, ptr %3, align 4, !tbaa !8
  %43 = load i32, ptr @k, align 4, !tbaa !8
  %44 = add nsw i32 %42, %43
  store i32 %44, ptr %5, align 4, !tbaa !8
  %45 = load i32, ptr %5, align 4, !tbaa !8
  %46 = load i32, ptr @n, align 4, !tbaa !8
  %47 = icmp sgt i32 %45, %46
  br i1 %47, label %48, label %52

48:                                               ; preds = %41
  %49 = load i32, ptr @n, align 4, !tbaa !8
  %50 = load i32, ptr %5, align 4, !tbaa !8
  %51 = sub nsw i32 %50, %49
  store i32 %51, ptr %5, align 4, !tbaa !8
  br label %52

52:                                               ; preds = %48, %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %54 = load i32, ptr %53, align 4, !tbaa !8
  store i32 %54, ptr %6, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %56 = load i32, ptr %55, align 4, !tbaa !8
  store i32 %56, ptr %7, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %57 = load i32, ptr %6, align 4, !tbaa !8
  %58 = add nsw i32 %57, 1
  %59 = load i32, ptr @k, align 4, !tbaa !8
  %60 = sub nsw i32 %58, %59
  store i32 %60, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %61 = load i32, ptr %7, align 4, !tbaa !8
  %62 = sub nsw i32 %61, 1
  %63 = load i32, ptr @k, align 4, !tbaa !8
  %64 = sub nsw i32 %62, %63
  store i32 %64, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %65 = load i32, ptr %6, align 4, !tbaa !8
  %66 = sub nsw i32 %65, 1
  store i32 %66, ptr %10, align 4, !tbaa !8
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %68 = load i32, ptr %67, align 4, !tbaa !8
  store i32 %68, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 0, ptr %11, align 8, !tbaa !11
  %69 = load i32, ptr %8, align 4, !tbaa !8
  %70 = icmp sge i32 %69, 1
  br i1 %70, label %71, label %80

71:                                               ; preds = %52
  %72 = load i32, ptr %9, align 4, !tbaa !8
  %73 = call noundef i64 @_Z5queryix(i32 noundef %72, i64 noundef 0)
  %74 = load i32, ptr %8, align 4, !tbaa !8
  %75 = sub nsw i32 %74, 1
  %76 = call noundef i64 @_Z5queryix(i32 noundef %75, i64 noundef 0)
  %77 = sub nsw i64 %73, %76
  %78 = load i64, ptr %11, align 8, !tbaa !11
  %79 = add nsw i64 %78, %77
  store i64 %79, ptr %11, align 8, !tbaa !11
  br label %130

80:                                               ; preds = %52
  %81 = load i32, ptr %8, align 4, !tbaa !8
  %82 = icmp slt i32 %81, 1
  br i1 %82, label %83, label %106

83:                                               ; preds = %80
  %84 = load i32, ptr %9, align 4, !tbaa !8
  %85 = icmp sge i32 %84, 1
  br i1 %85, label %86, label %106

86:                                               ; preds = %83
  %87 = load i32, ptr %9, align 4, !tbaa !8
  %88 = call noundef i64 @_Z5queryix(i32 noundef %87, i64 noundef 0)
  %89 = load i64, ptr %11, align 8, !tbaa !11
  %90 = add nsw i64 %89, %88
  store i64 %90, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %91 = load i32, ptr %8, align 4, !tbaa !8
  %92 = load i32, ptr @n, align 4, !tbaa !8
  %93 = add nsw i32 %91, %92
  store i32 %93, ptr %12, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %94 = load i32, ptr %7, align 4, !tbaa !8
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %13, align 4, !tbaa !8
  %96 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %97 = load i32, ptr %96, align 4, !tbaa !8
  store i32 %97, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  %98 = load i32, ptr @n, align 4, !tbaa !8
  %99 = call noundef i64 @_Z5queryix(i32 noundef %98, i64 noundef 0)
  %100 = load i32, ptr %8, align 4, !tbaa !8
  %101 = sub nsw i32 %100, 1
  %102 = call noundef i64 @_Z5queryix(i32 noundef %101, i64 noundef 0)
  %103 = sub nsw i64 %99, %102
  %104 = load i64, ptr %11, align 8, !tbaa !11
  %105 = add nsw i64 %104, %103
  store i64 %105, ptr %11, align 8, !tbaa !11
  br label %129

106:                                              ; preds = %83, %80
  %107 = load i32, ptr @n, align 4, !tbaa !8
  %108 = load i32, ptr %8, align 4, !tbaa !8
  %109 = add nsw i32 %108, %107
  store i32 %109, ptr %8, align 4, !tbaa !8
  %110 = load i32, ptr @n, align 4, !tbaa !8
  %111 = load i32, ptr %9, align 4, !tbaa !8
  %112 = add nsw i32 %111, %110
  store i32 %112, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %113 = load i32, ptr %7, align 4, !tbaa !8
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %14, align 4, !tbaa !8
  %115 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %116 = load i32, ptr %115, align 4, !tbaa !8
  store i32 %116, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %117 = load i32, ptr %7, align 4, !tbaa !8
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %15, align 4, !tbaa !8
  %119 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %120 = load i32, ptr %119, align 4, !tbaa !8
  store i32 %120, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  %121 = load i32, ptr %9, align 4, !tbaa !8
  %122 = call noundef i64 @_Z5queryix(i32 noundef %121, i64 noundef 0)
  %123 = load i32, ptr %8, align 4, !tbaa !8
  %124 = sub nsw i32 %123, 1
  %125 = call noundef i64 @_Z5queryix(i32 noundef %124, i64 noundef 0)
  %126 = sub nsw i64 %122, %125
  %127 = load i64, ptr %11, align 8, !tbaa !11
  %128 = add nsw i64 %127, %126
  store i64 %128, ptr %11, align 8, !tbaa !11
  br label %129

129:                                              ; preds = %106, %86
  br label %130

130:                                              ; preds = %129, %71
  %131 = load i32, ptr %7, align 4, !tbaa !8
  %132 = add nsw i32 %131, 1
  %133 = load i32, ptr @k, align 4, !tbaa !8
  %134 = sub nsw i32 %132, %133
  store i32 %134, ptr %8, align 4, !tbaa !8
  %135 = load i32, ptr %6, align 4, !tbaa !8
  %136 = load i32, ptr @k, align 4, !tbaa !8
  %137 = sub nsw i32 %135, %136
  store i32 %137, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %138 = load i32, ptr %6, align 4, !tbaa !8
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %16, align 4, !tbaa !8
  %140 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %141 = load i32, ptr %140, align 4, !tbaa !8
  store i32 %141, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  %142 = load i32, ptr %9, align 4, !tbaa !8
  %143 = icmp slt i32 %142, 1
  br i1 %143, label %144, label %160

144:                                              ; preds = %130
  %145 = load i32, ptr @n, align 4, !tbaa !8
  %146 = load i32, ptr %9, align 4, !tbaa !8
  %147 = add nsw i32 %146, %145
  store i32 %147, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %148 = load i32, ptr %7, align 4, !tbaa !8
  %149 = sub nsw i32 %148, 1
  store i32 %149, ptr %17, align 4, !tbaa !8
  %150 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %151 = load i32, ptr %150, align 4, !tbaa !8
  store i32 %151, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  %152 = load i32, ptr %9, align 4, !tbaa !8
  %153 = call noundef i64 @_Z5queryix(i32 noundef %152, i64 noundef 0)
  %154 = load i32, ptr %8, align 4, !tbaa !8
  %155 = sub nsw i32 %154, 1
  %156 = call noundef i64 @_Z5queryix(i32 noundef %155, i64 noundef 0)
  %157 = sub nsw i64 %153, %156
  %158 = load i64, ptr %11, align 8, !tbaa !11
  %159 = add nsw i64 %158, %157
  store i64 %159, ptr %11, align 8, !tbaa !11
  br label %171

160:                                              ; preds = %130
  %161 = load i32, ptr %7, align 4, !tbaa !8
  %162 = sub nsw i32 %161, 1
  store i32 %162, ptr %9, align 4, !tbaa !8
  %163 = load i32, ptr %9, align 4, !tbaa !8
  %164 = call noundef i64 @_Z5queryix(i32 noundef %163, i64 noundef 0)
  %165 = load i32, ptr %8, align 4, !tbaa !8
  %166 = sub nsw i32 %165, 1
  %167 = call noundef i64 @_Z5queryix(i32 noundef %166, i64 noundef 0)
  %168 = sub nsw i64 %164, %167
  %169 = load i64, ptr %11, align 8, !tbaa !11
  %170 = add nsw i64 %169, %168
  store i64 %170, ptr %11, align 8, !tbaa !11
  br label %171

171:                                              ; preds = %160, %144
  %172 = load i64, ptr %11, align 8, !tbaa !11
  %173 = add nsw i64 %172, 1
  %174 = load i64, ptr @ans, align 8, !tbaa !11
  %175 = add nsw i64 %174, %173
  store i64 %175, ptr @ans, align 8, !tbaa !11
  %176 = load i64, ptr @ans, align 8, !tbaa !11
  %177 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %176)
  %178 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %177, i8 noundef signext 32)
  %179 = load i32, ptr %3, align 4, !tbaa !8
  call void @_Z6updateii(i32 noundef %179, i32 noundef 1)
  %180 = load i32, ptr %5, align 4, !tbaa !8
  store i32 %180, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %181

181:                                              ; preds = %171
  %182 = load i32, ptr %4, align 4, !tbaa !8
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %4, align 4, !tbaa !8
  br label %36, !llvm.loop !13

184:                                              ; preds = %40
  %185 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  ret i32 0
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #6 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) #6 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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 #2 = { "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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = { 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 #7 = { 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"}


; 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 i32, align 4
@k = external dso_local global i32, align 4
@ans = 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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %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 i32, align 4
  %13 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %14 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %15 = getelementptr i8, ptr %14, i64 -24
  %16 = load i64, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %16
  %18 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %17, ptr noundef null)
  %19 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %20 = getelementptr i8, ptr %19, i64 -24
  %21 = load i64, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %21
  %23 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %22, ptr noundef null)
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %25 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 4 dereferenceable(4) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %26 = load i32, ptr @n, align 4, !tbaa !8
  %27 = load i32, ptr @k, align 4, !tbaa !8
  %28 = sub nsw i32 %26, %27
  store i32 %28, ptr %1, align 4, !tbaa !8
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @k, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %30 = load i32, ptr %29, align 4, !tbaa !8
  store i32 %30, ptr @k, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 1, ptr %2, align 4, !tbaa !8
  %31 = load i32, ptr @n, align 4, !tbaa !8
  %.not28 = icmp slt i32 %31, 1
  br i1 %.not28, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %105, %0
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  ret i32 0

.lr.ph:                                           ; preds = %0, %105
  %33 = phi i32 [ %116, %105 ], [ 1, %0 ]
  %34 = phi i32 [ %118, %105 ], [ %31, %0 ]
  %.02129 = phi i32 [ %117, %105 ], [ 1, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %35 = load i32, ptr @k, align 4, !tbaa !8
  %36 = add nsw i32 %35, %33
  %37 = icmp sgt i32 %36, %34
  %38 = select i1 %37, i32 %34, i32 0
  %spec.select = sub nsw i32 %36, %38
  store i32 %spec.select, ptr %3, align 4, !tbaa !8
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %40 = load i32, ptr %39, align 4, !tbaa !8
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %42 = load i32, ptr %41, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %43 = add nsw i32 %40, 1
  %44 = load i32, ptr @k, align 4, !tbaa !8
  %45 = sub nsw i32 %43, %44
  store i32 %45, ptr %4, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %46 = add nsw i32 %42, -1
  %47 = sub nsw i32 %46, %44
  store i32 %47, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  %48 = add nsw i32 %40, -1
  store i32 %48, ptr %6, align 4, !tbaa !8
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %50 = load i32, ptr %49, align 4, !tbaa !8
  store i32 %50, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  %51 = load i32, ptr %4, align 4, !tbaa !8
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %53, label %59

53:                                               ; preds = %.lr.ph
  %54 = call noundef i64 @_Z5queryix(i32 noundef %50, i64 noundef 0)
  %55 = load i32, ptr %4, align 4, !tbaa !8
  %56 = add nsw i32 %55, -1
  %57 = call noundef i64 @_Z5queryix(i32 noundef %56, i64 noundef 0)
  %58 = sub nsw i64 %54, %57
  %.pre = add nsw i32 %42, 1
  br label %91

59:                                               ; preds = %.lr.ph
  %60 = icmp sgt i32 %50, 0
  br i1 %60, label %61, label %76

61:                                               ; preds = %59
  %62 = call noundef i64 @_Z5queryix(i32 noundef %50, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %63 = load i32, ptr %4, align 4, !tbaa !8
  %64 = load i32, ptr @n, align 4, !tbaa !8
  %65 = add nsw i32 %64, %63
  store i32 %65, ptr %7, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #7
  %66 = add nsw i32 %42, 1
  store i32 %66, ptr %8, align 4, !tbaa !8
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %68 = load i32, ptr %67, align 4, !tbaa !8
  store i32 %68, ptr %4, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  %69 = load i32, ptr @n, align 4, !tbaa !8
  %70 = call noundef i64 @_Z5queryix(i32 noundef %69, i64 noundef 0)
  %71 = load i32, ptr %4, align 4, !tbaa !8
  %72 = add nsw i32 %71, -1
  %73 = call noundef i64 @_Z5queryix(i32 noundef %72, i64 noundef 0)
  %74 = add i64 %70, %62
  %75 = sub i64 %74, %73
  br label %91

76:                                               ; preds = %59
  %77 = load i32, ptr @n, align 4, !tbaa !8
  %78 = add nsw i32 %77, %51
  store i32 %78, ptr %4, align 4, !tbaa !8
  %79 = add nsw i32 %77, %50
  store i32 %79, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #7
  %80 = add nsw i32 %42, 1
  store i32 %80, ptr %9, align 4, !tbaa !8
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %82 = load i32, ptr %81, align 4, !tbaa !8
  store i32 %82, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #7
  store i32 %80, ptr %10, align 4, !tbaa !8
  %83 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %84 = load i32, ptr %83, align 4, !tbaa !8
  store i32 %84, ptr %4, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #7
  %85 = load i32, ptr %5, align 4, !tbaa !8
  %86 = call noundef i64 @_Z5queryix(i32 noundef %85, i64 noundef 0)
  %87 = load i32, ptr %4, align 4, !tbaa !8
  %88 = add nsw i32 %87, -1
  %89 = call noundef i64 @_Z5queryix(i32 noundef %88, i64 noundef 0)
  %90 = sub nsw i64 %86, %89
  br label %91

91:                                               ; preds = %61, %76, %53
  %.pre-phi = phi i32 [ %66, %61 ], [ %80, %76 ], [ %.pre, %53 ]
  %.0 = phi i64 [ %75, %61 ], [ %90, %76 ], [ %58, %53 ]
  %92 = load i32, ptr @k, align 4, !tbaa !8
  %93 = sub i32 %.pre-phi, %92
  store i32 %93, ptr %4, align 4, !tbaa !8
  %94 = sub nsw i32 %40, %92
  store i32 %94, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #7
  store i32 %43, ptr %11, align 4, !tbaa !8
  %95 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %96 = load i32, ptr %95, align 4, !tbaa !8
  store i32 %96, ptr %4, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #7
  %97 = load i32, ptr %5, align 4, !tbaa !8
  %98 = icmp slt i32 %97, 1
  br i1 %98, label %99, label %104

99:                                               ; preds = %91
  %100 = load i32, ptr @n, align 4, !tbaa !8
  %101 = add nsw i32 %100, %97
  store i32 %101, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #7
  store i32 %46, ptr %12, align 4, !tbaa !8
  %102 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %103 = load i32, ptr %102, align 4, !tbaa !8
  store i32 %103, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #7
  br label %105

104:                                              ; preds = %91
  store i32 %46, ptr %5, align 4, !tbaa !8
  br label %105

105:                                              ; preds = %104, %99
  %.sink33 = phi i32 [ %46, %104 ], [ %103, %99 ]
  %106 = call noundef i64 @_Z5queryix(i32 noundef %.sink33, i64 noundef 0)
  %.sink32 = load i32, ptr %4, align 4, !tbaa !8
  %107 = add nsw i32 %.sink32, -1
  %108 = call noundef i64 @_Z5queryix(i32 noundef %107, i64 noundef 0)
  %109 = sub nsw i64 %106, %108
  %110 = load i64, ptr @ans, align 8, !tbaa !11
  %.1 = add i64 %.0, 1
  %111 = add i64 %.1, %109
  %112 = add nsw i64 %111, %110
  store i64 %112, ptr @ans, align 8, !tbaa !11
  %113 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %112)
  %114 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %113, i8 noundef signext 32)
  %115 = load i32, ptr %2, align 4, !tbaa !8
  call void @_Z6updateii(i32 noundef %115, i32 noundef 1)
  %116 = load i32, ptr %3, align 4, !tbaa !8
  store i32 %116, ptr %2, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %117 = add nuw nsw i32 %.02129, 1
  %118 = load i32, ptr @n, align 4, !tbaa !8
  %.not.not = icmp slt i32 %.02129, %118
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

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

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

; 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 #3

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

; 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 #6 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 #6 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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 #2 = { "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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress 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 = { 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 #7 = { 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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass