; LLVM IR from tangjz/acm-icpc :: self_training/2015-02-07 (K)

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

@Hash = external dso_local global %"class.std::map", align 8
@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@fa = external dso_local global [20002 x i32], align 16
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3idxi(i32 noundef) #0

; 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 uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [5 x i8], align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %15

15:                                               ; preds = %124, %0
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp ne i32 %19, -1
  br label %21

21:                                               ; preds = %18, %15
  %22 = phi i1 [ false, %15 ], [ %20, %18 ]
  br i1 %22, label %23, label %127

23:                                               ; preds = %21
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @Hash) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %33, %23
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 20002
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %24
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %31
  store i32 %29, ptr %32, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %28
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !5
  br label %24, !llvm.loop !9

36:                                               ; preds = %27
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #5
  store i8 0, ptr %3, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %121, %36
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = icmp sle i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %124

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 5, ptr %8) #5
  %44 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 0
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %6, ptr noundef %7, ptr noundef %44)
  %46 = load i8, ptr %3, align 1, !tbaa !11, !range !13, !noundef !14
  %47 = trunc i8 %46 to i1
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  store i32 9, ptr %5, align 4
  br label %118

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = call noundef i32 @_Z3idxi(i32 noundef %51)
  store i32 %52, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = call noundef i32 @_Z3idxi(i32 noundef %53)
  store i32 %54, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = call noundef i32 @_Z4findi(i32 noundef %55)
  store i32 %56, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = load i32, ptr @n, align 4, !tbaa !5
  %59 = add nsw i32 %57, %58
  %60 = call noundef i32 @_Z4findi(i32 noundef %59)
  store i32 %60, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %61 = load i32, ptr %10, align 4, !tbaa !5
  %62 = call noundef i32 @_Z4findi(i32 noundef %61)
  store i32 %62, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %63 = load i32, ptr %10, align 4, !tbaa !5
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = add nsw i32 %63, %64
  %66 = call noundef i32 @_Z4findi(i32 noundef %65)
  store i32 %66, ptr %14, align 4, !tbaa !5
  %67 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 0
  %68 = load i8, ptr %67, align 1, !tbaa !15
  %69 = sext i8 %68 to i32
  %70 = icmp eq i32 %69, 101
  br i1 %70, label %71, label %93

71:                                               ; preds = %49
  %72 = load i32, ptr %11, align 4, !tbaa !5
  %73 = load i32, ptr %14, align 4, !tbaa !5
  %74 = icmp eq i32 %72, %73
  br i1 %74, label %79, label %75

75:                                               ; preds = %71
  %76 = load i32, ptr %12, align 4, !tbaa !5
  %77 = load i32, ptr %13, align 4, !tbaa !5
  %78 = icmp eq i32 %76, %77
  br i1 %78, label %79, label %80

79:                                               ; preds = %75, %71
  store i8 1, ptr %3, align 1, !tbaa !11
  store i32 9, ptr %5, align 4
  br label %117

80:                                               ; preds = %75
  %81 = load i32, ptr %13, align 4, !tbaa !5
  %82 = call noundef i32 @_Z4findi(i32 noundef %81)
  %83 = load i32, ptr %11, align 4, !tbaa !5
  %84 = call noundef i32 @_Z4findi(i32 noundef %83)
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %85
  store i32 %82, ptr %86, align 4, !tbaa !5
  %87 = load i32, ptr %14, align 4, !tbaa !5
  %88 = call noundef i32 @_Z4findi(i32 noundef %87)
  %89 = load i32, ptr %12, align 4, !tbaa !5
  %90 = call noundef i32 @_Z4findi(i32 noundef %89)
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %91
  store i32 %88, ptr %92, align 4, !tbaa !5
  br label %115

93:                                               ; preds = %49
  %94 = load i32, ptr %11, align 4, !tbaa !5
  %95 = load i32, ptr %13, align 4, !tbaa !5
  %96 = icmp eq i32 %94, %95
  br i1 %96, label %101, label %97

97:                                               ; preds = %93
  %98 = load i32, ptr %12, align 4, !tbaa !5
  %99 = load i32, ptr %14, align 4, !tbaa !5
  %100 = icmp eq i32 %98, %99
  br i1 %100, label %101, label %102

101:                                              ; preds = %97, %93
  store i8 1, ptr %3, align 1, !tbaa !11
  store i32 9, ptr %5, align 4
  br label %117

102:                                              ; preds = %97
  %103 = load i32, ptr %14, align 4, !tbaa !5
  %104 = call noundef i32 @_Z4findi(i32 noundef %103)
  %105 = load i32, ptr %11, align 4, !tbaa !5
  %106 = call noundef i32 @_Z4findi(i32 noundef %105)
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %107
  store i32 %104, ptr %108, align 4, !tbaa !5
  %109 = load i32, ptr %13, align 4, !tbaa !5
  %110 = call noundef i32 @_Z4findi(i32 noundef %109)
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = call noundef i32 @_Z4findi(i32 noundef %111)
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %113
  store i32 %110, ptr %114, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %102, %80
  %116 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %116, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr %5, align 4
  br label %117

117:                                              ; preds = %115, %101, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %118

118:                                              ; preds = %117, %48
  call void @llvm.lifetime.end.p0(i64 5, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %119 = load i32, ptr %5, align 4
  switch i32 %119, label %128 [
    i32 0, label %120
    i32 9, label %121
  ]

120:                                              ; preds = %118
  br label %121

121:                                              ; preds = %120, %118
  %122 = load i32, ptr %4, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %4, align 4, !tbaa !5
  br label %38, !llvm.loop !16

124:                                              ; preds = %42
  %125 = load i32, ptr @ans, align 4, !tbaa !5
  %126 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %125)
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #5
  br label %15, !llvm.loop !17

127:                                              ; preds = %21
  ret i32 0

128:                                              ; preds = %118
  unreachable
}

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

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

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !10}
!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::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 }

@Hash = external dso_local global %"class.std::map", align 8
@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@fa = external dso_local local_unnamed_addr global [20002 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3idxi(i32 noundef) local_unnamed_addr #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [5 x i8], align 1
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = icmp ne i32 %4, -1
  %6 = load i32, ptr @n, align 4
  %7 = icmp ne i32 %6, -1
  %8 = select i1 %5, i1 %7, i1 false
  br i1 %8, label %.lr.ph44, label %._crit_edge45

.lr.ph44:                                         ; preds = %0, %._crit_edge
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @Hash) #5
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %.lr.ph44
  %index = phi i64 [ 0, %.lr.ph44 ], [ %index.next.3, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %.lr.ph44 ], [ %vec.ind.next.3, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %9 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %index
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  store <4 x i32> %vec.ind, ptr %9, align 16, !tbaa !5
  store <4 x i32> %step.add, ptr %10, align 16, !tbaa !5
  %index.next = or disjoint i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %step.add.1 = add <4 x i32> %vec.ind, <i32 12, i32 12, i32 12, i32 12>
  %11 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %index.next
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store <4 x i32> %vec.ind.next, ptr %11, align 16, !tbaa !5
  store <4 x i32> %step.add.1, ptr %12, align 16, !tbaa !5
  %index.next.1 = or disjoint i64 %index, 16
  %vec.ind.next.1 = add <4 x i32> %vec.ind, <i32 16, i32 16, i32 16, i32 16>
  %step.add.2 = add <4 x i32> %vec.ind, <i32 20, i32 20, i32 20, i32 20>
  %13 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %index.next.1
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  store <4 x i32> %vec.ind.next.1, ptr %13, align 16, !tbaa !5
  store <4 x i32> %step.add.2, ptr %14, align 16, !tbaa !5
  %index.next.2 = or disjoint i64 %index, 24
  %vec.ind.next.2 = add <4 x i32> %vec.ind, <i32 24, i32 24, i32 24, i32 24>
  %step.add.3 = add <4 x i32> %vec.ind, <i32 28, i32 28, i32 28, i32 28>
  %15 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %index.next.2
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  store <4 x i32> %vec.ind.next.2, ptr %15, align 16, !tbaa !5
  store <4 x i32> %step.add.3, ptr %16, align 16, !tbaa !5
  %index.next.3 = add nuw nsw i64 %index, 32
  %vec.ind.next.3 = add <4 x i32> %vec.ind, <i32 32, i32 32, i32 32, i32 32>
  %17 = icmp eq i64 %index.next.3, 20000
  br i1 %17, label %scalar.ph, label %vector.body, !llvm.loop !9

scalar.ph:                                        ; preds = %vector.body
  store i32 20000, ptr getelementptr inbounds (i8, ptr @fa, i64 80000), align 16, !tbaa !5
  store i32 20001, ptr getelementptr inbounds (i8, ptr @fa, i64 80004), align 4, !tbaa !5
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %.not40 = icmp slt i32 %19, 1
  br i1 %.not40, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %59, %scalar.ph
  %20 = load i32, ptr @ans, align 4, !tbaa !5
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %20)
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %23 = icmp ne i32 %22, -1
  %24 = load i32, ptr @n, align 4
  %25 = icmp ne i32 %24, -1
  %26 = select i1 %23, i1 %25, i1 false
  br i1 %26, label %.lr.ph44, label %._crit_edge45, !llvm.loop !13

.lr.ph:                                           ; preds = %scalar.ph, %59
  %.02842 = phi i1 [ %.2, %59 ], [ false, %scalar.ph ]
  %.02941 = phi i32 [ %60, %59 ], [ 1, %scalar.ph ]
  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 5, ptr nonnull %3) #5
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  br i1 %.02842, label %59, label %28

28:                                               ; preds = %.lr.ph
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = add nsw i32 %29, -1
  %31 = call noundef i32 @_Z3idxi(i32 noundef %30)
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = call noundef i32 @_Z3idxi(i32 noundef %32)
  %34 = call noundef i32 @_Z4findi(i32 noundef %31)
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %36 = add nsw i32 %35, %31
  %37 = call noundef i32 @_Z4findi(i32 noundef %36)
  %38 = call noundef i32 @_Z4findi(i32 noundef %33)
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = add nsw i32 %39, %33
  %41 = call noundef i32 @_Z4findi(i32 noundef %40)
  %42 = load i8, ptr %3, align 1, !tbaa !14
  %43 = icmp eq i8 %42, 101
  br i1 %43, label %44, label %47

44:                                               ; preds = %28
  %45 = icmp eq i32 %34, %41
  %46 = icmp eq i32 %37, %38
  %or.cond = or i1 %46, %45
  br i1 %or.cond, label %59, label %50

47:                                               ; preds = %28
  %48 = icmp eq i32 %34, %38
  %49 = icmp eq i32 %37, %41
  %or.cond38 = or i1 %48, %49
  br i1 %or.cond38, label %59, label %50

50:                                               ; preds = %47, %44
  %.sink54 = phi i32 [ %38, %44 ], [ %41, %47 ]
  %.sink50 = phi i32 [ %41, %44 ], [ %38, %47 ]
  %51 = call noundef i32 @_Z4findi(i32 noundef %.sink54)
  %52 = call noundef i32 @_Z4findi(i32 noundef %34)
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %53
  store i32 %51, ptr %54, align 4, !tbaa !5
  %55 = call noundef i32 @_Z4findi(i32 noundef %.sink50)
  %56 = call noundef i32 @_Z4findi(i32 noundef %37)
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [20002 x i32], ptr @fa, i64 0, i64 %57
  store i32 %55, ptr %58, align 4, !tbaa !5
  store i32 %.02941, ptr @ans, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %50, %44, %47, %.lr.ph
  %.2 = phi i1 [ true, %.lr.ph ], [ false, %50 ], [ true, %44 ], [ true, %47 ]
  call void @llvm.lifetime.end.p0(i64 5, 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
  %60 = add nuw nsw i32 %.02941, 1
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.02941, %61
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge45:                                    ; preds = %._crit_edge, %0
  ret i32 0
}

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

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

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !10}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass