; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/MKTHNUM (mk2)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_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_iterator" = type { ptr }
%"struct.std::pair" = type { i32, i32 }
%struct.node = type { i32, ptr, ptr }

@val = external dso_local global [111111 x i32], align 16
@RM = external dso_local global [111111 x i32], align 16
@maxi = external dso_local global i32, align 4
@compresser = external dso_local global %"class.std::map", align 8
@null = external dso_local global ptr, align 8
@root = external dso_local global [111111 x ptr], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4node6insertEiii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, i32 noundef) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5queryP4nodeS0_iii(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #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 i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %10 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %11 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %28, %0
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

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

19:                                               ; preds = %14
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [111111 x i32], ptr @val, i64 0, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %22)
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [111111 x i32], ptr @val, i64 0, i64 %25
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @compresser, ptr noundef nonnull align 4 dereferenceable(4) %26)
  br label %28

28:                                               ; preds = %19
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %8, align 4, !tbaa !5
  br label %14, !llvm.loop !9

31:                                               ; preds = %18
  store i32 0, ptr @maxi, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %32 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @compresser) #5
  %33 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %9, i32 0, i32 0
  store ptr %32, ptr %33, align 8
  br label %34

34:                                               ; preds = %52, %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %35 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @compresser) #5
  %36 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %10, i32 0, i32 0
  store ptr %35, ptr %36, align 8
  %37 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %55

39:                                               ; preds = %34
  %40 = load i32, ptr @maxi, align 4, !tbaa !5
  %41 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  %42 = getelementptr inbounds %"struct.std::pair", ptr %41, i32 0, i32 0
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @compresser, ptr noundef nonnull align 4 dereferenceable(4) %42)
  store i32 %40, ptr %43, align 4, !tbaa !5
  %44 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  %45 = getelementptr inbounds %"struct.std::pair", ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 4, !tbaa !11
  %47 = load i32, ptr @maxi, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [111111 x i32], ptr @RM, i64 0, i64 %48
  store i32 %46, ptr %49, align 4, !tbaa !5
  %50 = load i32, ptr @maxi, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr @maxi, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %39
  %53 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %9, i32 noundef 0) #5
  %54 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %11, i32 0, i32 0
  store ptr %53, ptr %54, align 8
  br label %34, !llvm.loop !13

55:                                               ; preds = %38
  %56 = load ptr, ptr @null, align 8, !tbaa !14
  %57 = load ptr, ptr @null, align 8, !tbaa !14
  %58 = getelementptr inbounds %struct.node, ptr %57, i32 0, i32 2
  store ptr %56, ptr %58, align 8, !tbaa !16
  %59 = load ptr, ptr @null, align 8, !tbaa !14
  %60 = getelementptr inbounds %struct.node, ptr %59, i32 0, i32 1
  store ptr %56, ptr %60, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %89, %55
  %62 = load i32, ptr %12, align 4, !tbaa !5
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %92

66:                                               ; preds = %61
  %67 = load i32, ptr %12, align 4, !tbaa !5
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %66
  %70 = load ptr, ptr @null, align 8, !tbaa !14
  br label %77

71:                                               ; preds = %66
  %72 = load i32, ptr %12, align 4, !tbaa !5
  %73 = sub nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [111111 x ptr], ptr @root, i64 0, i64 %74
  %76 = load ptr, ptr %75, align 8, !tbaa !14
  br label %77

77:                                               ; preds = %71, %69
  %78 = phi ptr [ %70, %69 ], [ %76, %71 ]
  %79 = load i32, ptr @maxi, align 4, !tbaa !5
  %80 = load i32, ptr %12, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [111111 x i32], ptr @val, i64 0, i64 %81
  %83 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @compresser, ptr noundef nonnull align 4 dereferenceable(4) %82)
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = call noundef ptr @_ZN4node6insertEiii(ptr noundef nonnull align 8 dereferenceable(24) %78, i32 noundef 0, i32 noundef %79, i32 noundef %84)
  %86 = load i32, ptr %12, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [111111 x ptr], ptr @root, i64 0, i64 %87
  store ptr %85, ptr %88, align 8, !tbaa !14
  br label %89

89:                                               ; preds = %77
  %90 = load i32, ptr %12, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %12, align 4, !tbaa !5
  br label %61, !llvm.loop !19

92:                                               ; preds = %65
  br label %93

93:                                               ; preds = %117, %92
  %94 = load i32, ptr %3, align 4, !tbaa !5
  %95 = add nsw i32 %94, -1
  store i32 %95, ptr %3, align 4, !tbaa !5
  %96 = icmp ne i32 %94, 0
  br i1 %96, label %97, label %127

97:                                               ; preds = %93
  %98 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = add nsw i32 %99, -1
  store i32 %100, ptr %4, align 4, !tbaa !5
  %101 = load i32, ptr %5, align 4, !tbaa !5
  %102 = add nsw i32 %101, -1
  store i32 %102, ptr %5, align 4, !tbaa !5
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [111111 x ptr], ptr @root, i64 0, i64 %104
  %106 = load ptr, ptr %105, align 8, !tbaa !14
  %107 = load i32, ptr %4, align 4, !tbaa !5
  %108 = icmp eq i32 %107, 0
  br i1 %108, label %109, label %111

109:                                              ; preds = %97
  %110 = load ptr, ptr @null, align 8, !tbaa !14
  br label %117

111:                                              ; preds = %97
  %112 = load i32, ptr %4, align 4, !tbaa !5
  %113 = sub nsw i32 %112, 1
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [111111 x ptr], ptr @root, i64 0, i64 %114
  %116 = load ptr, ptr %115, align 8, !tbaa !14
  br label %117

117:                                              ; preds = %111, %109
  %118 = phi ptr [ %110, %109 ], [ %116, %111 ]
  %119 = load i32, ptr @maxi, align 4, !tbaa !5
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = call noundef i32 @_Z5queryP4nodeS0_iii(ptr noundef %106, ptr noundef %118, i32 noundef 0, i32 noundef %119, i32 noundef %120)
  store i32 %121, ptr %7, align 4, !tbaa !5
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [111111 x i32], ptr @RM, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %125)
  br label %93, !llvm.loop !20

127:                                              ; preds = %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %128 = load i32, ptr %1, align 4
  ret i32 %128
}

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

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

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

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

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

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

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #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, !6, i64 0}
!12 = !{!"_ZTSSt4pairIKiiE", !6, i64 0, !6, i64 4}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!17, !15, i64 16}
!17 = !{!"_ZTS4node", !6, i64 0, !15, i64 8, !15, i64 16}
!18 = !{!17, !15, i64 8}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_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_iterator" = type { ptr }

@val = external dso_local global [111111 x i32], align 16
@RM = external dso_local local_unnamed_addr global [111111 x i32], align 16
@maxi = external dso_local local_unnamed_addr global i32, align 4
@compresser = external dso_local global %"class.std::map", align 8
@null = external dso_local local_unnamed_addr global ptr, align 8
@root = external dso_local local_unnamed_addr global [111111 x ptr], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4node6insertEiii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5queryP4nodeS0_iii(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

._crit_edge:                                      ; preds = %.lr.ph, %0
  store i32 0, ptr @maxi, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %11 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @compresser) #5
  store ptr %11, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %12 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @compresser) #5
  store ptr %12, ptr %7, align 8
  %13 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br i1 %13, label %.lr.ph17, label %._crit_edge18

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %14 = getelementptr inbounds [111111 x i32], ptr @val, i64 0, i64 %indvars.iv
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %14)
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @compresser, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge18:                                    ; preds = %.lr.ph17, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  %20 = load ptr, ptr @null, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store ptr %20, ptr %21, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %20, i64 8
  store ptr %20, ptr %22, align 8, !tbaa !15
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.lr.ph21.preheader, label %.preheader

.lr.ph21.preheader:                               ; preds = %._crit_edge18
  %25 = load i32, ptr @maxi, align 4, !tbaa !5
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @compresser, ptr noundef nonnull align 4 dereferenceable(4) @val)
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = call noundef ptr @_ZN4node6insertEiii(ptr noundef nonnull align 8 dereferenceable(24) %20, i32 noundef 0, i32 noundef %25, i32 noundef %27)
  store ptr %28, ptr @root, align 16, !tbaa !11
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 1
  br i1 %30, label %.lr.ph21, label %.preheader

.lr.ph17:                                         ; preds = %._crit_edge, %.lr.ph17
  %31 = load i32, ptr @maxi, align 4, !tbaa !5
  %32 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @compresser, ptr noundef nonnull align 4 dereferenceable(4) %32)
  store i32 %31, ptr %33, align 4, !tbaa !5
  %34 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  %35 = load i32, ptr %34, align 4, !tbaa !16
  %36 = load i32, ptr @maxi, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [111111 x i32], ptr @RM, i64 0, i64 %37
  store i32 %35, ptr %38, align 4, !tbaa !5
  %39 = add nsw i32 %36, 1
  store i32 %39, ptr @maxi, align 4, !tbaa !5
  %40 = call ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef 0) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %41 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @compresser) #5
  store ptr %41, ptr %7, align 8
  %42 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br i1 %42, label %.lr.ph17, label %._crit_edge18, !llvm.loop !18

.preheader:                                       ; preds = %.lr.ph21, %.lr.ph21.preheader, %._crit_edge18
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr %2, align 4, !tbaa !5
  %.not22 = icmp eq i32 %43, 0
  br i1 %.not22, label %._crit_edge24, label %.lr.ph23

.lr.ph21:                                         ; preds = %.lr.ph21.preheader, %.lr.ph21
  %45 = phi ptr [ %50, %.lr.ph21 ], [ %28, %.lr.ph21.preheader ]
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.lr.ph21 ], [ 1, %.lr.ph21.preheader ]
  %46 = load i32, ptr @maxi, align 4, !tbaa !5
  %47 = getelementptr inbounds [111111 x i32], ptr @val, i64 0, i64 %indvars.iv26
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @compresser, ptr noundef nonnull align 4 dereferenceable(4) %47)
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = call noundef ptr @_ZN4node6insertEiii(ptr noundef nonnull align 8 dereferenceable(24) %45, i32 noundef 0, i32 noundef %46, i32 noundef %49)
  %51 = getelementptr inbounds [111111 x ptr], ptr @root, i64 0, i64 %indvars.iv26
  store ptr %50, ptr %51, align 8, !tbaa !11
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = icmp slt i64 %indvars.iv.next27, %53
  br i1 %54, label %.lr.ph21, label %.preheader, !llvm.loop !19

.lr.ph23:                                         ; preds = %.preheader, %.lr.ph23
  %55 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = add nsw i32 %56, -1
  store i32 %57, ptr %3, align 4, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = add nsw i32 %58, -1
  store i32 %59, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [111111 x ptr], ptr @root, i64 0, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  %63 = icmp eq i32 %57, 0
  %64 = add nsw i32 %56, -2
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [111111 x ptr], ptr @root, i64 0, i64 %65
  %.in = select i1 %63, ptr @null, ptr %66
  %67 = load ptr, ptr %.in, align 8, !tbaa !11
  %68 = load i32, ptr @maxi, align 4, !tbaa !5
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = call noundef i32 @_Z5queryP4nodeS0_iii(ptr noundef %62, ptr noundef %67, i32 noundef 0, i32 noundef %68, i32 noundef %69)
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [111111 x i32], ptr @RM, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %73)
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = add nsw i32 %75, -1
  store i32 %76, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %75, 0
  br i1 %.not, label %._crit_edge24, label %.lr.ph23, !llvm.loop !21

._crit_edge24:                                    ; preds = %.lr.ph23, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

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

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

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

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

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

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #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 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !12, i64 16}
!14 = !{!"_ZTS4node", !6, i64 0, !12, i64 8, !12, i64 16}
!15 = !{!14, !12, i64 8}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTSSt4pairIKiiE", !6, i64 0, !6, i64 4}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !20}
!20 = !{!"llvm.loop.peeled.count", i32 1}
!21 = distinct !{!21, !10}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass