; LLVM IR from DionysiosB/CodeForces :: 0500-0599 (524C-TheArtOfDealingWithATM)

; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long, long, std::_Identity<long>, std::less<long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long, long, std::_Identity<long>, std::less<long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

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

23:                                               ; preds = %37, %0
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %44

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %29 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6)
          to label %30 unwind label %40

30:                                               ; preds = %28
  %31 = invoke { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %32 unwind label %40

32:                                               ; preds = %30
  %33 = getelementptr inbounds { ptr, i8 }, ptr %9, i32 0, i32 0
  %34 = extractvalue { ptr, i8 } %31, 0
  store ptr %34, ptr %33, align 8
  %35 = getelementptr inbounds { ptr, i8 }, ptr %9, i32 0, i32 1
  %36 = extractvalue { ptr, i8 } %31, 1
  store i8 %36, ptr %35, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %37

37:                                               ; preds = %32
  %38 = load i64, ptr %5, align 8, !tbaa !5
  %39 = add nsw i64 %38, 1
  store i64 %39, ptr %5, align 8, !tbaa !5
  br label %23, !llvm.loop !9

40:                                               ; preds = %30, %28
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %7, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %186

44:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %45 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %10)
          to label %46 unwind label %63

46:                                               ; preds = %44
  br label %47

47:                                               ; preds = %176, %46
  %48 = load i64, ptr %10, align 8, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr %10, align 8, !tbaa !5
  %50 = icmp ne i64 %48, 0
  br i1 %50, label %51, label %183

51:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %52 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %11)
          to label %53 unwind label %67

53:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %54 = load i64, ptr %3, align 8, !tbaa !5
  %55 = add nsw i64 %54, 1
  store i64 %55, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %56 = call ptr @_ZNKSt3setIlSt4lessIlESaIlEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  %57 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %13, i32 0, i32 0
  store ptr %56, ptr %57, align 8
  br label %58

58:                                               ; preds = %163, %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %59 = call ptr @_ZNKSt3setIlSt4lessIlESaIlEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  %60 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %14, i32 0, i32 0
  store ptr %59, ptr %60, align 8
  %61 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIlES2_(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br i1 %61, label %71, label %62

62:                                               ; preds = %58
  store i32 7, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %166

63:                                               ; preds = %44
  %64 = landingpad { ptr, i32 }
          cleanup
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %7, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %8, align 4
  br label %185

67:                                               ; preds = %51
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %7, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %8, align 4
  br label %182

71:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %72 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIlEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  %73 = load i64, ptr %72, align 8, !tbaa !5
  store i64 %73, ptr %16, align 8, !tbaa !5
  %74 = load i64, ptr %11, align 8, !tbaa !5
  %75 = load i64, ptr %16, align 8, !tbaa !5
  %76 = srem i64 %74, %75
  %77 = icmp eq i64 %76, 0
  br i1 %77, label %78, label %98

78:                                               ; preds = %71
  %79 = load i64, ptr %11, align 8, !tbaa !5
  %80 = load i64, ptr %16, align 8, !tbaa !5
  %81 = sdiv i64 %79, %80
  %82 = load i64, ptr %3, align 8, !tbaa !5
  %83 = icmp sle i64 %81, %82
  br i1 %83, label %84, label %98

84:                                               ; preds = %78
  %85 = load i64, ptr %12, align 8, !tbaa !5
  %86 = load i64, ptr %11, align 8, !tbaa !5
  %87 = load i64, ptr %16, align 8, !tbaa !5
  %88 = sdiv i64 %86, %87
  %89 = icmp slt i64 %85, %88
  br i1 %89, label %90, label %92

90:                                               ; preds = %84
  %91 = load i64, ptr %12, align 8, !tbaa !5
  br label %96

92:                                               ; preds = %84
  %93 = load i64, ptr %11, align 8, !tbaa !5
  %94 = load i64, ptr %16, align 8, !tbaa !5
  %95 = sdiv i64 %93, %94
  br label %96

96:                                               ; preds = %92, %90
  %97 = phi i64 [ %91, %90 ], [ %95, %92 ]
  store i64 %97, ptr %12, align 8, !tbaa !5
  br label %98

98:                                               ; preds = %96, %78, %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store i64 1, ptr %17, align 8, !tbaa !5
  br label %99

99:                                               ; preds = %158, %98
  %100 = load i64, ptr %17, align 8, !tbaa !5
  %101 = load i64, ptr %3, align 8, !tbaa !5
  %102 = icmp sle i64 %100, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  store i32 10, ptr %15, align 4
  br label %161

104:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %105 = load i64, ptr %11, align 8, !tbaa !5
  %106 = load i64, ptr %17, align 8, !tbaa !5
  %107 = load i64, ptr %16, align 8, !tbaa !5
  %108 = mul nsw i64 %106, %107
  %109 = sub nsw i64 %105, %108
  store i64 %109, ptr %18, align 8, !tbaa !5
  %110 = load i64, ptr %18, align 8, !tbaa !5
  %111 = icmp sle i64 %110, 0
  br i1 %111, label %112, label %113

112:                                              ; preds = %104
  store i32 10, ptr %15, align 4
  br label %155

113:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  store i64 1, ptr %19, align 8, !tbaa !5
  br label %114

114:                                              ; preds = %151, %113
  %115 = load i64, ptr %19, align 8, !tbaa !5
  %116 = load i64, ptr %17, align 8, !tbaa !5
  %117 = add nsw i64 %115, %116
  %118 = load i64, ptr %3, align 8, !tbaa !5
  %119 = icmp sle i64 %117, %118
  br i1 %119, label %120, label %126

120:                                              ; preds = %114
  %121 = load i64, ptr %19, align 8, !tbaa !5
  %122 = load i64, ptr %17, align 8, !tbaa !5
  %123 = add nsw i64 %121, %122
  %124 = load i64, ptr %12, align 8, !tbaa !5
  %125 = icmp slt i64 %123, %124
  br label %126

126:                                              ; preds = %120, %114
  %127 = phi i1 [ false, %114 ], [ %125, %120 ]
  br i1 %127, label %129, label %128

128:                                              ; preds = %126
  store i32 13, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %154

129:                                              ; preds = %126
  %130 = load i64, ptr %18, align 8, !tbaa !5
  %131 = load i64, ptr %19, align 8, !tbaa !5
  %132 = srem i64 %130, %131
  %133 = icmp ne i64 %132, 0
  br i1 %133, label %134, label %135

134:                                              ; preds = %129
  br label %151

135:                                              ; preds = %129
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %136 = load i64, ptr %18, align 8, !tbaa !5
  %137 = load i64, ptr %19, align 8, !tbaa !5
  %138 = sdiv i64 %136, %137
  store i64 %138, ptr %20, align 8, !tbaa !5
  %139 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull align 8 dereferenceable(8) %20)
          to label %140 unwind label %146

140:                                              ; preds = %135
  %141 = icmp ne i64 %139, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  br i1 %141, label %142, label %150

142:                                              ; preds = %140
  %143 = load i64, ptr %19, align 8, !tbaa !5
  %144 = load i64, ptr %17, align 8, !tbaa !5
  %145 = add nsw i64 %143, %144
  store i64 %145, ptr %12, align 8, !tbaa !5
  br label %150

146:                                              ; preds = %135
  %147 = landingpad { ptr, i32 }
          cleanup
  %148 = extractvalue { ptr, i32 } %147, 0
  store ptr %148, ptr %7, align 8
  %149 = extractvalue { ptr, i32 } %147, 1
  store i32 %149, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  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 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %181

150:                                              ; preds = %142, %140
  br label %151

151:                                              ; preds = %150, %134
  %152 = load i64, ptr %19, align 8, !tbaa !5
  %153 = add nsw i64 %152, 1
  store i64 %153, ptr %19, align 8, !tbaa !5
  br label %114, !llvm.loop !11

154:                                              ; preds = %128
  store i32 0, ptr %15, align 4
  br label %155

155:                                              ; preds = %154, %112
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %156 = load i32, ptr %15, align 4
  switch i32 %156, label %161 [
    i32 0, label %157
  ]

157:                                              ; preds = %155
  br label %158

158:                                              ; preds = %157
  %159 = load i64, ptr %17, align 8, !tbaa !5
  %160 = add nsw i64 %159, 1
  store i64 %160, ptr %17, align 8, !tbaa !5
  br label %99, !llvm.loop !12

161:                                              ; preds = %155, %103
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br label %162

162:                                              ; preds = %161
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %163

163:                                              ; preds = %162
  %164 = call ptr @_ZNSt23_Rb_tree_const_iteratorIlEppEi(ptr noundef nonnull align 8 dereferenceable(8) %13, i32 noundef 0) #5
  %165 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %21, i32 0, i32 0
  store ptr %164, ptr %165, align 8
  br label %58, !llvm.loop !13

166:                                              ; preds = %62
  %167 = load i64, ptr %12, align 8, !tbaa !5
  %168 = load i64, ptr %3, align 8, !tbaa !5
  %169 = icmp sle i64 %167, %168
  br i1 %169, label %170, label %172

170:                                              ; preds = %166
  %171 = load i64, ptr %12, align 8, !tbaa !5
  br label %173

172:                                              ; preds = %166
  br label %173

173:                                              ; preds = %172, %170
  %174 = phi i64 [ %171, %170 ], [ -1, %172 ]
  %175 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %174)
          to label %176 unwind label %177

176:                                              ; preds = %173
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %47, !llvm.loop !14

177:                                              ; preds = %173
  %178 = landingpad { ptr, i32 }
          cleanup
  %179 = extractvalue { ptr, i32 } %178, 0
  store ptr %179, ptr %7, align 8
  %180 = extractvalue { ptr, i32 } %178, 1
  store i32 %180, ptr %8, align 4
  br label %181

181:                                              ; preds = %177, %146
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %182

182:                                              ; preds = %181, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %185

183:                                              ; preds = %47
  store i32 0, ptr %1, align 4
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %184 = load i32, ptr %1, align 4
  ret i32 %184

185:                                              ; preds = %182, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %186

186:                                              ; preds = %185, %40
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  br label %187

187:                                              ; preds = %186
  %188 = load ptr, ptr %7, align 8
  %189 = load i32, ptr %8, align 4
  %190 = insertvalue { ptr, i32 } poison, ptr %188, 0
  %191 = insertvalue { ptr, i32 } %190, i32 %189, 1
  resume { ptr, i32 } %191
}

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIlSt4lessIlESaIlEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNKSt3setIlSt4lessIlESaIlEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNKSt3setIlSt4lessIlESaIlEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

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

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

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

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

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

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

%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long, long, std::_Identity<long>, std::less<long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long, long, std::_Identity<long>, std::less<long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca %"class.std::set", align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #6
  call void @_ZNSt3setIlSt4lessIlESaIlEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #6
  %11 = load i64, ptr %1, align 8, !tbaa !5
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %18, %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %5)
  %14 = load i64, ptr %5, align 8, !tbaa !5
  %15 = add nsw i64 %14, -1
  store i64 %15, ptr %5, align 8, !tbaa !5
  %.not69 = icmp eq i64 %14, 0
  br i1 %.not69, label %._crit_edge72, label %.lr.ph71

.lr.ph:                                           ; preds = %0, %18
  %.03150 = phi i64 [ %19, %18 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %4)
  %17 = invoke { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %18 unwind label %22

18:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %19 = add nuw nsw i64 %.03150, 1
  %20 = load i64, ptr %1, align 8, !tbaa !5
  %21 = icmp slt i64 %19, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !9

22:                                               ; preds = %.lr.ph
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %68

.lr.ph71:                                         ; preds = %._crit_edge, %._crit_edge67
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %6)
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %26 = add nsw i64 %25, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %27 = call ptr @_ZNKSt3setIlSt4lessIlESaIlEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %3) #6
  store ptr %27, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %28 = call ptr @_ZNKSt3setIlSt4lessIlESaIlEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %3) #6
  store ptr %28, ptr %8, align 8
  %29 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIlES2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  br i1 %29, label %.lr.ph66, label %._crit_edge67

._crit_edge67:                                    ; preds = %.critedge.thread, %.lr.ph71
  %.035.lcssa = phi i64 [ %26, %.lr.ph71 ], [ %.6, %.critedge.thread ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  %30 = load i64, ptr %2, align 8, !tbaa !5
  %.not40 = icmp sgt i64 %.035.lcssa, %30
  %31 = select i1 %.not40, i64 -1, i64 %.035.lcssa
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %31)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %33 = load i64, ptr %5, align 8, !tbaa !5
  %34 = add nsw i64 %33, -1
  store i64 %34, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i64 %33, 0
  br i1 %.not, label %._crit_edge72, label %.lr.ph71, !llvm.loop !11

.lr.ph66:                                         ; preds = %.lr.ph71, %.critedge.thread
  %.03564 = phi i64 [ %.6, %.critedge.thread ], [ %26, %.lr.ph71 ]
  %35 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIlEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = load i64, ptr %6, align 8, !tbaa !5
  %38 = srem i64 %37, %36
  %39 = sdiv i64 %37, %36
  %40 = icmp ne i64 %38, 0
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  %.not41 = icmp sgt i64 %39, %.pre
  %or.cond74 = select i1 %40, i1 true, i1 %.not41
  %.035. = call i64 @llvm.smin.i64(i64 %.03564, i64 %39)
  %.1 = select i1 %or.cond74, i64 %.03564, i64 %.035.
  %.not4256 = icmp slt i64 %.pre, 1
  br i1 %.not4256, label %.critedge.thread, label %.lr.ph60

.lr.ph60:                                         ; preds = %.lr.ph66, %.critedge
  %41 = phi i64 [ %64, %.critedge ], [ %.pre, %.lr.ph66 ]
  %.03258 = phi i64 [ %46, %.critedge ], [ 1, %.lr.ph66 ]
  %.257 = phi i64 [ %.3.lcssa, %.critedge ], [ %.1, %.lr.ph66 ]
  %42 = load i64, ptr %6, align 8, !tbaa !5
  %43 = mul nsw i64 %.03258, %36
  %44 = sub nsw i64 %42, %43
  %45 = icmp sgt i64 %44, 0
  br i1 %45, label %.preheader, label %.critedge.thread

.preheader:                                       ; preds = %.lr.ph60
  %46 = add nuw nsw i64 %.03258, 1
  %.not4351 = icmp slt i64 %.03258, %41
  %47 = icmp slt i64 %46, %.257
  %or.cond52 = select i1 %.not4351, i1 %47, i1 false
  br i1 %or.cond52, label %.lr.ph55, label %.critedge

.lr.ph55:                                         ; preds = %.preheader, %58
  %48 = phi i64 [ %59, %58 ], [ %41, %.preheader ]
  %49 = phi i64 [ %60, %58 ], [ %41, %.preheader ]
  %50 = phi i64 [ %62, %58 ], [ %46, %.preheader ]
  %.054 = phi i64 [ %61, %58 ], [ 1, %.preheader ]
  %.353 = phi i64 [ %.4, %58 ], [ %.257, %.preheader ]
  %51 = urem i64 %44, %.054
  %52 = udiv i64 %44, %.054
  %.not44 = icmp eq i64 %51, 0
  br i1 %.not44, label %53, label %58

53:                                               ; preds = %.lr.ph55
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #6
  store i64 %52, ptr %9, align 8, !tbaa !5
  %54 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %55 unwind label %56

55:                                               ; preds = %53
  %.not45 = icmp eq i64 %54, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #6
  %spec.select = select i1 %.not45, i64 %.353, i64 %50
  %.pre73 = load i64, ptr %2, align 8, !tbaa !5
  br label %58

56:                                               ; preds = %53
  %57 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %68

58:                                               ; preds = %55, %.lr.ph55
  %59 = phi i64 [ %48, %.lr.ph55 ], [ %.pre73, %55 ]
  %60 = phi i64 [ %49, %.lr.ph55 ], [ %.pre73, %55 ]
  %.4 = phi i64 [ %.353, %.lr.ph55 ], [ %spec.select, %55 ]
  %61 = add nuw nsw i64 %.054, 1
  %62 = add nuw nsw i64 %61, %.03258
  %.not43 = icmp sle i64 %62, %60
  %63 = icmp slt i64 %62, %.4
  %or.cond = select i1 %.not43, i1 %63, i1 false
  br i1 %or.cond, label %.lr.ph55, label %.critedge, !llvm.loop !12

.critedge:                                        ; preds = %58, %.preheader
  %64 = phi i64 [ %41, %.preheader ], [ %59, %58 ]
  %.3.lcssa = phi i64 [ %.257, %.preheader ], [ %.4, %58 ]
  %.not42.not = icmp slt i64 %.03258, %64
  br i1 %.not42.not, label %.lr.ph60, label %.critedge.thread, !llvm.loop !13

.critedge.thread:                                 ; preds = %.critedge, %.lr.ph60, %.lr.ph66
  %.6 = phi i64 [ %.1, %.lr.ph66 ], [ %.257, %.lr.ph60 ], [ %.3.lcssa, %.critedge ]
  %65 = call ptr @_ZNSt23_Rb_tree_const_iteratorIlEppEi(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %66 = call ptr @_ZNKSt3setIlSt4lessIlESaIlEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %3) #6
  store ptr %66, ptr %8, align 8
  %67 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIlES2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  br i1 %67, label %.lr.ph66, label %._crit_edge67, !llvm.loop !14

._crit_edge72:                                    ; preds = %._crit_edge67, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret i32 0

68:                                               ; preds = %56, %22
  %.pn = phi { ptr, i32 } [ %23, %22 ], [ %57, %56 ]
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn
}

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4 align 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: mustprogress nounwind uwtable
declare dso_local ptr @_ZNKSt3setIlSt4lessIlESaIlEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIlES2_(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 ptr @_ZNKSt3setIlSt4lessIlESaIlEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4 align 2

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #5

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


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,DivRemPairsPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass