; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/DP Level 3/Balancing the Stone (bal)

; 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" }
%"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] }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %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 [1000000 x i64], align 16
  %7 = alloca [2 x [2 x i64]], align 16
  %8 = alloca %"class.std::__cxx11::basic_string", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8000000, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %8) #7
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #7
  %13 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
          to label %14 unwind label %47

14:                                               ; preds = %0
  br label %15

15:                                               ; preds = %208, %14
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = add nsw i32 %16, -1
  store i32 %17, ptr %2, align 4, !tbaa !5
  %18 = icmp ne i32 %16, 0
  br i1 %18, label %19, label %214

19:                                               ; preds = %15
  %20 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %20, i8 0, i64 32, i1 false)
  %21 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4, ptr noundef %5)
          to label %22 unwind label %47

22:                                               ; preds = %19
  %23 = invoke 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) %8)
          to label %24 unwind label %47

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

25:                                               ; preds = %44, %24
  %26 = load i32, ptr %11, align 4, !tbaa !5
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %55

29:                                               ; preds = %25
  %30 = load i32, ptr %11, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = invoke noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %8, i64 noundef %31)
          to label %33 unwind label %51

33:                                               ; preds = %29
  %34 = load i8, ptr %32, align 1, !tbaa !9
  %35 = sext i8 %34 to i32
  %36 = sub nsw i32 %35, 48
  %37 = sext i32 %36 to i64
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = sub nsw i32 %38, %39
  %41 = sub nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1000000 x i64], ptr %6, i64 0, i64 %42
  store i64 %37, ptr %43, align 8, !tbaa !10
  br label %44

44:                                               ; preds = %33
  %45 = load i32, ptr %11, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %11, align 4, !tbaa !5
  br label %25, !llvm.loop !12

47:                                               ; preds = %22, %19, %0
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %9, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %10, align 4
  br label %216

51:                                               ; preds = %29
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %9, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %10, align 4
  br label %213

55:                                               ; preds = %25
  br label %56

56:                                               ; preds = %64, %55
  %57 = load i32, ptr %11, align 4, !tbaa !5
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %60, label %67

60:                                               ; preds = %56
  %61 = load i32, ptr %11, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1000000 x i64], ptr %6, i64 0, i64 %62
  store i64 0, ptr %63, align 8, !tbaa !10
  br label %64

64:                                               ; preds = %60
  %65 = load i32, ptr %11, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %11, align 4, !tbaa !5
  br label %56, !llvm.loop !14

67:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %74, %67
  %69 = load i32, ptr %11, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1000000 x i64], ptr %6, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !10
  %73 = icmp eq i64 %72, 0
  br i1 %73, label %74, label %77

74:                                               ; preds = %68
  %75 = load i32, ptr %11, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %11, align 4, !tbaa !5
  br label %68, !llvm.loop !15

77:                                               ; preds = %68
  %78 = load i32, ptr %12, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %79
  %81 = getelementptr inbounds [2 x i64], ptr %80, i64 0, i64 0
  store i64 1, ptr %81, align 16, !tbaa !10
  %82 = load i32, ptr %12, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %83
  %85 = getelementptr inbounds [2 x i64], ptr %84, i64 0, i64 1
  store i64 1, ptr %85, align 8, !tbaa !10
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %11, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %187, %77
  %89 = load i32, ptr %11, align 4, !tbaa !5
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %92, label %190

92:                                               ; preds = %88
  %93 = load i32, ptr %12, align 4, !tbaa !5
  %94 = sub nsw i32 1, %93
  store i32 %94, ptr %12, align 4, !tbaa !5
  %95 = load i32, ptr %11, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1000000 x i64], ptr %6, i64 0, i64 %96
  %98 = load i64, ptr %97, align 8, !tbaa !10
  %99 = icmp eq i64 %98, 0
  br i1 %99, label %100, label %142

100:                                              ; preds = %92
  %101 = load i32, ptr %12, align 4, !tbaa !5
  %102 = sub nsw i32 1, %101
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %103
  %105 = getelementptr inbounds [2 x i64], ptr %104, i64 0, i64 0
  %106 = load i64, ptr %105, align 16, !tbaa !10
  %107 = load i32, ptr %12, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %108
  %110 = getelementptr inbounds [2 x i64], ptr %109, i64 0, i64 0
  store i64 %106, ptr %110, align 16, !tbaa !10
  %111 = load i32, ptr %11, align 4, !tbaa !5
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = sub nsw i32 %112, 1
  %114 = icmp eq i32 %111, %113
  br i1 %114, label %115, label %125

115:                                              ; preds = %100
  %116 = load i32, ptr %12, align 4, !tbaa !5
  %117 = sub nsw i32 1, %116
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %118
  %120 = getelementptr inbounds [2 x i64], ptr %119, i64 0, i64 1
  %121 = load i64, ptr %120, align 8, !tbaa !10
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = srem i64 %121, %123
  br label %136

125:                                              ; preds = %100
  %126 = load i32, ptr %12, align 4, !tbaa !5
  %127 = sub nsw i32 1, %126
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %128
  %130 = getelementptr inbounds [2 x i64], ptr %129, i64 0, i64 1
  %131 = load i64, ptr %130, align 8, !tbaa !10
  %132 = mul nsw i64 %131, 2
  %133 = load i32, ptr %5, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = srem i64 %132, %134
  br label %136

136:                                              ; preds = %125, %115
  %137 = phi i64 [ %124, %115 ], [ %135, %125 ]
  %138 = load i32, ptr %12, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %139
  %141 = getelementptr inbounds [2 x i64], ptr %140, i64 0, i64 1
  store i64 %137, ptr %141, align 8, !tbaa !10
  br label %186

142:                                              ; preds = %92
  %143 = load i32, ptr %12, align 4, !tbaa !5
  %144 = sub nsw i32 1, %143
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %145
  %147 = getelementptr inbounds [2 x i64], ptr %146, i64 0, i64 0
  %148 = load i64, ptr %147, align 16, !tbaa !10
  %149 = load i32, ptr %12, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %150
  %152 = getelementptr inbounds [2 x i64], ptr %151, i64 0, i64 0
  store i64 %148, ptr %152, align 16, !tbaa !10
  %153 = load i32, ptr %11, align 4, !tbaa !5
  %154 = load i32, ptr %3, align 4, !tbaa !5
  %155 = sub nsw i32 %154, 1
  %156 = icmp eq i32 %153, %155
  br i1 %156, label %157, label %163

157:                                              ; preds = %142
  %158 = load i32, ptr %12, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %159
  %161 = getelementptr inbounds [2 x i64], ptr %160, i64 0, i64 1
  %162 = load i64, ptr %161, align 8, !tbaa !10
  br label %180

163:                                              ; preds = %142
  %164 = load i32, ptr %12, align 4, !tbaa !5
  %165 = sub nsw i32 1, %164
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %166
  %168 = getelementptr inbounds [2 x i64], ptr %167, i64 0, i64 0
  %169 = load i64, ptr %168, align 16, !tbaa !10
  %170 = load i32, ptr %12, align 4, !tbaa !5
  %171 = sub nsw i32 1, %170
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %172
  %174 = getelementptr inbounds [2 x i64], ptr %173, i64 0, i64 1
  %175 = load i64, ptr %174, align 8, !tbaa !10
  %176 = add nsw i64 %169, %175
  %177 = load i32, ptr %5, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = srem i64 %176, %178
  br label %180

180:                                              ; preds = %163, %157
  %181 = phi i64 [ %162, %157 ], [ %179, %163 ]
  %182 = load i32, ptr %12, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %183
  %185 = getelementptr inbounds [2 x i64], ptr %184, i64 0, i64 1
  store i64 %181, ptr %185, align 8, !tbaa !10
  br label %186

186:                                              ; preds = %180, %136
  br label %187

187:                                              ; preds = %186
  %188 = load i32, ptr %11, align 4, !tbaa !5
  %189 = add nsw i32 %188, 1
  store i32 %189, ptr %11, align 4, !tbaa !5
  br label %88, !llvm.loop !16

190:                                              ; preds = %88
  %191 = load i32, ptr %12, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %192
  %194 = getelementptr inbounds [2 x i64], ptr %193, i64 0, i64 0
  %195 = load i64, ptr %194, align 16, !tbaa !10
  %196 = load i32, ptr %12, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [2 x [2 x i64]], ptr %7, i64 0, i64 %197
  %199 = getelementptr inbounds [2 x i64], ptr %198, i64 0, i64 1
  %200 = load i64, ptr %199, align 8, !tbaa !10
  %201 = add nsw i64 %195, %200
  %202 = load i32, ptr %5, align 4, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = srem i64 %201, %203
  %205 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %204)
          to label %206 unwind label %209

206:                                              ; preds = %190
  %207 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %205, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %208 unwind label %209

208:                                              ; preds = %206
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %15, !llvm.loop !17

209:                                              ; preds = %206, %190
  %210 = landingpad { ptr, i32 }
          cleanup
  %211 = extractvalue { ptr, i32 } %210, 0
  store ptr %211, ptr %9, align 8
  %212 = extractvalue { ptr, i32 } %210, 1
  store i32 %212, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %213

213:                                              ; preds = %209, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %216

214:                                              ; preds = %15
  store i32 0, ptr %1, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8000000, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %215 = load i32, ptr %1, align 4
  ret i32 %215

216:                                              ; preds = %213, %47
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8000000, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %217

217:                                              ; preds = %216
  %218 = load ptr, ptr %9, align 8
  %219 = load i32, ptr %10, align 4
  %220 = insertvalue { ptr, i32 } poison, ptr %218, 0
  %221 = insertvalue { ptr, i32 } %220, i32 %219, 1
  resume { ptr, i32 } %221
}

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #5 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) #5 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)) #6

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "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 nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}


; 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" }
%"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] }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [1000000 x i64], align 16
  %6 = alloca [2 x [2 x i64]], align 16
  %7 = alloca %"class.std::__cxx11::basic_string", align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.start.p0(i64 8000000, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #8
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  %10 = getelementptr inbounds i8, ptr %6, i64 16
  br label %11

11:                                               ; preds = %83, %0
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %87, label %14

14:                                               ; preds = %11
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %10, i8 0, i64 16, i1 false)
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %16 = invoke 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) %7)
          to label %.preheader38 unwind label %41

.preheader38:                                     ; preds = %14
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %.preheader37

.preheader37.loopexit:                            ; preds = %.lr.ph
  %19 = trunc nuw nsw i64 %indvars.iv.next to i32
  br label %.preheader37

.preheader37:                                     ; preds = %.preheader37.loopexit, %.preheader38
  %.033.lcssa = phi i32 [ 0, %.preheader38 ], [ %19, %.preheader37.loopexit ]
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp slt i32 %.033.lcssa, %20
  br i1 %21, label %.lr.ph41.preheader, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.lr.ph41.preheader, %.preheader37
  br label %.preheader

.lr.ph41.preheader:                               ; preds = %.preheader37
  %22 = zext nneg i32 %.033.lcssa to i64
  %23 = shl nuw nsw i64 %22, 3
  %scevgep = getelementptr i8, ptr %5, i64 %23
  %24 = xor i32 %.033.lcssa, -1
  %25 = add i32 %20, %24
  %26 = zext i32 %25 to i64
  %27 = shl nuw nsw i64 %26, 3
  %28 = add nuw nsw i64 %27, 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %scevgep, i8 0, i64 %28, i1 false), !tbaa !9
  br label %.preheader.preheader

.lr.ph:                                           ; preds = %.preheader38, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader38 ]
  %29 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %7, i64 noundef %indvars.iv)
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = sext i8 %30 to i64
  %32 = add nsw i64 %31, -48
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = trunc nuw nsw i64 %indvars.iv to i32
  %35 = xor i32 %34, -1
  %36 = add i32 %33, %35
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1000000 x i64], ptr %5, i64 0, i64 %37
  store i64 %32, ptr %38, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = sext i32 %33 to i64
  %40 = icmp slt i64 %indvars.iv.next, %39
  br i1 %40, label %.lr.ph, label %.preheader37.loopexit, !llvm.loop !12

41:                                               ; preds = %14
  %42 = landingpad { ptr, i32 }
          cleanup
  br label %88

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %.preheader ], [ 1, %.preheader.preheader ]
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %.preheader ], [ 0, %.preheader.preheader ]
  %43 = getelementptr inbounds [1000000 x i64], ptr %5, i64 0, i64 %indvars.iv54
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = icmp eq i64 %44, 0
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %indvars.iv.next58 = add nuw i64 %indvars.iv57, 1
  br i1 %45, label %.preheader, label %46, !llvm.loop !14

46:                                               ; preds = %.preheader
  %47 = trunc nuw nsw i64 %indvars.iv54 to i32
  store i64 1, ptr %6, align 16, !tbaa !9
  store i64 1, ptr %9, align 8, !tbaa !9
  %.343 = add nuw nsw i32 %47, 1
  %48 = icmp slt i32 %.343, %20
  %.pre65 = load i32, ptr %4, align 4
  br i1 %48, label %.lr.ph47, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %46
  %.pre68 = sext i32 %.pre65 to i64
  br label %._crit_edge

.lr.ph47:                                         ; preds = %46
  %49 = add i32 %20, -2
  %50 = sext i32 %.pre65 to i64
  %wide.trip.count = zext i32 %20 to i64
  br label %51

51:                                               ; preds = %.lr.ph47, %76
  %indvars.iv59 = phi i64 [ %indvars.iv57, %.lr.ph47 ], [ %indvars.iv.next60, %76 ]
  %.045 = phi i32 [ 0, %.lr.ph47 ], [ %52, %76 ]
  %.3.in44 = phi i32 [ %47, %.lr.ph47 ], [ %78, %76 ]
  %52 = sub nuw nsw i32 1, %.045
  %53 = getelementptr inbounds [1000000 x i64], ptr %5, i64 0, i64 %indvars.iv59
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = icmp eq i64 %54, 0
  %56 = zext nneg i32 %.045 to i64
  %57 = getelementptr inbounds [2 x [2 x i64]], ptr %6, i64 0, i64 %56
  %58 = load i64, ptr %57, align 16, !tbaa !9
  %59 = zext nneg i32 %52 to i64
  %60 = getelementptr inbounds [2 x [2 x i64]], ptr %6, i64 0, i64 %59
  store i64 %58, ptr %60, align 16, !tbaa !9
  %61 = icmp ne i32 %.3.in44, %49
  br i1 %55, label %62, label %67

62:                                               ; preds = %51
  %63 = getelementptr inbounds i8, ptr %57, i64 8
  %64 = load i64, ptr %63, align 8, !tbaa !9
  %65 = zext i1 %61 to i64
  %.pn69 = shl nsw i64 %64, %65
  %66 = srem i64 %.pn69, %50
  br label %76

67:                                               ; preds = %51
  br i1 %61, label %71, label %68

68:                                               ; preds = %67
  %69 = getelementptr inbounds i8, ptr %60, i64 8
  %70 = load i64, ptr %69, align 8, !tbaa !9
  br label %76

71:                                               ; preds = %67
  %72 = getelementptr inbounds i8, ptr %57, i64 8
  %73 = load i64, ptr %72, align 8, !tbaa !9
  %74 = add nsw i64 %73, %58
  %75 = srem i64 %74, %50
  br label %76

76:                                               ; preds = %68, %71, %62
  %.sink = phi i64 [ %66, %62 ], [ %70, %68 ], [ %75, %71 ]
  %77 = getelementptr inbounds i8, ptr %60, i64 8
  store i64 %.sink, ptr %77, align 8, !tbaa !9
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %78 = trunc nuw i64 %indvars.iv59 to i32
  %exitcond.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %51, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %76
  %79 = add nsw i64 %.sink, %58
  br label %._crit_edge

._crit_edge:                                      ; preds = %.._crit_edge_crit_edge, %._crit_edge.loopexit
  %.pre-phi = phi i64 [ %.pre68, %.._crit_edge_crit_edge ], [ %50, %._crit_edge.loopexit ]
  %80 = phi i64 [ 2, %.._crit_edge_crit_edge ], [ %79, %._crit_edge.loopexit ]
  %81 = srem i64 %80, %.pre-phi
  %82 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %81)
          to label %83 unwind label %85

83:                                               ; preds = %._crit_edge
  %84 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %82, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %11 unwind label %85, !llvm.loop !16

85:                                               ; preds = %83, %._crit_edge
  %86 = landingpad { ptr, i32 }
          cleanup
  br label %88

87:                                               ; preds = %11
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 8000000, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0

88:                                               ; preds = %85, %41
  %.pn = phi { ptr, i32 } [ %86, %85 ], [ %42, %41 ]
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 8000000, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  resume { ptr, i32 } %.pn
}

; 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 nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

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

; 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 nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { "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 = { 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 #8 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass