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

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"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" }
%"class.std::bitset" = type { %"struct.std::_Base_bitset" }
%"struct.std::_Base_bitset" = type { i64 }
%"class.std::bitset<64>::reference" = type { ptr, i64 }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@_Z1AB5cxx11 = external dso_local global [500 x %"class.std::__cxx11::basic_string"], align 16
@_Z1BB5cxx11 = external dso_local global [500 x %"class.std::__cxx11::basic_string"], align 16
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, 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 i32 @_Z3hshc(i8 noundef signext) #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 %"class.std::bitset", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"class.std::bitset<64>::reference", align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %"class.std::bitset<64>::reference", align 8
  store i32 0, ptr %1, align 4
  %16 = load ptr, ptr @stdin, align 8, !tbaa !5
  %17 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.4, ptr noundef %16)
  %18 = load ptr, ptr @stdout, align 8, !tbaa !5
  %19 = call ptr @freopen(ptr noundef @.str.5, ptr noundef @.str.6, ptr noundef %18)
  %20 = 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)
  %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) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %32, %0
  %23 = load i32, ptr %2, align 4, !tbaa !9
  %24 = load i32, ptr @N, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1AB5cxx11, i64 0, i64 %29
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %30)
  br label %32

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

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %46, %35
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = load i32, ptr @N, align 4, !tbaa !9
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %36
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1BB5cxx11, i64 0, i64 %43
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %44)
  br label %46

46:                                               ; preds = %41
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !9
  br label %36, !llvm.loop !13

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

50:                                               ; preds = %174, %49
  %51 = load i32, ptr %4, align 4, !tbaa !9
  %52 = load i32, ptr @M, align 4, !tbaa !9
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %177

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %56 = load i32, ptr %4, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %6, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %170, %55
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = load i32, ptr @M, align 4, !tbaa !9
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %173

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %7, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %166, %63
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = load i32, ptr @M, align 4, !tbaa !9
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %169

71:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @_ZNSt6bitsetILm64EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %109, %71
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = load i32, ptr @N, align 4, !tbaa !9
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %112

77:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1AB5cxx11, i64 0, i64 %79
  %81 = load i32, ptr %4, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %80, i64 noundef %82)
  %84 = load i8, ptr %83, align 1, !tbaa !14
  %85 = call noundef i32 @_Z3hshc(i8 noundef signext %84)
  %86 = load i32, ptr %9, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1AB5cxx11, i64 0, i64 %87
  %89 = load i32, ptr %6, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %88, i64 noundef %90)
  %92 = load i8, ptr %91, align 1, !tbaa !14
  %93 = call noundef i32 @_Z3hshc(i8 noundef signext %92)
  %94 = mul nsw i32 4, %93
  %95 = add nsw i32 %85, %94
  %96 = load i32, ptr %9, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1AB5cxx11, i64 0, i64 %97
  %99 = load i32, ptr %7, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %98, i64 noundef %100)
  %102 = load i8, ptr %101, align 1, !tbaa !14
  %103 = call noundef i32 @_Z3hshc(i8 noundef signext %102)
  %104 = mul nsw i32 16, %103
  %105 = add nsw i32 %95, %104
  store i32 %105, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %106 = load i32, ptr %10, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  call void @_ZNSt6bitsetILm64EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<64>::reference") align 8 %11, ptr noundef nonnull align 8 dereferenceable(8) %8, i64 noundef %107)
  %108 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm64EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %11, i1 noundef zeroext true) #4
  call void @_ZNSt6bitsetILm64EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %109

109:                                              ; preds = %77
  %110 = load i32, ptr %9, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %9, align 4, !tbaa !9
  br label %72, !llvm.loop !15

112:                                              ; preds = %76
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  store i8 0, ptr %12, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %113

113:                                              ; preds = %155, %112
  %114 = load i32, ptr %13, align 4, !tbaa !9
  %115 = load i32, ptr @N, align 4, !tbaa !9
  %116 = icmp slt i32 %114, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %113
  store i32 20, ptr %5, align 4
  br label %158

118:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %119 = load i32, ptr %13, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1BB5cxx11, i64 0, i64 %120
  %122 = load i32, ptr %4, align 4, !tbaa !9
  %123 = sext i32 %122 to i64
  %124 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %121, i64 noundef %123)
  %125 = load i8, ptr %124, align 1, !tbaa !14
  %126 = call noundef i32 @_Z3hshc(i8 noundef signext %125)
  %127 = load i32, ptr %13, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1BB5cxx11, i64 0, i64 %128
  %130 = load i32, ptr %6, align 4, !tbaa !9
  %131 = sext i32 %130 to i64
  %132 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %129, i64 noundef %131)
  %133 = load i8, ptr %132, align 1, !tbaa !14
  %134 = call noundef i32 @_Z3hshc(i8 noundef signext %133)
  %135 = mul nsw i32 4, %134
  %136 = add nsw i32 %126, %135
  %137 = load i32, ptr %13, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1BB5cxx11, i64 0, i64 %138
  %140 = load i32, ptr %7, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %139, i64 noundef %141)
  %143 = load i8, ptr %142, align 1, !tbaa !14
  %144 = call noundef i32 @_Z3hshc(i8 noundef signext %143)
  %145 = mul nsw i32 16, %144
  %146 = add nsw i32 %136, %145
  store i32 %146, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  %147 = load i32, ptr %14, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  call void @_ZNSt6bitsetILm64EEixEm(ptr dead_on_unwind writable sret(%"class.std::bitset<64>::reference") align 8 %15, ptr noundef nonnull align 8 dereferenceable(8) %8, i64 noundef %148)
  %149 = call noundef zeroext i1 @_ZNKSt6bitsetILm64EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %15) #4
  call void @_ZNSt6bitsetILm64EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  br i1 %149, label %150, label %151

150:                                              ; preds = %118
  store i8 1, ptr %12, align 1, !tbaa !16
  store i32 20, ptr %5, align 4
  br label %152

151:                                              ; preds = %118
  store i32 0, ptr %5, align 4
  br label %152

152:                                              ; preds = %151, %150
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %153 = load i32, ptr %5, align 4
  switch i32 %153, label %158 [
    i32 0, label %154
  ]

154:                                              ; preds = %152
  br label %155

155:                                              ; preds = %154
  %156 = load i32, ptr %13, align 4, !tbaa !9
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %13, align 4, !tbaa !9
  br label %113, !llvm.loop !18

158:                                              ; preds = %152, %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %159

159:                                              ; preds = %158
  %160 = load i8, ptr %12, align 1, !tbaa !16, !range !19, !noundef !20
  %161 = trunc i8 %160 to i1
  %162 = zext i1 %161 to i32
  %163 = xor i32 %162, 1
  %164 = load i32, ptr @ans, align 4, !tbaa !9
  %165 = add nsw i32 %164, %163
  store i32 %165, ptr @ans, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %166

166:                                              ; preds = %159
  %167 = load i32, ptr %7, align 4, !tbaa !9
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %7, align 4, !tbaa !9
  br label %66, !llvm.loop !21

169:                                              ; preds = %70
  br label %170

170:                                              ; preds = %169
  %171 = load i32, ptr %6, align 4, !tbaa !9
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %6, align 4, !tbaa !9
  br label %58, !llvm.loop !22

173:                                              ; preds = %62
  br label %174

174:                                              ; preds = %173
  %175 = load i32, ptr %4, align 4, !tbaa !9
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %4, align 4, !tbaa !9
  br label %50, !llvm.loop !23

177:                                              ; preds = %54
  %178 = load i32, ptr @ans, align 4, !tbaa !9
  %179 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %178)
  %180 = load i32, ptr %1, align 4
  ret i32 %180
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6bitsetILm64EEixEm(ptr dead_on_unwind noalias writable sret(%"class.std::bitset<64>::reference") align 8, ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm64EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16), i1 noundef zeroext) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6bitsetILm64EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !12}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = distinct !{!18, !12}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}


; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"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" }
%"class.std::bitset" = type { %"struct.std::_Base_bitset" }
%"struct.std::_Base_bitset" = type { i64 }
%"class.std::bitset<64>::reference" = type { ptr, i64 }

@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@_Z1AB5cxx11 = external dso_local global [500 x %"class.std::__cxx11::basic_string"], align 16
@_Z1BB5cxx11 = external dso_local global [500 x %"class.std::__cxx11::basic_string"], align 16
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, 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 i32 @_Z3hshc(i8 noundef signext) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca %"class.std::bitset", align 8
  %2 = alloca %"class.std::bitset<64>::reference", align 8
  %3 = alloca %"class.std::bitset<64>::reference", align 8
  %4 = load ptr, ptr @stdin, align 8, !tbaa !5
  %5 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4, ptr noundef %4)
  %6 = load ptr, ptr @stdout, align 8, !tbaa !5
  %7 = tail call ptr @freopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, ptr noundef %6)
  %8 = 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)
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %10 = load i32, ptr @N, align 4, !tbaa !9
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %.preheader44

.preheader45:                                     ; preds = %.lr.ph
  %12 = icmp sgt i32 %15, 0
  br i1 %12, label %.lr.ph48, label %.preheader44

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %13 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1AB5cxx11, i64 0, i64 %indvars.iv
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %13)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr @N, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = icmp slt i64 %indvars.iv.next, %16
  br i1 %17, label %.lr.ph, label %.preheader45, !llvm.loop !11

.preheader44:                                     ; preds = %.lr.ph48, %0, %.preheader45
  %18 = load i32, ptr @M, align 4, !tbaa !9
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph62, label %._crit_edge63

.lr.ph48:                                         ; preds = %.preheader45, %.lr.ph48
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %.lr.ph48 ], [ 0, %.preheader45 ]
  %20 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1BB5cxx11, i64 0, i64 %indvars.iv65
  %21 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) %20)
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %22 = load i32, ptr @N, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next66, %23
  br i1 %24, label %.lr.ph48, label %.preheader44, !llvm.loop !13

.loopexit43.loopexit:                             ; preds = %.loopexit
  %.pre = sext i32 %32 to i64
  br label %.loopexit43

.loopexit43:                                      ; preds = %.loopexit43.loopexit, %.lr.ph62
  %.pre-phi = phi i64 [ %.pre, %.loopexit43.loopexit ], [ %30, %.lr.ph62 ]
  %25 = phi i32 [ %32, %.loopexit43.loopexit ], [ %29, %.lr.ph62 ]
  %26 = icmp slt i64 %indvars.iv.next87, %.pre-phi
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  br i1 %26, label %.lr.ph62, label %._crit_edge63, !llvm.loop !14

._crit_edge63:                                    ; preds = %.loopexit43, %.preheader44
  %27 = load i32, ptr @ans, align 4, !tbaa !9
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %27)
  ret i32 0

.lr.ph62:                                         ; preds = %.preheader44, %.loopexit43
  %29 = phi i32 [ %25, %.loopexit43 ], [ %18, %.preheader44 ]
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %.loopexit43 ], [ 0, %.preheader44 ]
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %.loopexit43 ], [ 1, %.preheader44 ]
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %.loopexit43 ], [ 2, %.preheader44 ]
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next87, %30
  br i1 %31, label %.lr.ph60, label %.loopexit43

.loopexit:                                        ; preds = %._crit_edge, %.lr.ph60
  %32 = phi i32 [ %35, %.lr.ph60 ], [ %83, %._crit_edge ]
  %33 = phi i32 [ %36, %.lr.ph60 ], [ %83, %._crit_edge ]
  %34 = icmp sgt i32 %33, %37
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  br i1 %34, label %.lr.ph60, label %.loopexit43.loopexit, !llvm.loop !15

.lr.ph60:                                         ; preds = %.lr.ph62, %.loopexit
  %35 = phi i32 [ %32, %.loopexit ], [ %29, %.lr.ph62 ]
  %36 = phi i32 [ %33, %.loopexit ], [ %29, %.lr.ph62 ]
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %.loopexit ], [ %indvars.iv81, %.lr.ph62 ]
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %.loopexit ], [ %indvars.iv74, %.lr.ph62 ]
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %37 = trunc nuw i64 %indvars.iv.next84 to i32
  %38 = icmp sgt i32 %36, %37
  br i1 %38, label %.lr.ph57, label %.loopexit

.lr.ph57:                                         ; preds = %.lr.ph60, %._crit_edge
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %._crit_edge ], [ %indvars.iv76, %.lr.ph60 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @_ZNSt6bitsetILm64EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #4
  %39 = load i32, ptr @N, align 4, !tbaa !9
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %.lr.ph50, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph50
  %41 = icmp sgt i32 %58, 0
  br i1 %41, label %.lr.ph52, label %._crit_edge

.lr.ph50:                                         ; preds = %.lr.ph57, %.lr.ph50
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.lr.ph50 ], [ 0, %.lr.ph57 ]
  %42 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1AB5cxx11, i64 0, i64 %indvars.iv68
  %43 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %42, i64 noundef %indvars.iv86)
  %44 = load i8, ptr %43, align 1, !tbaa !16
  %45 = call noundef i32 @_Z3hshc(i8 noundef signext %44)
  %46 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %42, i64 noundef %indvars.iv83)
  %47 = load i8, ptr %46, align 1, !tbaa !16
  %48 = call noundef i32 @_Z3hshc(i8 noundef signext %47)
  %49 = shl nsw i32 %48, 2
  %50 = add nsw i32 %49, %45
  %51 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %42, i64 noundef %indvars.iv78)
  %52 = load i8, ptr %51, align 1, !tbaa !16
  %53 = call noundef i32 @_Z3hshc(i8 noundef signext %52)
  %54 = shl nsw i32 %53, 4
  %55 = add nsw i32 %50, %54
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  %56 = sext i32 %55 to i64
  call void @_ZNSt6bitsetILm64EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<64>::reference") align 8 %2, ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %56)
  %57 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm64EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16) %2, i1 noundef zeroext true) #4
  call void @_ZNSt6bitsetILm64EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %58 = load i32, ptr @N, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = icmp slt i64 %indvars.iv.next69, %59
  br i1 %60, label %.lr.ph50, label %.preheader, !llvm.loop !17

61:                                               ; preds = %.lr.ph52
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %62 = load i32, ptr @N, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = icmp slt i64 %indvars.iv.next72, %63
  br i1 %64, label %.lr.ph52, label %._crit_edge, !llvm.loop !18

.lr.ph52:                                         ; preds = %.preheader, %61
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %61 ], [ 0, %.preheader ]
  %65 = getelementptr inbounds [500 x %"class.std::__cxx11::basic_string"], ptr @_Z1BB5cxx11, i64 0, i64 %indvars.iv71
  %66 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %65, i64 noundef %indvars.iv86)
  %67 = load i8, ptr %66, align 1, !tbaa !16
  %68 = call noundef i32 @_Z3hshc(i8 noundef signext %67)
  %69 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %65, i64 noundef %indvars.iv83)
  %70 = load i8, ptr %69, align 1, !tbaa !16
  %71 = call noundef i32 @_Z3hshc(i8 noundef signext %70)
  %72 = shl nsw i32 %71, 2
  %73 = add nsw i32 %72, %68
  %74 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %65, i64 noundef %indvars.iv78)
  %75 = load i8, ptr %74, align 1, !tbaa !16
  %76 = call noundef i32 @_Z3hshc(i8 noundef signext %75)
  %77 = shl nsw i32 %76, 4
  %78 = add nsw i32 %73, %77
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %79 = sext i32 %78 to i64
  call void @_ZNSt6bitsetILm64EEixEm(ptr dead_on_unwind nonnull writable sret(%"class.std::bitset<64>::reference") align 8 %3, ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %79)
  %80 = call noundef zeroext i1 @_ZNKSt6bitsetILm64EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @_ZNSt6bitsetILm64EE9referenceD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  br i1 %80, label %._crit_edge, label %61

._crit_edge:                                      ; preds = %.lr.ph52, %61, %.lr.ph57, %.preheader
  %.2 = phi i32 [ 1, %.preheader ], [ 1, %.lr.ph57 ], [ 1, %61 ], [ 0, %.lr.ph52 ]
  %81 = load i32, ptr @ans, align 4, !tbaa !9
  %82 = add nsw i32 %81, %.2
  store i32 %82, ptr @ans, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %83 = load i32, ptr @M, align 4, !tbaa !9
  %84 = trunc nuw i64 %indvars.iv.next79 to i32
  %85 = icmp sgt i32 %83, %84
  br i1 %85, label %.lr.ph57, label %.loopexit, !llvm.loop !19
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6bitsetILm64EEixEm(ptr dead_on_unwind noalias writable sret(%"class.std::bitset<64>::reference") align 8, ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm64EE9referenceaSEb(ptr noundef nonnull align 8 dereferenceable(16), i1 noundef zeroext) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6bitsetILm64EE9referencecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


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