; LLVM IR from tangjz/acm-icpc :: self_training/2015-04-25 (J)

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

%struct.Trie = type { i32, [26 x i32], i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@pos = external dso_local global [300001 x i32], align 16
@tot = external dso_local global i32, align 4
@in = external dso_local global [300001 x i32], align 16
@out = external dso_local global [300001 x i32], align 16
@seg = external dso_local global [600002 x i32], align 16
@ans = external dso_local global i32, align 4
@e = external dso_local global [300001 x %struct.Trie], align 16
@g = external dso_local global [300001 x %"class.std::vector"], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; 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 void @_Z5buildv() #4

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #5

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #6 {
  %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
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @t)
  br label %10

10:                                               ; preds = %115, %0
  %11 = load i32, ptr @t, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @t, align 4, !tbaa !5
  %13 = icmp ne i32 %11, 0
  br i1 %13, label %14, label %118

14:                                               ; preds = %10
  store i32 0, ptr @tot, align 4, !tbaa !5
  %15 = load i32, ptr @tot, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr @tot, align 4, !tbaa !5
  %17 = sext i32 %15 to i64
  %18 = getelementptr inbounds %struct.Trie, ptr @e, i64 %17
  call void @llvm.memset.p0.i64(ptr align 4 %18, i8 0, i64 112, i1 false)
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %27, %14
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %20
  %26 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z6inserti(i32 noundef %26)
  br label %27

27:                                               ; preds = %25
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %20, !llvm.loop !9

30:                                               ; preds = %24
  call void @_Z5buildv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %40, %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr @tot, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %43

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %38
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %39) #7
  br label %40

40:                                               ; preds = %36
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !11

43:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %57, %43
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = load i32, ptr @tot, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %60

49:                                               ; preds = %44
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [300001 x %struct.Trie], ptr @e, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.Trie, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 4, !tbaa !12
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %55
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %56, ptr noundef nonnull align 4 dereferenceable(4) %4)
  br label %57

57:                                               ; preds = %49
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %4, align 4, !tbaa !5
  br label %44, !llvm.loop !14

60:                                               ; preds = %48
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef 0)
  store i32 0, ptr @ans, align 4, !tbaa !5
  %61 = load i32, ptr @tot, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  %63 = shl i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = mul i64 %64, 4
  call void @llvm.memset.p0.i64(ptr align 16 @seg, i8 0, i64 %65, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %112, %60
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = icmp sle i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %115

71:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [300001 x i32], ptr @pos, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  store i32 %75, ptr %8, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %87, %71
  %77 = load i32, ptr %8, align 4, !tbaa !5
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %80, label %79

79:                                               ; preds = %76
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %93

80:                                               ; preds = %76
  %81 = load i32, ptr @tot, align 4, !tbaa !5
  %82 = load i32, ptr %8, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [300001 x i32], ptr @in, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = call noundef i32 @_Z5queryiii(i32 noundef 1, i32 noundef %81, i32 noundef %85)
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %7, i32 noundef %86)
  br label %87

87:                                               ; preds = %80
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [300001 x %struct.Trie], ptr @e, i64 0, i64 %89
  %91 = getelementptr inbounds %struct.Trie, ptr %90, i32 0, i32 0
  %92 = load i32, ptr %91, align 16, !tbaa !15
  store i32 %92, ptr %8, align 4, !tbaa !5
  br label %76, !llvm.loop !16

93:                                               ; preds = %79
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %7, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) @ans, i32 noundef %95)
  %96 = load i32, ptr @tot, align 4, !tbaa !5
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [300001 x i32], ptr @pos, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [300001 x i32], ptr @in, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [300001 x i32], ptr @pos, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [300001 x i32], ptr @out, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z6updateiiiii(i32 noundef 1, i32 noundef %96, i32 noundef %103, i32 noundef %110, i32 noundef %111)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %112

112:                                              ; preds = %93
  %113 = load i32, ptr %5, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %5, align 4, !tbaa !5
  br label %66, !llvm.loop !17

115:                                              ; preds = %70
  %116 = load i32, ptr @ans, align 4, !tbaa !5
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %116)
  br label %10, !llvm.loop !18

118:                                              ; preds = %10
  ret i32 0
}

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

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

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

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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 #6 = { 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 #7 = { 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 = distinct !{!11, !10}
!12 = !{!13, !6, i64 108}
!13 = !{!"_ZTS4Trie", !6, i64 0, !7, i64 4, !6, i64 108}
!14 = distinct !{!14, !10}
!15 = !{!13, !6, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !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"

%struct.Trie = type { i32, [26 x i32], i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@pos = external dso_local local_unnamed_addr global [300001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@in = external dso_local local_unnamed_addr global [300001 x i32], align 16
@out = external dso_local local_unnamed_addr global [300001 x i32], align 16
@seg = external dso_local local_unnamed_addr global [600002 x i32], align 16
@ans = external dso_local global i32, align 4
@e = external dso_local local_unnamed_addr global [300001 x %struct.Trie], align 16
@g = external dso_local global [300001 x %"class.std::vector"], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6inserti(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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; 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 void @_Z5buildv() local_unnamed_addr #4

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #5

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #6 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @t)
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not42 = icmp eq i32 %4, 0
  br i1 %.not42, label %._crit_edge45, label %.lr.ph44

.lr.ph44:                                         ; preds = %0, %._crit_edge41
  store i32 1, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(112) @e, i8 0, i64 112, i1 false)
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not1821 = icmp slt i32 %7, 1
  br i1 %.not1821, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph44
  call void @_Z5buildv()
  %8 = load i32, ptr @tot, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph25, label %._crit_edge26.thread

._crit_edge26.thread:                             ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  br label %._crit_edge30

.lr.ph:                                           ; preds = %.lr.ph44, %.lr.ph
  %.01622 = phi i32 [ %10, %.lr.ph ], [ 1, %.lr.ph44 ]
  call void @_Z6inserti(i32 noundef %.01622)
  %10 = add nuw nsw i32 %.01622, 1
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %.not18.not = icmp slt i32 %.01622, %11
  br i1 %.not18.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge26:                                    ; preds = %.lr.ph25
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 1, ptr %1, align 4, !tbaa !5
  %12 = icmp sgt i32 %14, 1
  br i1 %12, label %.lr.ph29, label %._crit_edge30

.lr.ph25:                                         ; preds = %._crit_edge, %.lr.ph25
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph25 ], [ 0, %._crit_edge ]
  %13 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %indvars.iv
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr @tot, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = icmp slt i64 %indvars.iv.next, %15
  br i1 %16, label %.lr.ph25, label %._crit_edge26, !llvm.loop !11

._crit_edge30:                                    ; preds = %.lr.ph29, %._crit_edge26.thread, %._crit_edge26
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef 0)
  store i32 0, ptr @ans, align 4, !tbaa !5
  %17 = load i32, ptr @tot, align 4, !tbaa !5
  %18 = shl i32 %17, 1
  %19 = add i32 %18, 2
  %20 = sext i32 %19 to i64
  %21 = shl nsw i64 %20, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @seg, i8 0, i64 %21, i1 false)
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %.not1937 = icmp slt i32 %22, 1
  br i1 %.not1937, label %._crit_edge41, label %.lr.ph40

.lr.ph29:                                         ; preds = %._crit_edge26, %.lr.ph29
  %storemerge27 = phi i32 [ %29, %.lr.ph29 ], [ 1, %._crit_edge26 ]
  %23 = sext i32 %storemerge27 to i64
  %24 = getelementptr inbounds [300001 x %struct.Trie], ptr @e, i64 0, i64 %23, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !12
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [300001 x %"class.std::vector"], ptr @g, i64 0, i64 %26
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %27, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %1, align 4, !tbaa !5
  %30 = load i32, ptr @tot, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %.lr.ph29, label %._crit_edge30, !llvm.loop !14

._crit_edge41.loopexit:                           ; preds = %._crit_edge36
  %.pre50 = load i32, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge41

._crit_edge41:                                    ; preds = %._crit_edge41.loopexit, %._crit_edge30
  %32 = phi i32 [ %.pre50, %._crit_edge41.loopexit ], [ 0, %._crit_edge30 ]
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %32)
  %34 = load i32, ptr @t, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %34, 0
  br i1 %.not, label %._crit_edge45, label %.lr.ph44, !llvm.loop !15

.lr.ph40:                                         ; preds = %._crit_edge30, %._crit_edge36
  %indvars.iv47 = phi i64 [ %indvars.iv.next48, %._crit_edge36 ], [ 1, %._crit_edge30 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  %36 = getelementptr inbounds [300001 x i32], ptr @pos, i64 0, i64 %indvars.iv47
  %.031 = load i32, ptr %36, align 4, !tbaa !5
  %.not2032 = icmp eq i32 %.031, 0
  br i1 %.not2032, label %._crit_edge36, label %.lr.ph35

._crit_edge36.loopexit:                           ; preds = %.lr.ph35
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge36

._crit_edge36:                                    ; preds = %._crit_edge36.loopexit, %.lr.ph40
  %37 = phi i32 [ %.pre, %._crit_edge36.loopexit ], [ 0, %.lr.ph40 ]
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %2, align 4, !tbaa !5
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) @ans, i32 noundef %38)
  %39 = load i32, ptr @tot, align 4, !tbaa !5
  %40 = load i32, ptr %36, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [300001 x i32], ptr @in, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = getelementptr inbounds [300001 x i32], ptr @out, i64 0, i64 %41
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z6updateiiiii(i32 noundef 1, i32 noundef %39, i32 noundef %43, i32 noundef %45, i32 noundef %46)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %indvars.iv.next48 = add nuw nsw i64 %indvars.iv47, 1
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %.not19.not = icmp slt i64 %indvars.iv47, %48
  br i1 %.not19.not, label %.lr.ph40, label %._crit_edge41.loopexit, !llvm.loop !16

.lr.ph35:                                         ; preds = %.lr.ph40, %.lr.ph35
  %.033 = phi i32 [ %.0, %.lr.ph35 ], [ %.031, %.lr.ph40 ]
  %49 = load i32, ptr @tot, align 4, !tbaa !5
  %50 = sext i32 %.033 to i64
  %51 = getelementptr inbounds [300001 x i32], ptr @in, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = call noundef i32 @_Z5queryiii(i32 noundef 1, i32 noundef %49, i32 noundef %52)
  call void @_Z3updRii(ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %53)
  %54 = getelementptr inbounds [300001 x %struct.Trie], ptr @e, i64 0, i64 %50
  %.0 = load i32, ptr %54, align 16, !tbaa !5
  %.not20 = icmp eq i32 %.0, 0
  br i1 %.not20, label %._crit_edge36.loopexit, label %.lr.ph35, !llvm.loop !17

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

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

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

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

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 = { 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 nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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 #6 = { 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 #7 = { 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 = distinct !{!11, !10}
!12 = !{!13, !6, i64 108}
!13 = !{!"_ZTS4Trie", !6, i64 0, !7, i64 4, !6, i64 108}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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