; LLVM IR from tangjz/acm-icpc :: codeforces/1556C.ll (Z5solvev)

; 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"

%"struct.std::pair" = type { i32, i32 }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.1" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { ptr }
%"struct.std::_Head_base.1" = type { ptr }

@_ZZ5solvevE1a = external hidden global [100001 x i32], align 16
@_ZZ5solvevE3stk = external hidden global [100001 x %"struct.std::pair"], align 16
@_ZZ5solvevE2dp = external hidden global [100001 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %"class.std::tuple", align 8
  %14 = alloca %"struct.std::pair", align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.std::pair", align 4
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %31, %0
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %34

26:                                               ; preds = %21
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr @_ZZ5solvevE1a, i64 %28
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %29)
  br label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %3, align 4, !tbaa !5
  br label %21, !llvm.loop !9

34:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !11
  store i64 0, ptr @_ZZ5solvevE2dp, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 2, ptr %6, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %182, %34
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = icmp sle i32 %36, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = sub nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sub nsw i32 %44, %49
  store i32 %50, ptr %8, align 4, !tbaa !5
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %53, label %131

53:                                               ; preds = %40
  %54 = load i64, ptr %4, align 8, !tbaa !11
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp sge i64 %54, %56
  %58 = zext i1 %57 to i64
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %60
  store i64 %58, ptr %61, align 8, !tbaa !11
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 2
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  store i64 %68, ptr %9, align 8, !tbaa !11
  %69 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %70 = load i64, ptr %69, align 8, !tbaa !11
  %71 = add nsw i64 %66, %70
  %72 = load i64, ptr %5, align 8, !tbaa !11
  %73 = add nsw i64 %72, %71
  store i64 %73, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %74

74:                                               ; preds = %129, %53
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = icmp sgt i32 %75, 0
  br i1 %76, label %77, label %130

77:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = add nsw i32 %78, -1
  store i32 %79, ptr %2, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @_ZZ5solvevE3stk, i64 0, i64 %80
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  call void @_ZSt3tieIJiiEESt5tupleIJDpRT_EES3_(ptr dead_on_unwind writable sret(%"class.std::tuple") align 8 %13, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12) #5
  %82 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5tupleIJRiS0_EEaSIiiEENSt9enable_ifIXcl12__assignableIRKT_RKT0_EEERS1_E4typeERKSt4pairIS4_S7_E(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(8) %81) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  %83 = load i32, ptr %12, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = load i64, ptr %10, align 8, !tbaa !11
  %86 = add nsw i64 %85, %84
  store i64 %86, ptr %10, align 8, !tbaa !11
  %87 = load i64, ptr %10, align 8, !tbaa !11
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = icmp sle i64 %87, %89
  br i1 %90, label %91, label %115

91:                                               ; preds = %77
  %92 = load i32, ptr %11, align 4, !tbaa !5
  %93 = sub nsw i32 %92, 2
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %94
  %96 = load i64, ptr %95, align 8, !tbaa !11
  %97 = load i64, ptr %5, align 8, !tbaa !11
  %98 = add nsw i64 %97, %96
  store i64 %98, ptr %5, align 8, !tbaa !11
  %99 = load i64, ptr %10, align 8, !tbaa !11
  %100 = load i32, ptr %8, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = icmp eq i64 %99, %101
  br i1 %102, label %103, label %114

103:                                              ; preds = %91
  %104 = load i32, ptr %11, align 4, !tbaa !5
  %105 = sub nsw i32 %104, 2
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !11
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !11
  %113 = add nsw i64 %112, %108
  store i64 %113, ptr %111, align 8, !tbaa !11
  br label %114

114:                                              ; preds = %103, %91
  br label %126

115:                                              ; preds = %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %116 = load i64, ptr %10, align 8, !tbaa !11
  %117 = load i32, ptr %8, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = sub nsw i64 %116, %118
  %120 = trunc i64 %119 to i32
  store i32 %120, ptr %15, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IRiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %14, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %121 = load i32, ptr %2, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %2, align 4, !tbaa !5
  %123 = sext i32 %121 to i64
  %124 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @_ZZ5solvevE3stk, i64 0, i64 %123
  %125 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %124, ptr noundef nonnull align 4 dereferenceable(8) %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  store i32 9, ptr %7, align 4
  br label %127

126:                                              ; preds = %114
  store i32 0, ptr %7, align 4
  br label %127

127:                                              ; preds = %126, %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %128 = load i32, ptr %7, align 4
  switch i32 %128, label %187 [
    i32 0, label %129
    i32 9, label %130
  ]

129:                                              ; preds = %127
  br label %74, !llvm.loop !13

130:                                              ; preds = %127, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %163

131:                                              ; preds = %40
  %132 = load i32, ptr %8, align 4, !tbaa !5
  %133 = icmp slt i32 %132, 0
  br i1 %133, label %134, label %145

134:                                              ; preds = %131
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %136
  store i64 1, ptr %137, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %138 = load i32, ptr %8, align 4, !tbaa !5
  %139 = sub nsw i32 0, %138
  store i32 %139, ptr %17, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IRiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %140 = load i32, ptr %2, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %2, align 4, !tbaa !5
  %142 = sext i32 %140 to i64
  %143 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @_ZZ5solvevE3stk, i64 0, i64 %142
  %144 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %143, ptr noundef nonnull align 4 dereferenceable(8) %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %162

145:                                              ; preds = %131
  %146 = load i32, ptr %6, align 4, !tbaa !5
  %147 = sub nsw i32 %146, 2
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %148
  %150 = load i64, ptr %149, align 8, !tbaa !11
  %151 = add nsw i64 1, %150
  %152 = load i32, ptr %6, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %153
  store i64 %151, ptr %154, align 8, !tbaa !11
  %155 = load i32, ptr %6, align 4, !tbaa !5
  %156 = sub nsw i32 %155, 2
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %157
  %159 = load i64, ptr %158, align 8, !tbaa !11
  %160 = load i64, ptr %5, align 8, !tbaa !11
  %161 = add nsw i64 %160, %159
  store i64 %161, ptr %5, align 8, !tbaa !11
  br label %162

162:                                              ; preds = %145, %134
  br label %163

163:                                              ; preds = %162, %130
  %164 = load i32, ptr %6, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %165
  %167 = load i32, ptr %6, align 4, !tbaa !5
  %168 = sub nsw i32 %167, 1
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %169
  %171 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %166, ptr noundef nonnull align 4 dereferenceable(4) %170)
  %172 = load i32, ptr %171, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = load i64, ptr %5, align 8, !tbaa !11
  %175 = add nsw i64 %174, %173
  store i64 %175, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %176 = load i64, ptr %4, align 8, !tbaa !11
  %177 = load i32, ptr %8, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = sub nsw i64 %176, %178
  store i64 %179, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  store i64 0, ptr %19, align 8, !tbaa !11
  %180 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %181 = load i64, ptr %180, align 8, !tbaa !11
  store i64 %181, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %182

182:                                              ; preds = %163
  %183 = load i32, ptr %6, align 4, !tbaa !5
  %184 = add nsw i32 %183, 2
  store i32 %184, ptr %6, align 4, !tbaa !5
  br label %35, !llvm.loop !14

185:                                              ; preds = %39
  %186 = load i64, ptr %5, align 8, !tbaa !11
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret i64 %186

187:                                              ; preds = %127
  unreachable
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt3tieIJiiEESt5tupleIJDpRT_EES3_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 8, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

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

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

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

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

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


; 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"

%"struct.std::pair" = type { i32, i32 }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.1" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { ptr }
%"struct.std::_Head_base.1" = type { ptr }

@_ZZ5solvevE1a = external hidden global [100001 x i32], align 16
@_ZZ5solvevE3stk = external hidden global [100001 x %"struct.std::pair"], align 16
@_ZZ5solvevE2dp = external hidden local_unnamed_addr global [100001 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::tuple", align 8
  %8 = alloca %"struct.std::pair", align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::pair", align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %.not50 = icmp slt i32 %15, 1
  br i1 %.not50, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr @_ZZ5solvevE2dp, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  br label %._crit_edge64

._crit_edge:                                      ; preds = %.lr.ph
  %16 = icmp slt i32 %19, 2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !9
  store i64 0, ptr @_ZZ5solvevE2dp, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 2, ptr %3, align 4, !tbaa !5
  br i1 %16, label %._crit_edge64, label %.lr.ph63

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %17 = getelementptr inbounds i32, ptr @_ZZ5solvevE1a, i64 %indvars.iv
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %.not.not = icmp slt i64 %indvars.iv, %20
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge64:                                    ; preds = %.loopexit, %._crit_edge.thread, %._crit_edge
  %.028.lcssa = phi i64 [ 0, %._crit_edge ], [ 0, %._crit_edge.thread ], [ %98, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i64 %.028.lcssa

.lr.ph63:                                         ; preds = %._crit_edge, %.loopexit
  %21 = phi i64 [ %103, %.loopexit ], [ 0, %._crit_edge ]
  %.02661 = phi i32 [ %.4, %.loopexit ], [ 0, %._crit_edge ]
  %.02860 = phi i64 [ %98, %.loopexit ], [ 0, %._crit_edge ]
  %storemerge59 = phi i32 [ %105, %.loopexit ], [ 2, %._crit_edge ]
  %22 = sext i32 %storemerge59 to i64
  %23 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = add nsw i32 %storemerge59, -1
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sub nsw i32 %24, %28
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %31, label %71

31:                                               ; preds = %.lr.ph63
  %32 = zext nneg i32 %29 to i64
  %33 = icmp sge i64 %21, %32
  %34 = zext i1 %33 to i64
  %35 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %22
  store i64 %34, ptr %35, align 8, !tbaa !9
  %36 = add nsw i32 %storemerge59, -2
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store i64 %32, ptr %4, align 8, !tbaa !9
  %40 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %41 = load i64, ptr %40, align 8, !tbaa !9
  %42 = add i64 %39, %.02860
  %43 = add i64 %42, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %44 = icmp sgt i32 %.02661, 0
  br i1 %44, label %.lr.ph56.preheader, label %.loopexit

.lr.ph56.preheader:                               ; preds = %31
  %45 = zext nneg i32 %.02661 to i64
  br label %.lr.ph56

.lr.ph56:                                         ; preds = %.lr.ph56.preheader, %69
  %indvars.iv76 = phi i64 [ %45, %.lr.ph56.preheader ], [ %indvars.iv.next77, %69 ]
  %.054 = phi i64 [ 0, %.lr.ph56.preheader ], [ %50, %69 ]
  %.12952 = phi i64 [ %43, %.lr.ph56.preheader ], [ %57, %69 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %indvars.iv.next77 = add nsw i64 %indvars.iv76, -1
  %46 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @_ZZ5solvevE3stk, i64 0, i64 %indvars.iv.next77
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  call void @_ZSt3tieIJiiEESt5tupleIJDpRT_EES3_(ptr dead_on_unwind nonnull writable sret(%"class.std::tuple") align 8 %7, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6) #4
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5tupleIJRiS0_EEaSIiiEENSt9enable_ifIXcl12__assignableIRKT_RKT0_EEERS1_E4typeERKSt4pairIS4_S7_E(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 4 dereferenceable(8) %46) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = add nsw i64 %.054, %49
  %.not42 = icmp sgt i64 %50, %32
  br i1 %.not42, label %.thread, label %51

51:                                               ; preds = %.lr.ph56
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = add nsw i32 %52, -2
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = add nsw i64 %56, %.12952
  %58 = icmp eq i64 %50, %32
  br i1 %58, label %59, label %69

59:                                               ; preds = %51
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = add nsw i64 %63, %56
  store i64 %64, ptr %62, align 8, !tbaa !9
  br label %69

.thread:                                          ; preds = %.lr.ph56
  %65 = trunc nuw nsw i64 %indvars.iv76 to i32
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  %66 = trunc i64 %50 to i32
  %67 = sub i32 %66, %29
  store i32 %67, ptr %9, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IRiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %68 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %46, ptr noundef nonnull align 4 dereferenceable(8) %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %.loopexit

69:                                               ; preds = %59, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  %70 = icmp ugt i64 %indvars.iv76, 1
  br i1 %70, label %.lr.ph56, label %.loopexit.loopexit

71:                                               ; preds = %.lr.ph63
  %72 = icmp slt i32 %29, 0
  br i1 %72, label %73, label %80

73:                                               ; preds = %71
  %74 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %22
  store i64 1, ptr %74, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #4
  %75 = sub nsw i32 0, %29
  store i32 %75, ptr %11, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IRiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %76 = add nsw i32 %.02661, 1
  %77 = sext i32 %.02661 to i64
  %78 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @_ZZ5solvevE3stk, i64 0, i64 %77
  %79 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %78, ptr noundef nonnull align 4 dereferenceable(8) %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  br label %.loopexit

80:                                               ; preds = %71
  %81 = add nsw i32 %storemerge59, -2
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %82
  %84 = load i64, ptr %83, align 8, !tbaa !9
  %85 = add nsw i64 %84, 1
  %86 = getelementptr inbounds [100001 x i64], ptr @_ZZ5solvevE2dp, i64 0, i64 %22
  store i64 %85, ptr %86, align 8, !tbaa !9
  %87 = add nsw i64 %84, %.02860
  br label %.loopexit

.loopexit.loopexit:                               ; preds = %69
  %88 = trunc nuw nsw i64 %indvars.iv.next77 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %31, %.thread, %73, %80
  %.432 = phi i64 [ %.02860, %73 ], [ %87, %80 ], [ %.12952, %.thread ], [ %43, %31 ], [ %57, %.loopexit.loopexit ]
  %.4 = phi i32 [ %76, %73 ], [ %.02661, %80 ], [ %65, %.thread ], [ %.02661, %31 ], [ %88, %.loopexit.loopexit ]
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %90
  %92 = add nsw i32 %89, -1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solvevE1a, i64 0, i64 %93
  %95 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %91, ptr noundef nonnull align 4 dereferenceable(4) %94)
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = add nsw i64 %.432, %97
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #4
  %99 = load i64, ptr %2, align 8, !tbaa !9
  %100 = sext i32 %29 to i64
  %101 = sub nsw i64 %99, %100
  store i64 %101, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #4
  store i64 0, ptr %13, align 8, !tbaa !9
  %102 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %13)
  %103 = load i64, ptr %102, align 8, !tbaa !9
  store i64 %103, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #4
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = add nsw i32 %104, 2
  store i32 %105, ptr %3, align 4, !tbaa !5
  %106 = load i32, ptr %1, align 4, !tbaa !5
  %.not41 = icmp sgt i32 %105, %106
  br i1 %.not41, label %._crit_edge64, label %.lr.ph63, !llvm.loop !13
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZSt3tieIJiiEESt5tupleIJDpRT_EES3_(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 8, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

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

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

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

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

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

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


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