; LLVM IR from VastoLorde95/Competitive-Programming :: Hackerrank/Random/Median Updates (A)

; 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, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long 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 }
%"class.std::map" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<long long, std::pair<const long long, int>, std::_Select1st<std::pair<const long long, int>>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, std::pair<const long long, int>, std::_Select1st<std::pair<const long long, int>>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.std::map.4" = type { %"class.std::_Rb_tree.5" }
%"class.std::_Rb_tree.5" = type { %"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.std::multiset" = type { %"class.std::_Rb_tree" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i8, i64 }
%"struct.std::pair.13" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@cur = external dso_local global i32, align 4
@comp = external dso_local global %"class.std::set", align 8
@f = external dso_local global %"class.std::map", align 8
@finv = external dso_local global %"class.std::map.4", align 8
@cnt = external dso_local global %"class.std::multiset", align 8
@q = external dso_local global %"class.std::vector", align 8
@c = external dso_local global i8, align 1
@x = external dso_local global i64, align 8
@ncnt = external dso_local global i32, align 4
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6updateii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6medianv() #2

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca %"struct.std::pair.13", align 8
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %7 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %10 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %11 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store i32 0, ptr %1, align 4
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.8, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %30, %0
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %33

18:                                               ; preds = %13
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.9, ptr noundef @c, ptr noundef @x)
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #5
  %20 = call { i8, i64 } @_ZSt9make_pairIRcRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 1 dereferenceable(1) @c, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %21 = getelementptr inbounds { i8, i64 }, ptr %3, i32 0, i32 0
  %22 = extractvalue { i8, i64 } %20, 0
  store i8 %22, ptr %21, align 8
  %23 = getelementptr inbounds { i8, i64 }, ptr %3, i32 0, i32 1
  %24 = extractvalue { i8, i64 } %20, 1
  store i64 %24, ptr %23, align 8
  call void @_ZNSt6vectorISt4pairIcxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @q, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #5
  %25 = call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48) @comp, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %26 = getelementptr inbounds { ptr, i8 }, ptr %4, i32 0, i32 0
  %27 = extractvalue { ptr, i8 } %25, 0
  store ptr %27, ptr %26, align 8
  %28 = getelementptr inbounds { ptr, i8 }, ptr %4, i32 0, i32 1
  %29 = extractvalue { ptr, i8 } %25, 1
  store i8 %29, ptr %28, align 8
  br label %30

30:                                               ; preds = %18
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !9

33:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %34 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #5
  %35 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %5, i32 0, i32 0
  store ptr %34, ptr %35, align 8
  br label %36

36:                                               ; preds = %49, %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %37 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #5
  %38 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %6, i32 0, i32 0
  store ptr %37, ptr %38, align 8
  %39 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %52

41:                                               ; preds = %36
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  %43 = load i64, ptr %42, align 8, !tbaa !11
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @finv, ptr noundef nonnull align 4 dereferenceable(4) @ncnt)
  store i64 %43, ptr %44, align 8, !tbaa !11
  %45 = load i32, ptr @ncnt, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr @ncnt, align 4, !tbaa !5
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIxiSt4lessIxESaISt4pairIKxiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %47)
  store i32 %45, ptr %48, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %41
  %50 = call ptr @_ZNSt23_Rb_tree_const_iteratorIxEppEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef 0) #5
  %51 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %7, i32 0, i32 0
  store ptr %50, ptr %51, align 8
  br label %36, !llvm.loop !13

52:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %104, %52
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %107

58:                                               ; preds = %53
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIcxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @q, i64 noundef %60) #5
  %62 = getelementptr inbounds %"struct.std::pair", ptr %61, i32 0, i32 0
  %63 = load i8, ptr %62, align 8, !tbaa !14
  store i8 %63, ptr @c, align 1, !tbaa !16
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIcxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @q, i64 noundef %65) #5
  %67 = getelementptr inbounds %"struct.std::pair", ptr %66, i32 0, i32 1
  %68 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIxiSt4lessIxESaISt4pairIKxiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %67)
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  store i64 %70, ptr @x, align 8, !tbaa !11
  %71 = load i8, ptr @c, align 1, !tbaa !16
  %72 = sext i8 %71 to i32
  %73 = icmp eq i32 %72, 114
  br i1 %73, label %74, label %91

74:                                               ; preds = %58
  %75 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE5countERKx(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %76 = icmp ne i64 %75, 0
  br i1 %76, label %79, label %77

77:                                               ; preds = %74
  %78 = call i32 @puts(ptr noundef @.str.10)
  br label %104

79:                                               ; preds = %74
  %80 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE4findERKx(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %81 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %9, i32 0, i32 0
  store ptr %80, ptr %81, align 8
  %82 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %9, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8
  %84 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIxE(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr %83)
  %85 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %10, i32 0, i32 0
  store ptr %84, ptr %85, align 8
  %86 = load i64, ptr @x, align 8, !tbaa !11
  %87 = trunc i64 %86 to i32
  call void @_Z6updateii(i32 noundef %87, i32 noundef -1)
  %88 = load i32, ptr @cur, align 4, !tbaa !5
  %89 = add nsw i32 %88, -1
  store i32 %89, ptr @cur, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %79
  br label %98

91:                                               ; preds = %58
  %92 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %93 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %11, i32 0, i32 0
  store ptr %92, ptr %93, align 8
  %94 = load i64, ptr @x, align 8, !tbaa !11
  %95 = trunc i64 %94 to i32
  call void @_Z6updateii(i32 noundef %95, i32 noundef 1)
  %96 = load i32, ptr @cur, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr @cur, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %91, %90
  %99 = load i32, ptr @cur, align 4, !tbaa !5
  %100 = icmp eq i32 %99, 0
  br i1 %100, label %101, label %103

101:                                              ; preds = %98
  %102 = call i32 @puts(ptr noundef @.str.10)
  br label %104

103:                                              ; preds = %98
  call void @_Z6medianv()
  br label %104

104:                                              ; preds = %103, %101, %77
  %105 = load i32, ptr %8, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %8, align 4, !tbaa !5
  br label %53, !llvm.loop !17

107:                                              ; preds = %57
  ret i32 0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIcxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i8, i64 } @_ZSt9make_pairIRcRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIcxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

declare i32 @puts(ptr noundef) #4

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { "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 = !{!15, !7, i64 0}
!15 = !{!"_ZTSSt4pairIcxE", !7, i64 0, !12, i64 8}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !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, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long 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 }
%"class.std::map" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<long long, std::pair<const long long, int>, std::_Select1st<std::pair<const long long, int>>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, std::pair<const long long, int>, std::_Select1st<std::pair<const long long, int>>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.std::map.4" = type { %"class.std::_Rb_tree.5" }
%"class.std::_Rb_tree.5" = type { %"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"class.std::multiset" = type { %"class.std::_Rb_tree" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<char, long long>, std::allocator<std::pair<char, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i8, i64 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@cur = external dso_local local_unnamed_addr global i32, align 4
@comp = external dso_local global %"class.std::set", align 8
@f = external dso_local global %"class.std::map", align 8
@finv = external dso_local global %"class.std::map.4", align 8
@cnt = external dso_local global %"class.std::multiset", align 8
@q = external dso_local global %"class.std::vector", align 8
@c = external dso_local global i8, align 1
@x = external dso_local global i64, align 8
@ncnt = external dso_local global i32, align 4
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6updateii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6medianv() local_unnamed_addr #2

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.8, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  br label %11

._crit_edge:                                      ; preds = %11, %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %8 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #5
  store ptr %8, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %9 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #5
  store ptr %9, ptr %3, align 8
  %10 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br i1 %10, label %.lr.ph13, label %._crit_edge14

11:                                               ; preds = %.lr.ph, %11
  %.011 = phi i32 [ 0, %.lr.ph ], [ %17, %11 ]
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.9, ptr noundef nonnull @c, ptr noundef nonnull @x)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #5
  %13 = call { i8, i64 } @_ZSt9make_pairIRcRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 1 dereferenceable(1) @c, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %14 = extractvalue { i8, i64 } %13, 0
  store i8 %14, ptr %1, align 8
  %15 = extractvalue { i8, i64 } %13, 1
  store i64 %15, ptr %7, align 8
  call void @_ZNSt6vectorISt4pairIcxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @q, ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #5
  %16 = call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48) @comp, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %17 = add nuw nsw i32 %.011, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %11, label %._crit_edge, !llvm.loop !9

._crit_edge14:                                    ; preds = %.lr.ph13, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph17, label %._crit_edge18

.lr.ph13:                                         ; preds = %._crit_edge, %.lr.ph13
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @finv, ptr noundef nonnull align 4 dereferenceable(4) @ncnt)
  store i64 %23, ptr %24, align 8, !tbaa !11
  %25 = load i32, ptr @ncnt, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr @ncnt, align 4, !tbaa !5
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %28 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIxiSt4lessIxESaISt4pairIKxiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %27)
  store i32 %25, ptr %28, align 4, !tbaa !5
  %29 = call ptr @_ZNSt23_Rb_tree_const_iteratorIxEppEi(ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef 0) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %30 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #5
  store ptr %30, ptr %3, align 8
  %31 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br i1 %31, label %.lr.ph13, label %._crit_edge14, !llvm.loop !13

._crit_edge18:                                    ; preds = %59, %._crit_edge14
  ret i32 0

.lr.ph17:                                         ; preds = %._crit_edge14, %59
  %indvars.iv = phi i64 [ %indvars.iv.next, %59 ], [ 0, %._crit_edge14 ]
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIcxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @q, i64 noundef %indvars.iv) #5
  %33 = load i8, ptr %32, align 8, !tbaa !14
  store i8 %33, ptr @c, align 1, !tbaa !16
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIcxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @q, i64 noundef %indvars.iv) #5
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIxiSt4lessIxESaISt4pairIKxiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %35)
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  store i64 %38, ptr @x, align 8, !tbaa !11
  %39 = load i8, ptr @c, align 1, !tbaa !16
  %40 = icmp eq i8 %39, 114
  br i1 %40, label %41, label %48

41:                                               ; preds = %.lr.ph17
  %42 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE5countERKx(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %.not = icmp eq i64 %42, 0
  br i1 %.not, label %43, label %45

43:                                               ; preds = %41
  %44 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.10)
  br label %59

45:                                               ; preds = %41
  %46 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE4findERKx(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr noundef nonnull align 8 dereferenceable(8) @x)
  %47 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIxE(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr %46)
  br label %50

48:                                               ; preds = %.lr.ph17
  %49 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48) @cnt, ptr noundef nonnull align 8 dereferenceable(8) @x)
  br label %50

50:                                               ; preds = %48, %45
  %.sink21 = phi i32 [ 1, %48 ], [ -1, %45 ]
  %51 = load i64, ptr @x, align 8, !tbaa !11
  %52 = trunc i64 %51 to i32
  call void @_Z6updateii(i32 noundef %52, i32 noundef %.sink21)
  %53 = load i32, ptr @cur, align 4, !tbaa !5
  %54 = add nsw i32 %53, %.sink21
  store i32 %54, ptr @cur, align 4, !tbaa !5
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %50
  %57 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.10)
  br label %59

58:                                               ; preds = %50
  call void @_Z6medianv()
  br label %59

59:                                               ; preds = %58, %56, %43
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = icmp slt i64 %indvars.iv.next, %61
  br i1 %62, label %.lr.ph17, label %._crit_edge18, !llvm.loop !17
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIcxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i8, i64 } @_ZSt9make_pairIRcRxESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS3_INS4_IT0_E4typeEE6__typeEEOS5_OSA_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIcxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { 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 #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 = !{!15, !7, i64 0}
!15 = !{!"_ZTSSt4pairIcxE", !7, i64 0, !12, i64 8}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !10}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass