; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2016-17/Feb 2017/Silver (17 Feb S3)

; 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" }
%"struct.std::pair" = type { i32, i32 }

@N = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@cur = external dso_local global i32, align 4
@adj = external dso_local global [100 x [100 x [4 x i8]]], align 16
@is = external dso_local global [100 x [100 x i8]], align 16
@visit = external dso_local global [100 x [100 x i8]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 4
  %4 = alloca %"struct.std::pair", align 4
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::pair", align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = 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)
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(4) @K)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(4) @R)
  %13 = load i32, ptr @K, align 4, !tbaa !5
  %14 = load i32, ptr @K, align 4, !tbaa !5
  %15 = sub nsw i32 %14, 1
  %16 = mul nsw i32 %13, %15
  %17 = sdiv i32 %16, 2
  store i32 %17, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %18

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

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

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %4)
  %24 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 0
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %24)
  %26 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 1
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 4 dereferenceable(4) %26)
  %28 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 0
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 4 dereferenceable(4) %28)
  %30 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 1
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 4 dereferenceable(4) %30)
  %32 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = add nsw i32 %33, -1
  store i32 %34, ptr %32, align 4, !tbaa !9
  %35 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr %35, align 4, !tbaa !11
  %38 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %38, align 4, !tbaa !9
  %41 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = add nsw i32 %42, -1
  store i32 %43, ptr %41, align 4, !tbaa !11
  %44 = call noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %4)
  br i1 %44, label %45, label %46

45:                                               ; preds = %23
  call void @_ZSt4swapIiiENSt9enable_ifIXsr6__and_ISt14__is_swappableIT_ES1_IT0_EEE5valueEvE4typeERSt4pairIS2_S4_ESA_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %4) #7
  br label %46

46:                                               ; preds = %45, %23
  %47 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = icmp eq i32 %48, %50
  br i1 %51, label %52, label %71

52:                                               ; preds = %46
  %53 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 0
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %55
  %57 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [100 x [4 x i8]], ptr %56, i64 0, i64 %59
  %61 = getelementptr inbounds [4 x i8], ptr %60, i64 0, i64 1
  store i8 1, ptr %61, align 1, !tbaa !12
  %62 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 0
  %63 = load i32, ptr %62, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %64
  %66 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 1
  %67 = load i32, ptr %66, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100 x [4 x i8]], ptr %65, i64 0, i64 %68
  %70 = getelementptr inbounds [4 x i8], ptr %69, i64 0, i64 3
  store i8 1, ptr %70, align 1, !tbaa !12
  br label %90

71:                                               ; preds = %46
  %72 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 0
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %74
  %76 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 1
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100 x [4 x i8]], ptr %75, i64 0, i64 %78
  %80 = getelementptr inbounds [4 x i8], ptr %79, i64 0, i64 0
  store i8 1, ptr %80, align 4, !tbaa !12
  %81 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %83
  %85 = getelementptr inbounds %"struct.std::pair", ptr %4, i32 0, i32 1
  %86 = load i32, ptr %85, align 4, !tbaa !11
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [100 x [4 x i8]], ptr %84, i64 0, i64 %87
  %89 = getelementptr inbounds [4 x i8], ptr %88, i64 0, i64 2
  store i8 1, ptr %89, align 2, !tbaa !12
  br label %90

90:                                               ; preds = %71, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %2, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !14

94:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %119, %94
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = load i32, ptr @K, align 4, !tbaa !5
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %122

100:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  %101 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %102 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %101)
  %103 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %104 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %102, ptr noundef nonnull align 4 dereferenceable(4) %103)
  %105 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = add nsw i32 %106, -1
  store i32 %107, ptr %105, align 4, !tbaa !9
  %108 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !11
  %110 = add nsw i32 %109, -1
  store i32 %110, ptr %108, align 4, !tbaa !11
  %111 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %112 = load i32, ptr %111, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [100 x [100 x i8]], ptr @is, i64 0, i64 %113
  %115 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %116 = load i32, ptr %115, align 4, !tbaa !11
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [100 x i8], ptr %114, i64 0, i64 %117
  store i8 1, ptr %118, align 1, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %119

119:                                              ; preds = %100
  %120 = load i32, ptr %5, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %5, align 4, !tbaa !5
  br label %95, !llvm.loop !16

122:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %167, %122
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = load i32, ptr @N, align 4, !tbaa !5
  %126 = icmp slt i32 %124, %125
  br i1 %126, label %128, label %127

127:                                              ; preds = %123
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %170

128:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %163, %128
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = load i32, ptr @N, align 4, !tbaa !5
  %132 = icmp slt i32 %130, %131
  br i1 %132, label %134, label %133

133:                                              ; preds = %129
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %166

134:                                              ; preds = %129
  %135 = load i32, ptr %7, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100 x [100 x i8]], ptr @is, i64 0, i64 %136
  %138 = load i32, ptr %9, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [100 x i8], ptr %137, i64 0, i64 %139
  %141 = load i8, ptr %140, align 1, !tbaa !12, !range !17, !noundef !18
  %142 = trunc i8 %141 to i1
  br i1 %142, label %143, label %162

143:                                              ; preds = %134
  %144 = load i32, ptr %7, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [100 x [100 x i8]], ptr @visit, i64 0, i64 %145
  %147 = load i32, ptr %9, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100 x i8], ptr %146, i64 0, i64 %148
  %150 = load i8, ptr %149, align 1, !tbaa !12, !range !17, !noundef !18
  %151 = trunc i8 %150 to i1
  br i1 %151, label %162, label %152

152:                                              ; preds = %143
  store i32 0, ptr @cur, align 4, !tbaa !5
  %153 = load i32, ptr %7, align 4, !tbaa !5
  %154 = load i32, ptr %9, align 4, !tbaa !5
  call void @_Z4fillii(i32 noundef %153, i32 noundef %154)
  %155 = load i32, ptr @cur, align 4, !tbaa !5
  %156 = load i32, ptr @cur, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = mul nsw i32 %155, %157
  %159 = sdiv i32 %158, 2
  %160 = load i32, ptr @ans, align 4, !tbaa !5
  %161 = sub nsw i32 %160, %159
  store i32 %161, ptr @ans, align 4, !tbaa !5
  br label %162

162:                                              ; preds = %152, %143, %134
  br label %163

163:                                              ; preds = %162
  %164 = load i32, ptr %9, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %9, align 4, !tbaa !5
  br label %129, !llvm.loop !19

166:                                              ; preds = %133
  br label %167

167:                                              ; preds = %166
  %168 = load i32, ptr %7, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %7, align 4, !tbaa !5
  br label %123, !llvm.loop !20

170:                                              ; preds = %127
  %171 = load i32, ptr @ans, align 4, !tbaa !5
  %172 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %171)
  %173 = load i32, ptr %1, align 4
  ret i32 %173
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #5

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

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


; 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" }
%"struct.std::pair" = type { i32, i32 }

@N = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@cur = external dso_local local_unnamed_addr global i32, align 4
@adj = external dso_local local_unnamed_addr global [100 x [100 x [4 x i8]]], align 16
@is = external dso_local local_unnamed_addr global [100 x [100 x i8]], align 16
@visit = external dso_local local_unnamed_addr global [100 x [100 x i8]], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca %"struct.std::pair", align 8
  %3 = alloca %"struct.std::pair", align 4
  %4 = 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)
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(4) @K)
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) @R)
  %7 = load i32, ptr @K, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  %9 = mul nsw i32 %8, %7
  %10 = sdiv i32 %9, 2
  store i32 %10, ptr @ans, align 4, !tbaa !5
  %11 = load i32, ptr @R, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %.preheader20

.lr.ph:                                           ; preds = %0
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = getelementptr inbounds i8, ptr %2, i64 4
  br label %18

.preheader20.loopexit:                            ; preds = %47
  %.pre = load i32, ptr @K, align 4, !tbaa !5
  br label %.preheader20

.preheader20:                                     ; preds = %.preheader20.loopexit, %0
  %15 = phi i32 [ %.pre, %.preheader20.loopexit ], [ %7, %0 ]
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph23, label %.preheader19

.lr.ph23:                                         ; preds = %.preheader20
  %17 = getelementptr inbounds i8, ptr %3, i64 4
  br label %53

18:                                               ; preds = %.lr.ph, %47
  %.01721 = phi i32 [ 0, %.lr.ph ], [ %48, %47 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %23 = load <2 x i32>, ptr %1, align 8, !tbaa !5
  %24 = add nsw <2 x i32> %23, <i32 -1, i32 -1>
  store <2 x i32> %24, ptr %1, align 8, !tbaa !5
  %25 = load <2 x i32>, ptr %2, align 8, !tbaa !5
  %26 = add nsw <2 x i32> %25, <i32 -1, i32 -1>
  store <2 x i32> %26, ptr %2, align 8, !tbaa !5
  %27 = call noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2)
  br i1 %27, label %28, label %29

28:                                               ; preds = %18
  call void @_ZSt4swapIiiENSt9enable_ifIXsr6__and_ISt14__is_swappableIT_ES1_IT0_EEE5valueEvE4typeERSt4pairIS2_S4_ESA_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) #7
  br label %29

29:                                               ; preds = %28, %18
  %30 = load i32, ptr %1, align 8, !tbaa !9
  %31 = load i32, ptr %2, align 8, !tbaa !9
  %32 = icmp eq i32 %30, %31
  %33 = sext i32 %30 to i64
  %34 = load i32, ptr %13, align 4, !tbaa !11
  %35 = sext i32 %34 to i64
  br i1 %32, label %36, label %41

36:                                               ; preds = %29
  %37 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %33, i64 %35, i64 1
  store i8 1, ptr %37, align 1, !tbaa !12
  %38 = load i32, ptr %14, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %33, i64 %39, i64 3
  store i8 1, ptr %40, align 1, !tbaa !12
  br label %47

41:                                               ; preds = %29
  %42 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %33, i64 %35
  store i8 1, ptr %42, align 4, !tbaa !12
  %43 = sext i32 %31 to i64
  %44 = load i32, ptr %14, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100 x [100 x [4 x i8]]], ptr @adj, i64 0, i64 %43, i64 %45, i64 2
  store i8 1, ptr %46, align 2, !tbaa !12
  br label %47

47:                                               ; preds = %41, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %48 = add nuw nsw i32 %.01721, 1
  %49 = load i32, ptr @R, align 4, !tbaa !5
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %18, label %.preheader20.loopexit, !llvm.loop !14

.preheader19:                                     ; preds = %53, %.preheader20
  %51 = load i32, ptr @N, align 4, !tbaa !5
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %.preheader, label %._crit_edge27

53:                                               ; preds = %.lr.ph23, %53
  %.01622 = phi i32 [ 0, %.lr.ph23 ], [ %63, %53 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %55 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %54, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %56 = load i32, ptr %3, align 4, !tbaa !9
  %57 = add nsw i32 %56, -1
  %58 = load i32, ptr %17, align 4, !tbaa !11
  %59 = add nsw i32 %58, -1
  %60 = sext i32 %57 to i64
  %61 = sext i32 %59 to i64
  %62 = getelementptr inbounds [100 x [100 x i8]], ptr @is, i64 0, i64 %60, i64 %61
  store i8 1, ptr %62, align 1, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  %63 = add nuw nsw i32 %.01622, 1
  %64 = load i32, ptr @K, align 4, !tbaa !5
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %53, label %.preheader19, !llvm.loop !16

.preheader:                                       ; preds = %.preheader19, %._crit_edge
  %66 = phi i32 [ %71, %._crit_edge ], [ %51, %.preheader19 ]
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %._crit_edge ], [ 0, %.preheader19 ]
  %67 = icmp sgt i32 %66, 0
  br i1 %67, label %.lr.ph25, label %._crit_edge

.lr.ph25:                                         ; preds = %.preheader
  %68 = trunc nuw nsw i64 %indvars.iv30 to i32
  br label %74

._crit_edge27:                                    ; preds = %._crit_edge, %.preheader19
  %69 = load i32, ptr @ans, align 4, !tbaa !5
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %69)
  ret i32 0

._crit_edge:                                      ; preds = %91, %.preheader
  %71 = phi i32 [ %66, %.preheader ], [ %92, %91 ]
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %72 = sext i32 %71 to i64
  %73 = icmp slt i64 %indvars.iv.next31, %72
  br i1 %73, label %.preheader, label %._crit_edge27, !llvm.loop !17

74:                                               ; preds = %.lr.ph25, %91
  %75 = phi i32 [ %66, %.lr.ph25 ], [ %92, %91 ]
  %76 = phi i32 [ %66, %.lr.ph25 ], [ %93, %91 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph25 ], [ %indvars.iv.next, %91 ]
  %77 = getelementptr inbounds [100 x [100 x i8]], ptr @is, i64 0, i64 %indvars.iv30, i64 %indvars.iv
  %78 = load i8, ptr %77, align 1, !tbaa !12, !range !19, !noundef !20
  %79 = trunc nuw i8 %78 to i1
  br i1 %79, label %80, label %91

80:                                               ; preds = %74
  %81 = getelementptr inbounds [100 x [100 x i8]], ptr @visit, i64 0, i64 %indvars.iv30, i64 %indvars.iv
  %82 = load i8, ptr %81, align 1, !tbaa !12, !range !19, !noundef !20
  %83 = trunc nuw i8 %82 to i1
  br i1 %83, label %91, label %84

84:                                               ; preds = %80
  store i32 0, ptr @cur, align 4, !tbaa !5
  %85 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_Z4fillii(i32 noundef %68, i32 noundef %85)
  %86 = load i32, ptr @cur, align 4, !tbaa !5
  %87 = add nsw i32 %86, -1
  %88 = mul nsw i32 %87, %86
  %.neg = sdiv i32 %88, -2
  %89 = load i32, ptr @ans, align 4, !tbaa !5
  %90 = add i32 %.neg, %89
  store i32 %90, ptr @ans, align 4, !tbaa !5
  %.pre33 = load i32, ptr @N, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %74, %80, %84
  %92 = phi i32 [ %75, %74 ], [ %75, %80 ], [ %.pre33, %84 ]
  %93 = phi i32 [ %76, %74 ], [ %76, %80 ], [ %.pre33, %84 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %94 = sext i32 %93 to i64
  %95 = icmp slt i64 %indvars.iv.next, %94
  br i1 %95, label %74, label %._crit_edge, !llvm.loop !21
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZStgtIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #5

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !15}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass