; LLVM IR from DionysiosB/CodeForces :: 0400-0499 (479D-LongJumps)

; 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 [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 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 i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca %"class.std::set", align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::pair", align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 48, ptr %6) #5
  call void @_ZNSt3setIlSt4lessIlESaIlEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  store i8 0, ptr %7, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  store i8 0, ptr %8, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  store i8 0, ptr %9, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  br label %21

21:                                               ; preds = %146, %0
  %22 = load i64, ptr %2, align 8, !tbaa !9
  %23 = add nsw i64 %22, -1
  store i64 %23, ptr %2, align 8, !tbaa !9
  %24 = icmp ne i64 %22, 0
  br i1 %24, label %25, label %148

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

27:                                               ; preds = %25
  %28 = invoke { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %29 unwind label %47

29:                                               ; preds = %27
  %30 = getelementptr inbounds { ptr, i8 }, ptr %14, i32 0, i32 0
  %31 = extractvalue { ptr, i8 } %28, 0
  store ptr %31, ptr %30, align 8
  %32 = getelementptr inbounds { ptr, i8 }, ptr %14, i32 0, i32 1
  %33 = extractvalue { ptr, i8 } %28, 1
  store i8 %33, ptr %32, align 8
  %34 = load i64, ptr %4, align 8, !tbaa !9
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = icmp sle i64 %34, %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  br i1 %36, label %37, label %44

37:                                               ; preds = %29
  %38 = load i64, ptr %11, align 8, !tbaa !9
  %39 = load i64, ptr %4, align 8, !tbaa !9
  %40 = sub nsw i64 %38, %39
  store i64 %40, ptr %15, align 8, !tbaa !9
  %41 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(8) %15)
          to label %42 unwind label %51

42:                                               ; preds = %37
  %43 = icmp ne i64 %41, 0
  br label %44

44:                                               ; preds = %42, %29
  %45 = phi i1 [ false, %29 ], [ %43, %42 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br i1 %45, label %46, label %55

46:                                               ; preds = %44
  store i8 1, ptr %7, align 1, !tbaa !5
  br label %55

47:                                               ; preds = %27, %25
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %12, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %13, align 4
  br label %147

51:                                               ; preds = %37
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %12, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %147

55:                                               ; preds = %46, %44
  %56 = load i64, ptr %5, align 8, !tbaa !9
  %57 = load i64, ptr %11, align 8, !tbaa !9
  %58 = icmp sle i64 %56, %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  br i1 %58, label %59, label %66

59:                                               ; preds = %55
  %60 = load i64, ptr %11, align 8, !tbaa !9
  %61 = load i64, ptr %5, align 8, !tbaa !9
  %62 = sub nsw i64 %60, %61
  store i64 %62, ptr %16, align 8, !tbaa !9
  %63 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(8) %16)
          to label %64 unwind label %69

64:                                               ; preds = %59
  %65 = icmp ne i64 %63, 0
  br label %66

66:                                               ; preds = %64, %55
  %67 = phi i1 [ false, %55 ], [ %65, %64 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br i1 %67, label %68, label %73

68:                                               ; preds = %66
  store i8 1, ptr %8, align 1, !tbaa !5
  br label %73

69:                                               ; preds = %59
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %12, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %147

73:                                               ; preds = %68, %66
  %74 = load i64, ptr %4, align 8, !tbaa !9
  %75 = load i64, ptr %5, align 8, !tbaa !9
  %76 = add nsw i64 %74, %75
  %77 = load i64, ptr %11, align 8, !tbaa !9
  %78 = icmp sle i64 %76, %77
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  br i1 %78, label %79, label %88

79:                                               ; preds = %73
  %80 = load i64, ptr %11, align 8, !tbaa !9
  %81 = load i64, ptr %4, align 8, !tbaa !9
  %82 = sub nsw i64 %80, %81
  %83 = load i64, ptr %5, align 8, !tbaa !9
  %84 = sub nsw i64 %82, %83
  store i64 %84, ptr %17, align 8, !tbaa !9
  %85 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(8) %17)
          to label %86 unwind label %94

86:                                               ; preds = %79
  %87 = icmp ne i64 %85, 0
  br label %88

88:                                               ; preds = %86, %73
  %89 = phi i1 [ false, %73 ], [ %87, %86 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br i1 %89, label %90, label %98

90:                                               ; preds = %88
  store i8 1, ptr %9, align 1, !tbaa !5
  %91 = load i64, ptr %11, align 8, !tbaa !9
  %92 = load i64, ptr %5, align 8, !tbaa !9
  %93 = sub nsw i64 %91, %92
  store i64 %93, ptr %10, align 8, !tbaa !9
  br label %98

94:                                               ; preds = %79
  %95 = landingpad { ptr, i32 }
          cleanup
  %96 = extractvalue { ptr, i32 } %95, 0
  store ptr %96, ptr %12, align 8
  %97 = extractvalue { ptr, i32 } %95, 1
  store i32 %97, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br label %147

98:                                               ; preds = %90, %88
  %99 = load i64, ptr %5, align 8, !tbaa !9
  %100 = load i64, ptr %11, align 8, !tbaa !9
  %101 = icmp sle i64 %99, %100
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  br i1 %101, label %102, label %111

102:                                              ; preds = %98
  %103 = load i64, ptr %11, align 8, !tbaa !9
  %104 = load i64, ptr %4, align 8, !tbaa !9
  %105 = add nsw i64 %103, %104
  %106 = load i64, ptr %5, align 8, !tbaa !9
  %107 = sub nsw i64 %105, %106
  store i64 %107, ptr %18, align 8, !tbaa !9
  %108 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(8) %18)
          to label %109 unwind label %117

109:                                              ; preds = %102
  %110 = icmp ne i64 %108, 0
  br label %111

111:                                              ; preds = %109, %98
  %112 = phi i1 [ false, %98 ], [ %110, %109 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br i1 %112, label %113, label %121

113:                                              ; preds = %111
  store i8 1, ptr %9, align 1, !tbaa !5
  %114 = load i64, ptr %11, align 8, !tbaa !9
  %115 = load i64, ptr %5, align 8, !tbaa !9
  %116 = sub nsw i64 %114, %115
  store i64 %116, ptr %10, align 8, !tbaa !9
  br label %121

117:                                              ; preds = %102
  %118 = landingpad { ptr, i32 }
          cleanup
  %119 = extractvalue { ptr, i32 } %118, 0
  store ptr %119, ptr %12, align 8
  %120 = extractvalue { ptr, i32 } %118, 1
  store i32 %120, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %147

121:                                              ; preds = %113, %111
  %122 = load i64, ptr %11, align 8, !tbaa !9
  %123 = load i64, ptr %4, align 8, !tbaa !9
  %124 = add nsw i64 %122, %123
  %125 = load i64, ptr %3, align 8, !tbaa !9
  %126 = icmp sle i64 %124, %125
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  br i1 %126, label %127, label %136

127:                                              ; preds = %121
  %128 = load i64, ptr %11, align 8, !tbaa !9
  %129 = load i64, ptr %4, align 8, !tbaa !9
  %130 = add nsw i64 %128, %129
  %131 = load i64, ptr %5, align 8, !tbaa !9
  %132 = sub nsw i64 %130, %131
  store i64 %132, ptr %19, align 8, !tbaa !9
  %133 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(8) %19)
          to label %134 unwind label %142

134:                                              ; preds = %127
  %135 = icmp ne i64 %133, 0
  br label %136

136:                                              ; preds = %134, %121
  %137 = phi i1 [ false, %121 ], [ %135, %134 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br i1 %137, label %138, label %146

138:                                              ; preds = %136
  store i8 1, ptr %9, align 1, !tbaa !5
  %139 = load i64, ptr %11, align 8, !tbaa !9
  %140 = load i64, ptr %4, align 8, !tbaa !9
  %141 = add nsw i64 %139, %140
  store i64 %141, ptr %10, align 8, !tbaa !9
  br label %146

142:                                              ; preds = %127
  %143 = landingpad { ptr, i32 }
          cleanup
  %144 = extractvalue { ptr, i32 } %143, 0
  store ptr %144, ptr %12, align 8
  %145 = extractvalue { ptr, i32 } %143, 1
  store i32 %145, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %147

146:                                              ; preds = %138, %136
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %21, !llvm.loop !11

147:                                              ; preds = %142, %117, %94, %69, %51, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %192

148:                                              ; preds = %21
  %149 = load i8, ptr %7, align 1, !tbaa !5, !range !13, !noundef !14
  %150 = trunc i8 %149 to i1
  br i1 %150, label %151, label %161

151:                                              ; preds = %148
  %152 = load i8, ptr %8, align 1, !tbaa !5, !range !13, !noundef !14
  %153 = trunc i8 %152 to i1
  br i1 %153, label %154, label %161

154:                                              ; preds = %151
  %155 = invoke i32 @puts(ptr noundef @.str.2)
          to label %156 unwind label %157

156:                                              ; preds = %154
  br label %190

157:                                              ; preds = %182, %178, %171, %164, %154
  %158 = landingpad { ptr, i32 }
          cleanup
  %159 = extractvalue { ptr, i32 } %158, 0
  store ptr %159, ptr %12, align 8
  %160 = extractvalue { ptr, i32 } %158, 1
  store i32 %160, ptr %13, align 4
  br label %192

161:                                              ; preds = %151, %148
  %162 = load i8, ptr %7, align 1, !tbaa !5, !range !13, !noundef !14
  %163 = trunc i8 %162 to i1
  br i1 %163, label %164, label %168

164:                                              ; preds = %161
  %165 = load i64, ptr %5, align 8, !tbaa !9
  %166 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %165)
          to label %167 unwind label %157

167:                                              ; preds = %164
  br label %189

168:                                              ; preds = %161
  %169 = load i8, ptr %8, align 1, !tbaa !5, !range !13, !noundef !14
  %170 = trunc i8 %169 to i1
  br i1 %170, label %171, label %175

171:                                              ; preds = %168
  %172 = load i64, ptr %4, align 8, !tbaa !9
  %173 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %172)
          to label %174 unwind label %157

174:                                              ; preds = %171
  br label %188

175:                                              ; preds = %168
  %176 = load i8, ptr %9, align 1, !tbaa !5, !range !13, !noundef !14
  %177 = trunc i8 %176 to i1
  br i1 %177, label %178, label %182

178:                                              ; preds = %175
  %179 = load i64, ptr %10, align 8, !tbaa !9
  %180 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %179)
          to label %181 unwind label %157

181:                                              ; preds = %178
  br label %187

182:                                              ; preds = %175
  %183 = load i64, ptr %4, align 8, !tbaa !9
  %184 = load i64, ptr %5, align 8, !tbaa !9
  %185 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %183, i64 noundef %184)
          to label %186 unwind label %157

186:                                              ; preds = %182
  br label %187

187:                                              ; preds = %186, %181
  br label %188

188:                                              ; preds = %187, %174
  br label %189

189:                                              ; preds = %188, %167
  br label %190

190:                                              ; preds = %189, %156
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %6) #5
  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 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %191 = load i32, ptr %1, align 4
  ret i32 %191

192:                                              ; preds = %157, %147
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %6) #5
  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 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  br label %193

193:                                              ; preds = %192
  %194 = load ptr, ptr %12, align 8
  %195 = load i32, ptr %13, align 4
  %196 = insertvalue { ptr, i32 } poison, ptr %194, 0
  %197 = insertvalue { ptr, i32 } %196, i32 %195, 1
  resume { ptr, i32 } %197
}

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

declare i32 @puts(ptr noundef) #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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i8 0, i8 2}
!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::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 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 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 i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %"class.std::set", align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #5
  call void @_ZNSt3setIlSt4lessIlESaIlEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #5
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = add nsw i64 %13, -1
  store i64 %14, ptr %1, align 8, !tbaa !5
  %.not64 = icmp eq i64 %13, 0
  br i1 %.not64, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %0, %79
  %.068 = phi i1 [ %.1, %79 ], [ false, %0 ]
  %.01867 = phi i64 [ %.3, %79 ], [ undef, %0 ]
  %.02066 = phi i1 [ %.323, %79 ], [ false, %0 ]
  %.02465 = phi i8 [ %.125, %79 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %6)
  %16 = invoke { ptr, i8 } @_ZNSt3setIlSt4lessIlESaIlEE6insertERKl(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %17 unwind label %24

17:                                               ; preds = %.lr.ph
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = load i64, ptr %6, align 8, !tbaa !5
  %.not26 = icmp sgt i64 %18, %19
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  br i1 %.not26, label %.critedge, label %20

20:                                               ; preds = %17
  %21 = sub nsw i64 %19, %18
  store i64 %21, ptr %7, align 8, !tbaa !5
  %22 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %23 unwind label %26

23:                                               ; preds = %20
  %.not27 = icmp ne i64 %22, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  %spec.select = select i1 %.not27, i1 true, i1 %.068
  %.pre = load i64, ptr %6, align 8, !tbaa !5
  br label %28

24:                                               ; preds = %.lr.ph
  %25 = landingpad { ptr, i32 }
          cleanup
  br label %82

26:                                               ; preds = %20
  %27 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %82

.critedge:                                        ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %28

28:                                               ; preds = %23, %.critedge
  %29 = phi i64 [ %19, %.critedge ], [ %.pre, %23 ]
  %.1 = phi i1 [ %.068, %.critedge ], [ %spec.select, %23 ]
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %.not28 = icmp sgt i64 %30, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  br i1 %.not28, label %.critedge2, label %31

31:                                               ; preds = %28
  %32 = sub nsw i64 %29, %30
  store i64 %32, ptr %8, align 8, !tbaa !5
  %33 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %34 unwind label %35

34:                                               ; preds = %31
  %.not29 = icmp eq i64 %33, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  %spec.select37 = select i1 %.not29, i8 %.02465, i8 1
  %.pre79 = load i64, ptr %4, align 8, !tbaa !5
  %.pre80 = load i64, ptr %6, align 8, !tbaa !5
  br label %37

35:                                               ; preds = %31
  %36 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  br label %82

.critedge2:                                       ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  br label %37

37:                                               ; preds = %34, %.critedge2
  %38 = phi i64 [ %29, %.critedge2 ], [ %.pre80, %34 ]
  %39 = phi i64 [ %30, %.critedge2 ], [ %.pre79, %34 ]
  %.125 = phi i8 [ %.02465, %.critedge2 ], [ %spec.select37, %34 ]
  %40 = load i64, ptr %3, align 8, !tbaa !5
  %41 = add nsw i64 %39, %40
  %.not30 = icmp sgt i64 %41, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  br i1 %.not30, label %.critedge4, label %42

42:                                               ; preds = %37
  %43 = sub i64 %38, %41
  store i64 %43, ptr %9, align 8, !tbaa !5
  %44 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %45 unwind label %47

45:                                               ; preds = %42
  %.not31 = icmp ne i64 %44, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  %.pre81 = load i64, ptr %4, align 8, !tbaa !5
  %.pre82 = load i64, ptr %6, align 8, !tbaa !5
  %46 = sub nsw i64 %.pre82, %.pre81
  %spec.select105 = select i1 %.not31, i1 true, i1 %.02066
  %spec.select106 = select i1 %.not31, i64 %46, i64 %.01867
  br label %49

47:                                               ; preds = %42
  %48 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  br label %82

.critedge4:                                       ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  br label %49

49:                                               ; preds = %45, %.critedge4
  %50 = phi i64 [ %38, %.critedge4 ], [ %.pre82, %45 ]
  %51 = phi i64 [ %39, %.critedge4 ], [ %.pre81, %45 ]
  %.121 = phi i1 [ %.02066, %.critedge4 ], [ %spec.select105, %45 ]
  %.119 = phi i64 [ %.01867, %.critedge4 ], [ %spec.select106, %45 ]
  %.not32 = icmp sgt i64 %51, %50
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  br i1 %.not32, label %.critedge6, label %52

52:                                               ; preds = %49
  %53 = load i64, ptr %3, align 8, !tbaa !5
  %54 = sub i64 %50, %51
  %55 = add i64 %54, %53
  store i64 %55, ptr %10, align 8, !tbaa !5
  %56 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(8) %10)
          to label %57 unwind label %61

57:                                               ; preds = %52
  %.not33 = icmp eq i64 %56, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  %.pre83 = load i64, ptr %6, align 8, !tbaa !5
  br i1 %.not33, label %63, label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %4, align 8, !tbaa !5
  %60 = sub nsw i64 %.pre83, %59
  br label %63

61:                                               ; preds = %52
  %62 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  br label %82

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

63:                                               ; preds = %.critedge6, %58, %57
  %64 = phi i64 [ %.pre83, %58 ], [ %.pre83, %57 ], [ %50, %.critedge6 ]
  %.222 = phi i1 [ true, %58 ], [ %.121, %57 ], [ %.121, %.critedge6 ]
  %.2 = phi i64 [ %60, %58 ], [ %.119, %57 ], [ %.119, %.critedge6 ]
  %65 = load i64, ptr %3, align 8, !tbaa !5
  %66 = add nsw i64 %65, %64
  %67 = load i64, ptr %2, align 8, !tbaa !5
  %.not34 = icmp sgt i64 %66, %67
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  br i1 %.not34, label %.critedge8, label %68

68:                                               ; preds = %63
  %69 = load i64, ptr %4, align 8, !tbaa !5
  %70 = sub nsw i64 %66, %69
  store i64 %70, ptr %11, align 8, !tbaa !5
  %71 = invoke noundef i64 @_ZNKSt3setIlSt4lessIlESaIlEE5countERKl(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %72 unwind label %77

72:                                               ; preds = %68
  %.not36 = icmp eq i64 %71, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  br i1 %.not36, label %79, label %73

73:                                               ; preds = %72
  %74 = load i64, ptr %6, align 8, !tbaa !5
  %75 = load i64, ptr %3, align 8, !tbaa !5
  %76 = add nsw i64 %75, %74
  br label %79

77:                                               ; preds = %68
  %78 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  br label %82

.critedge8:                                       ; preds = %63
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  br label %79

79:                                               ; preds = %.critedge8, %73, %72
  %.323 = phi i1 [ true, %73 ], [ %.222, %72 ], [ %.222, %.critedge8 ]
  %.3 = phi i64 [ %76, %73 ], [ %.2, %72 ], [ %.2, %.critedge8 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  %80 = load i64, ptr %1, align 8, !tbaa !5
  %81 = add nsw i64 %80, -1
  store i64 %81, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %80, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

82:                                               ; preds = %77, %61, %47, %35, %26, %24
  %.pn = phi { ptr, i32 } [ %78, %77 ], [ %62, %61 ], [ %48, %47 ], [ %36, %35 ], [ %27, %26 ], [ %25, %24 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  resume { ptr, i32 } %.pn

._crit_edge:                                      ; preds = %79
  %83 = trunc nuw i8 %.125 to i1
  br i1 %.1, label %84, label %.critedge39

84:                                               ; preds = %._crit_edge
  br i1 %83, label %85, label %87

85:                                               ; preds = %84
  %86 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %99

87:                                               ; preds = %84
  %88 = load i64, ptr %4, align 8, !tbaa !5
  %89 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %88)
  br label %99

.critedge39:                                      ; preds = %._crit_edge
  br i1 %83, label %90, label %93

90:                                               ; preds = %.critedge39
  %91 = load i64, ptr %3, align 8, !tbaa !5
  %92 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %91)
  br label %99

93:                                               ; preds = %.critedge39
  br i1 %.323, label %94, label %.thread

94:                                               ; preds = %93
  %95 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.3)
  br label %99

.thread:                                          ; preds = %0, %93
  %96 = load i64, ptr %3, align 8, !tbaa !5
  %97 = load i64, ptr %4, align 8, !tbaa !5
  %98 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %96, i64 noundef %97)
  br label %99

99:                                               ; preds = %87, %94, %.thread, %90, %85
  call void @_ZNSt3setIlSt4lessIlESaIlEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 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: 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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #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

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


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