; LLVM IR from eyangch/competitive-programming :: FacebookHackercup/2020/round1 (b)

; 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::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@S = external dso_local global i64, align 8
@P = external dso_local global [1000005 x i64], align 16
@Ap = external dso_local global i64, align 8
@Bp = external dso_local global i64, align 8
@Cp = external dso_local global i64, align 8
@Dp = external dso_local global i64, align 8
@Q = external dso_local global [1000005 x i64], align 16
@Aq = external dso_local global i64, align 8
@Bq = external dso_local global i64, align 8
@Cq = external dso_local global i64, align 8
@Dq = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5worksx(i64 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 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::basic_ofstream", align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %15 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %16 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = load ptr, ptr @stdin, align 8, !tbaa !8
  %22 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 512, ptr %2) #6
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %2, ptr noundef @.str.2, i32 noundef 16)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %23 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %24 unwind label %30

24:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 1, ptr %6, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %235, %24
  %26 = load i64, ptr %6, align 8, !tbaa !11
  %27 = load i64, ptr %3, align 8, !tbaa !11
  %28 = icmp sle i64 %26, %27
  br i1 %28, label %34, label %29

29:                                               ; preds = %25
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %239

30:                                               ; preds = %0
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %4, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %5, align 4
  br label %241

34:                                               ; preds = %25
  %35 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.3)
          to label %36 unwind label %55

36:                                               ; preds = %34
  %37 = load i64, ptr %6, align 8, !tbaa !11
  %38 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %35, i64 noundef %37)
          to label %39 unwind label %55

39:                                               ; preds = %36
  %40 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %41 unwind label %55

41:                                               ; preds = %39
  %42 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
          to label %43 unwind label %55

43:                                               ; preds = %41
  %44 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef nonnull align 8 dereferenceable(8) @M)
          to label %45 unwind label %55

45:                                               ; preds = %43
  %46 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 8 dereferenceable(8) @K)
          to label %47 unwind label %55

47:                                               ; preds = %45
  %48 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %46, ptr noundef nonnull align 8 dereferenceable(8) @S)
          to label %49 unwind label %55

49:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %50

50:                                               ; preds = %64, %49
  %51 = load i64, ptr %8, align 8, !tbaa !11
  %52 = load i64, ptr @K, align 8, !tbaa !11
  %53 = icmp slt i64 %51, %52
  br i1 %53, label %59, label %54

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

55:                                               ; preds = %175, %173, %170, %167, %103, %101, %99, %97, %77, %75, %73, %71, %47, %45, %43, %41, %39, %36, %34
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %4, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %5, align 4
  br label %238

59:                                               ; preds = %50
  %60 = load i64, ptr %8, align 8, !tbaa !11
  %61 = getelementptr inbounds [1000005 x i64], ptr @P, i64 0, i64 %60
  %62 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %61)
          to label %63 unwind label %67

63:                                               ; preds = %59
  br label %64

64:                                               ; preds = %63
  %65 = load i64, ptr %8, align 8, !tbaa !11
  %66 = add nsw i64 %65, 1
  store i64 %66, ptr %8, align 8, !tbaa !11
  br label %50, !llvm.loop !13

67:                                               ; preds = %59
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %4, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %238

71:                                               ; preds = %54
  %72 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @Ap)
          to label %73 unwind label %55

73:                                               ; preds = %71
  %74 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %72, ptr noundef nonnull align 8 dereferenceable(8) @Bp)
          to label %75 unwind label %55

75:                                               ; preds = %73
  %76 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %74, ptr noundef nonnull align 8 dereferenceable(8) @Cp)
          to label %77 unwind label %55

77:                                               ; preds = %75
  %78 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %76, ptr noundef nonnull align 8 dereferenceable(8) @Dp)
          to label %79 unwind label %55

79:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %80

80:                                               ; preds = %90, %79
  %81 = load i64, ptr %9, align 8, !tbaa !11
  %82 = load i64, ptr @K, align 8, !tbaa !11
  %83 = icmp slt i64 %81, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %80
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %97

85:                                               ; preds = %80
  %86 = load i64, ptr %9, align 8, !tbaa !11
  %87 = getelementptr inbounds [1000005 x i64], ptr @Q, i64 0, i64 %86
  %88 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %87)
          to label %89 unwind label %93

89:                                               ; preds = %85
  br label %90

90:                                               ; preds = %89
  %91 = load i64, ptr %9, align 8, !tbaa !11
  %92 = add nsw i64 %91, 1
  store i64 %92, ptr %9, align 8, !tbaa !11
  br label %80, !llvm.loop !15

93:                                               ; preds = %85
  %94 = landingpad { ptr, i32 }
          cleanup
  %95 = extractvalue { ptr, i32 } %94, 0
  store ptr %95, ptr %4, align 8
  %96 = extractvalue { ptr, i32 } %94, 1
  store i32 %96, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %238

97:                                               ; preds = %84
  %98 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @Aq)
          to label %99 unwind label %55

99:                                               ; preds = %97
  %100 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %98, ptr noundef nonnull align 8 dereferenceable(8) @Bq)
          to label %101 unwind label %55

101:                                              ; preds = %99
  %102 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %100, ptr noundef nonnull align 8 dereferenceable(8) @Cq)
          to label %103 unwind label %55

103:                                              ; preds = %101
  %104 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %102, ptr noundef nonnull align 8 dereferenceable(8) @Dq)
          to label %105 unwind label %55

105:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %106 = load i64, ptr @K, align 8, !tbaa !11
  store i64 %106, ptr %10, align 8, !tbaa !11
  br label %107

107:                                              ; preds = %133, %105
  %108 = load i64, ptr %10, align 8, !tbaa !11
  %109 = load i64, ptr @N, align 8, !tbaa !11
  %110 = icmp slt i64 %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %107
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %136

112:                                              ; preds = %107
  %113 = load i64, ptr @Ap, align 8, !tbaa !11
  %114 = load i64, ptr %10, align 8, !tbaa !11
  %115 = sub nsw i64 %114, 2
  %116 = getelementptr inbounds [1000005 x i64], ptr @P, i64 0, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !11
  %118 = mul nsw i64 %113, %117
  %119 = load i64, ptr @Bp, align 8, !tbaa !11
  %120 = load i64, ptr %10, align 8, !tbaa !11
  %121 = sub nsw i64 %120, 1
  %122 = getelementptr inbounds [1000005 x i64], ptr @P, i64 0, i64 %121
  %123 = load i64, ptr %122, align 8, !tbaa !11
  %124 = mul nsw i64 %119, %123
  %125 = add nsw i64 %118, %124
  %126 = load i64, ptr @Cp, align 8, !tbaa !11
  %127 = add nsw i64 %125, %126
  %128 = load i64, ptr @Dp, align 8, !tbaa !11
  %129 = srem i64 %127, %128
  %130 = add nsw i64 %129, 1
  %131 = load i64, ptr %10, align 8, !tbaa !11
  %132 = getelementptr inbounds [1000005 x i64], ptr @P, i64 0, i64 %131
  store i64 %130, ptr %132, align 8, !tbaa !11
  br label %133

133:                                              ; preds = %112
  %134 = load i64, ptr %10, align 8, !tbaa !11
  %135 = add nsw i64 %134, 1
  store i64 %135, ptr %10, align 8, !tbaa !11
  br label %107, !llvm.loop !16

136:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %137 = load i64, ptr @K, align 8, !tbaa !11
  store i64 %137, ptr %11, align 8, !tbaa !11
  br label %138

138:                                              ; preds = %164, %136
  %139 = load i64, ptr %11, align 8, !tbaa !11
  %140 = load i64, ptr @M, align 8, !tbaa !11
  %141 = icmp slt i64 %139, %140
  br i1 %141, label %143, label %142

142:                                              ; preds = %138
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %167

143:                                              ; preds = %138
  %144 = load i64, ptr @Aq, align 8, !tbaa !11
  %145 = load i64, ptr %11, align 8, !tbaa !11
  %146 = sub nsw i64 %145, 2
  %147 = getelementptr inbounds [1000005 x i64], ptr @Q, i64 0, i64 %146
  %148 = load i64, ptr %147, align 8, !tbaa !11
  %149 = mul nsw i64 %144, %148
  %150 = load i64, ptr @Bq, align 8, !tbaa !11
  %151 = load i64, ptr %11, align 8, !tbaa !11
  %152 = sub nsw i64 %151, 1
  %153 = getelementptr inbounds [1000005 x i64], ptr @Q, i64 0, i64 %152
  %154 = load i64, ptr %153, align 8, !tbaa !11
  %155 = mul nsw i64 %150, %154
  %156 = add nsw i64 %149, %155
  %157 = load i64, ptr @Cq, align 8, !tbaa !11
  %158 = add nsw i64 %156, %157
  %159 = load i64, ptr @Dq, align 8, !tbaa !11
  %160 = srem i64 %158, %159
  %161 = add nsw i64 %160, 1
  %162 = load i64, ptr %11, align 8, !tbaa !11
  %163 = getelementptr inbounds [1000005 x i64], ptr @Q, i64 0, i64 %162
  store i64 %161, ptr %163, align 8, !tbaa !11
  br label %164

164:                                              ; preds = %143
  %165 = load i64, ptr %11, align 8, !tbaa !11
  %166 = add nsw i64 %165, 1
  store i64 %166, ptr %11, align 8, !tbaa !11
  br label %138, !llvm.loop !17

167:                                              ; preds = %142
  %168 = load i64, ptr @N, align 8, !tbaa !11
  %169 = getelementptr inbounds i64, ptr @P, i64 %168
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef @P, ptr noundef %169)
          to label %170 unwind label %55

170:                                              ; preds = %167
  %171 = load i64, ptr @M, align 8, !tbaa !11
  %172 = getelementptr inbounds i64, ptr @Q, i64 %171
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef @Q, ptr noundef %172)
          to label %173 unwind label %55

173:                                              ; preds = %170
  %174 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.4)
          to label %175 unwind label %55

175:                                              ; preds = %173
  %176 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %174, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %177 unwind label %55

177:                                              ; preds = %175
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store i64 0, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 2147483647, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store i64 0, ptr %14, align 8, !tbaa !11
  br label %178

178:                                              ; preds = %200, %177
  %179 = load i64, ptr %12, align 8, !tbaa !11
  %180 = load i64, ptr %13, align 8, !tbaa !11
  %181 = icmp slt i64 %179, %180
  br i1 %181, label %182, label %201

182:                                              ; preds = %178
  %183 = load i64, ptr %12, align 8, !tbaa !11
  %184 = load i64, ptr %13, align 8, !tbaa !11
  %185 = add nsw i64 %183, %184
  %186 = sdiv i64 %185, 2
  store i64 %186, ptr %14, align 8, !tbaa !11
  %187 = load i64, ptr %14, align 8, !tbaa !11
  %188 = invoke noundef zeroext i1 @_Z5worksx(i64 noundef %187)
          to label %189 unwind label %193

189:                                              ; preds = %182
  br i1 %188, label %190, label %197

190:                                              ; preds = %189
  %191 = load i64, ptr %14, align 8, !tbaa !11
  %192 = sub nsw i64 %191, 1
  store i64 %192, ptr %13, align 8, !tbaa !11
  br label %200

193:                                              ; preds = %232, %229, %227, %224, %222, %220, %218, %210, %202, %182
  %194 = landingpad { ptr, i32 }
          cleanup
  %195 = extractvalue { ptr, i32 } %194, 0
  store ptr %195, ptr %4, align 8
  %196 = extractvalue { ptr, i32 } %194, 1
  store i32 %196, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %238

197:                                              ; preds = %189
  %198 = load i64, ptr %14, align 8, !tbaa !11
  %199 = add nsw i64 %198, 1
  store i64 %199, ptr %12, align 8, !tbaa !11
  br label %200

200:                                              ; preds = %197, %190
  br label %178, !llvm.loop !18

201:                                              ; preds = %178
  br label %202

202:                                              ; preds = %206, %201
  %203 = load i64, ptr %14, align 8, !tbaa !11
  %204 = invoke noundef zeroext i1 @_Z5worksx(i64 noundef %203)
          to label %205 unwind label %193

205:                                              ; preds = %202
  br i1 %204, label %206, label %209

206:                                              ; preds = %205
  %207 = load i64, ptr %14, align 8, !tbaa !11
  %208 = add nsw i64 %207, -1
  store i64 %208, ptr %14, align 8, !tbaa !11
  br label %202, !llvm.loop !19

209:                                              ; preds = %205
  br label %210

210:                                              ; preds = %215, %209
  %211 = load i64, ptr %14, align 8, !tbaa !11
  %212 = invoke noundef zeroext i1 @_Z5worksx(i64 noundef %211)
          to label %213 unwind label %193

213:                                              ; preds = %210
  %214 = xor i1 %212, true
  br i1 %214, label %215, label %218

215:                                              ; preds = %213
  %216 = load i64, ptr %14, align 8, !tbaa !11
  %217 = add nsw i64 %216, 1
  store i64 %217, ptr %14, align 8, !tbaa !11
  br label %210, !llvm.loop !20

218:                                              ; preds = %213
  %219 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.5)
          to label %220 unwind label %193

220:                                              ; preds = %218
  %221 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %219, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %222 unwind label %193

222:                                              ; preds = %220
  %223 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef @.str.6)
          to label %224 unwind label %193

224:                                              ; preds = %222
  %225 = load i64, ptr %6, align 8, !tbaa !11
  %226 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %223, i64 noundef %225)
          to label %227 unwind label %193

227:                                              ; preds = %224
  %228 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %226, ptr noundef @.str.7)
          to label %229 unwind label %193

229:                                              ; preds = %227
  %230 = load i64, ptr %14, align 8, !tbaa !11
  %231 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %228, i64 noundef %230)
          to label %232 unwind label %193

232:                                              ; preds = %229
  %233 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %231, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %234 unwind label %193

234:                                              ; preds = %232
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %235

235:                                              ; preds = %234
  %236 = load i64, ptr %6, align 8, !tbaa !11
  %237 = add nsw i64 %236, 1
  store i64 %237, ptr %6, align 8, !tbaa !11
  br label %25, !llvm.loop !21

238:                                              ; preds = %193, %93, %67, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %241

239:                                              ; preds = %29
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %2) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr %2) #6
  %240 = load i32, ptr %1, align 4
  ret i32 %240

241:                                              ; preds = %238, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %2) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr %2) #6
  br label %242

242:                                              ; preds = %241
  %243 = load ptr, ptr %4, align 8
  %244 = load i32, ptr %5, align 4
  %245 = insertvalue { ptr, i32 } poison, ptr %243, 0
  %246 = insertvalue { ptr, i32 } %245, i32 %244, 1
  resume { ptr, i32 } %246
}

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

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

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, i32 noundef) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@K = external dso_local global i64, align 8
@S = external dso_local global i64, align 8
@P = external dso_local global [1000005 x i64], align 16
@Ap = external dso_local global i64, align 8
@Bp = external dso_local global i64, align 8
@Cp = external dso_local global i64, align 8
@Dp = external dso_local global i64, align 8
@Q = external dso_local global [1000005 x i64], align 16
@Aq = external dso_local global i64, align 8
@Bq = external dso_local global i64, align 8
@Cq = external dso_local global i64, align 8
@Dq = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5worksx(i64 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 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::basic_ofstream", align 8
  %2 = alloca i64, align 8
  %3 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %4 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %6
  %8 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %7, ptr noundef null)
  %9 = load ptr, ptr @stdin, align 8, !tbaa !8
  %10 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %1) #6
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %1, ptr noundef nonnull @.str.2, i32 noundef 16)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %11 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %.preheader59 unwind label %13

.preheader59:                                     ; preds = %0
  %12 = load i64, ptr %2, align 8, !tbaa !11
  %.not75 = icmp slt i64 %12, 1
  br i1 %.not75, label %._crit_edge78, label %.lr.ph77

._crit_edge78:                                    ; preds = %141, %.preheader59
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %1) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %1) #6
  ret i32 0

13:                                               ; preds = %0
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.lr.ph77:                                         ; preds = %.preheader59, %141
  %.04276 = phi i64 [ %142, %141 ], [ 1, %.preheader59 ]
  %15 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.3)
          to label %16 unwind label %31

16:                                               ; preds = %.lr.ph77
  %17 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %15, i64 noundef %.04276)
          to label %18 unwind label %31

18:                                               ; preds = %16
  %19 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %20 unwind label %31

20:                                               ; preds = %18
  %21 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
          to label %22 unwind label %31

22:                                               ; preds = %20
  %23 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(8) @M)
          to label %24 unwind label %31

24:                                               ; preds = %22
  %25 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 8 dereferenceable(8) @K)
          to label %26 unwind label %31

26:                                               ; preds = %24
  %27 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(8) @S)
          to label %.preheader58 unwind label %31

.preheader58:                                     ; preds = %26
  %28 = load i64, ptr @K, align 8, !tbaa !11
  %29 = icmp sgt i64 %28, 0
  br i1 %29, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %35, %.preheader58
  %30 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @Ap)
          to label %41 unwind label %31

31:                                               ; preds = %110, %108, %105, %._crit_edge72, %62, %60, %58, %._crit_edge66, %45, %43, %41, %._crit_edge, %26, %24, %22, %20, %18, %16, %.lr.ph77
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.lr.ph:                                           ; preds = %.preheader58, %35
  %.04163 = phi i64 [ %36, %35 ], [ 0, %.preheader58 ]
  %33 = getelementptr inbounds [1000005 x i64], ptr @P, i64 0, i64 %.04163
  %34 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %33)
          to label %35 unwind label %39

35:                                               ; preds = %.lr.ph
  %36 = add nuw nsw i64 %.04163, 1
  %37 = load i64, ptr @K, align 8, !tbaa !11
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %.lr.ph, label %._crit_edge, !llvm.loop !13

39:                                               ; preds = %.lr.ph
  %40 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

41:                                               ; preds = %._crit_edge
  %42 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 8 dereferenceable(8) @Bp)
          to label %43 unwind label %31

43:                                               ; preds = %41
  %44 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef nonnull align 8 dereferenceable(8) @Cp)
          to label %45 unwind label %31

45:                                               ; preds = %43
  %46 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 8 dereferenceable(8) @Dp)
          to label %.preheader57 unwind label %31

.preheader57:                                     ; preds = %45
  %47 = load i64, ptr @K, align 8, !tbaa !11
  %48 = icmp sgt i64 %47, 0
  br i1 %48, label %.lr.ph65, label %._crit_edge66

._crit_edge66:                                    ; preds = %52, %.preheader57
  %49 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @Aq)
          to label %58 unwind label %31

.lr.ph65:                                         ; preds = %.preheader57, %52
  %.04064 = phi i64 [ %53, %52 ], [ 0, %.preheader57 ]
  %50 = getelementptr inbounds [1000005 x i64], ptr @Q, i64 0, i64 %.04064
  %51 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %50)
          to label %52 unwind label %56

52:                                               ; preds = %.lr.ph65
  %53 = add nuw nsw i64 %.04064, 1
  %54 = load i64, ptr @K, align 8, !tbaa !11
  %55 = icmp slt i64 %53, %54
  br i1 %55, label %.lr.ph65, label %._crit_edge66, !llvm.loop !15

56:                                               ; preds = %.lr.ph65
  %57 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

58:                                               ; preds = %._crit_edge66
  %59 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %49, ptr noundef nonnull align 8 dereferenceable(8) @Bq)
          to label %60 unwind label %31

60:                                               ; preds = %58
  %61 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %59, ptr noundef nonnull align 8 dereferenceable(8) @Cq)
          to label %62 unwind label %31

62:                                               ; preds = %60
  %63 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %61, ptr noundef nonnull align 8 dereferenceable(8) @Dq)
          to label %64 unwind label %31

64:                                               ; preds = %62
  %65 = load i64, ptr @K, align 8, !tbaa !11
  %66 = load i64, ptr @N, align 8, !tbaa !11
  %67 = icmp slt i64 %65, %66
  br i1 %67, label %.lr.ph69, label %.preheader56

.lr.ph69:                                         ; preds = %64
  %68 = load i64, ptr @Ap, align 8, !tbaa !11
  %69 = load i64, ptr @Bp, align 8, !tbaa !11
  %70 = load i64, ptr @Cp, align 8, !tbaa !11
  %71 = load i64, ptr @Dp, align 8, !tbaa !11
  %72 = shl i64 %65, 3
  %scevgep = getelementptr i8, ptr getelementptr (i8, ptr @P, i64 -8), i64 %72
  %load_initial = load i64, ptr %scevgep, align 8
  br label %80

.preheader56:                                     ; preds = %80, %64
  %73 = load i64, ptr @M, align 8, !tbaa !11
  %74 = icmp slt i64 %65, %73
  br i1 %74, label %.lr.ph71, label %._crit_edge72

.lr.ph71:                                         ; preds = %.preheader56
  %75 = load i64, ptr @Aq, align 8, !tbaa !11
  %76 = load i64, ptr @Bq, align 8, !tbaa !11
  %77 = load i64, ptr @Cq, align 8, !tbaa !11
  %78 = load i64, ptr @Dq, align 8, !tbaa !11
  %79 = shl i64 %65, 3
  %scevgep89 = getelementptr i8, ptr getelementptr (i8, ptr @Q, i64 -8), i64 %79
  %load_initial90 = load i64, ptr %scevgep89, align 8
  br label %93

80:                                               ; preds = %.lr.ph69, %80
  %store_forwarded = phi i64 [ %load_initial, %.lr.ph69 ], [ %89, %80 ]
  %.03967 = phi i64 [ %65, %.lr.ph69 ], [ %91, %80 ]
  %81 = add nsw i64 %.03967, -2
  %82 = getelementptr inbounds [1000005 x i64], ptr @P, i64 0, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !11
  %84 = mul nsw i64 %83, %68
  %85 = mul nsw i64 %store_forwarded, %69
  %86 = add nsw i64 %85, %84
  %87 = add nsw i64 %86, %70
  %88 = srem i64 %87, %71
  %89 = add nsw i64 %88, 1
  %90 = getelementptr inbounds [1000005 x i64], ptr @P, i64 0, i64 %.03967
  store i64 %89, ptr %90, align 8, !tbaa !11
  %91 = add nsw i64 %.03967, 1
  %exitcond.not = icmp eq i64 %91, %66
  br i1 %exitcond.not, label %.preheader56, label %80, !llvm.loop !16

._crit_edge72:                                    ; preds = %93, %.preheader56
  %92 = getelementptr inbounds i64, ptr @P, i64 %66
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @P, ptr noundef nonnull %92)
          to label %105 unwind label %31

93:                                               ; preds = %.lr.ph71, %93
  %store_forwarded91 = phi i64 [ %load_initial90, %.lr.ph71 ], [ %102, %93 ]
  %.03870 = phi i64 [ %65, %.lr.ph71 ], [ %104, %93 ]
  %94 = add nsw i64 %.03870, -2
  %95 = getelementptr inbounds [1000005 x i64], ptr @Q, i64 0, i64 %94
  %96 = load i64, ptr %95, align 8, !tbaa !11
  %97 = mul nsw i64 %96, %75
  %98 = mul nsw i64 %store_forwarded91, %76
  %99 = add nsw i64 %98, %97
  %100 = add nsw i64 %99, %77
  %101 = srem i64 %100, %78
  %102 = add nsw i64 %101, 1
  %103 = getelementptr inbounds [1000005 x i64], ptr @Q, i64 0, i64 %.03870
  store i64 %102, ptr %103, align 8, !tbaa !11
  %104 = add nsw i64 %.03870, 1
  %exitcond82.not = icmp eq i64 %104, %73
  br i1 %exitcond82.not, label %._crit_edge72, label %93, !llvm.loop !17

105:                                              ; preds = %._crit_edge72
  %106 = load i64, ptr @M, align 8, !tbaa !11
  %107 = getelementptr inbounds i64, ptr @Q, i64 %106
  invoke void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull @Q, ptr noundef nonnull %107)
          to label %108 unwind label %31

108:                                              ; preds = %105
  %109 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.4)
          to label %110 unwind label %31

110:                                              ; preds = %108
  %111 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %109, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %.preheader53 unwind label %31

.preheader53:                                     ; preds = %110, %115
  %.03474 = phi i64 [ %.135, %115 ], [ 2147483647, %110 ]
  %.03673 = phi i64 [ %.137, %115 ], [ 0, %110 ]
  %112 = add nsw i64 %.03474, %.03673
  %113 = sdiv i64 %112, 2
  %114 = invoke noundef zeroext i1 @_Z5worksx(i64 noundef %113)
          to label %115 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit

115:                                              ; preds = %.preheader53
  %116 = add nsw i64 %113, -1
  %117 = add nsw i64 %113, 1
  %.137 = select i1 %114, i64 %.03673, i64 %117
  %.135 = select i1 %114, i64 %116, i64 %.03474
  %118 = icmp slt i64 %.137, %.135
  br i1 %118, label %.preheader53, label %.preheader49, !llvm.loop !18

.loopexit:                                        ; preds = %.preheader
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit:                      ; preds = %.preheader49
  %lpad.loopexit50 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp.loopexit:    ; preds = %.preheader53
  %lpad.loopexit54 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp: ; preds = %127, %129, %131, %133, %135, %137, %139
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.preheader49:                                     ; preds = %115, %121
  %.1 = phi i64 [ %122, %121 ], [ %113, %115 ]
  %119 = invoke noundef zeroext i1 @_Z5worksx(i64 noundef %.1)
          to label %120 unwind label %.loopexit.split-lp.loopexit

120:                                              ; preds = %.preheader49
  br i1 %119, label %121, label %.preheader

121:                                              ; preds = %120
  %122 = add nsw i64 %.1, -1
  br label %.preheader49, !llvm.loop !19

.preheader:                                       ; preds = %120, %125
  %.2 = phi i64 [ %126, %125 ], [ %.1, %120 ]
  %123 = invoke noundef zeroext i1 @_Z5worksx(i64 noundef %.2)
          to label %124 unwind label %.loopexit

124:                                              ; preds = %.preheader
  br i1 %123, label %127, label %125

125:                                              ; preds = %124
  %126 = add nsw i64 %.2, 1
  br label %.preheader, !llvm.loop !20

127:                                              ; preds = %124
  %128 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.5)
          to label %129 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

129:                                              ; preds = %127
  %130 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %128, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %131 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

131:                                              ; preds = %129
  %132 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull @.str.6)
          to label %133 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

133:                                              ; preds = %131
  %134 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %132, i64 noundef %.04276)
          to label %135 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

135:                                              ; preds = %133
  %136 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %134, ptr noundef nonnull @.str.7)
          to label %137 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

137:                                              ; preds = %135
  %138 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %136, i64 noundef %.2)
          to label %139 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

139:                                              ; preds = %137
  %140 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %138, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %141 unwind label %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp

141:                                              ; preds = %139
  %142 = add nuw nsw i64 %.04276, 1
  %143 = load i64, ptr %2, align 8, !tbaa !11
  %.not.not = icmp slt i64 %.04276, %143
  br i1 %.not.not, label %.lr.ph77, label %._crit_edge78, !llvm.loop !21

.loopexit.split-lp:                               ; preds = %.loopexit, %.loopexit.split-lp.loopexit.split-lp.loopexit, %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp, %.loopexit.split-lp.loopexit, %31, %39, %56, %13
  %.pn.pn = phi { ptr, i32 } [ %14, %13 ], [ %40, %39 ], [ %57, %56 ], [ %32, %31 ], [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit50, %.loopexit.split-lp.loopexit ], [ %lpad.loopexit54, %.loopexit.split-lp.loopexit.split-lp.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp.loopexit.split-lp.loopexit.split-lp ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %1) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn.pn
}

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

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

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, i32 noundef) unnamed_addr #0 align 2

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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

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


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