; LLVM IR from tangjz/acm-icpc :: hdu (5994)

; 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.Node = type { i32, i32, i32, [2 x i32], [2 x i32], [2 x i32], i32, i32, i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@que = external dso_local global [200001 x [3 x i32]], align 16
@pos = external dso_local global [200001 x i32], align 16
@tot = external dso_local global i32, align 4
@ord = external dso_local global [200001 x i32], align 16
@tree = external dso_local global [200001 x %struct.Node], align 16
@cnt = external dso_local global i32, align 4
@out = external dso_local global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8kd_buildiiii(i32 noundef, i32 noundef, i32 noundef, 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 void @_Z6kd_setii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6kd_updiii(i32 noundef, i32 noundef, 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 i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca [3 x i8], align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %167, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @t, align 4, !tbaa !5
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %170

16:                                               ; preds = %11
  store i32 0, ptr @tot, align 4, !tbaa !5
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %64, %16
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp sle i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %67

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 3, ptr %5) #5
  %24 = getelementptr inbounds [3 x i8], ptr %5, i64 0, i64 0
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %24)
  %26 = getelementptr inbounds [3 x i8], ptr %5, i64 0, i64 0
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = icmp eq i32 %28, 67
  br i1 %29, label %30, label %52

30:                                               ; preds = %23
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %32
  %34 = getelementptr inbounds [3 x i32], ptr %33, i64 0, i64 0
  %35 = getelementptr inbounds i32, ptr %34, i64 0
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %37
  %39 = getelementptr inbounds [3 x i32], ptr %38, i64 0, i64 0
  %40 = getelementptr inbounds i32, ptr %39, i64 1
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %42
  %44 = getelementptr inbounds [3 x i32], ptr %43, i64 0, i64 0
  %45 = getelementptr inbounds i32, ptr %44, i64 2
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %35, ptr noundef %40, ptr noundef %45)
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = load i32, ptr @tot, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr @tot, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [200001 x i32], ptr @ord, i64 0, i64 %50
  store i32 %47, ptr %51, align 4, !tbaa !5
  br label %63

52:                                               ; preds = %23
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %54
  %56 = getelementptr inbounds [3 x i32], ptr %55, i64 0, i64 0
  %57 = getelementptr inbounds i32, ptr %56, i64 0
  %58 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %57)
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %60
  %62 = getelementptr inbounds [3 x i32], ptr %61, i64 0, i64 2
  store i32 0, ptr %62, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %52, %30
  call void @llvm.lifetime.end.p0(i64 3, ptr %5) #5
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %4, align 4, !tbaa !5
  br label %18, !llvm.loop !10

67:                                               ; preds = %22
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %68)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %70 = load i32, ptr @tot, align 4, !tbaa !5
  %71 = call noundef i32 @_Z8kd_buildiiii(i32 noundef 1, i32 noundef %70, i32 noundef 0, i32 noundef 0)
  store i32 %71, ptr %6, align 4, !tbaa !5
  store i32 1061109567, ptr getelementptr inbounds (%struct.Node, ptr @tree, i32 0, i32 7), align 8, !tbaa !12
  store i32 1061109567, ptr getelementptr inbounds (%struct.Node, ptr @tree, i32 0, i32 6), align 4, !tbaa !14
  store i32 0, ptr getelementptr inbounds (%struct.Node, ptr @tree, i32 0, i32 9), align 16, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %163, %67
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = icmp sle i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %166

77:                                               ; preds = %72
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %79
  %81 = getelementptr inbounds [3 x i32], ptr %80, i64 0, i64 2
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %94

84:                                               ; preds = %77
  %85 = load i32, ptr %7, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %90
  %92 = getelementptr inbounds [3 x i32], ptr %91, i64 0, i64 2
  %93 = load i32, ptr %92, align 4, !tbaa !5
  call void @_Z6kd_setii(i32 noundef %88, i32 noundef %93)
  br label %162

94:                                               ; preds = %77
  %95 = load i32, ptr %6, align 4, !tbaa !5
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %97
  %99 = getelementptr inbounds [3 x i32], ptr %98, i64 0, i64 0
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = xor i32 %100, %101
  call void @_Z6kd_updiii(i32 noundef %95, i32 noundef %102, i32 noundef -1)
  store i32 0, ptr @cnt, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %124, %94
  %104 = load i32, ptr %6, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [200001 x %struct.Node], ptr @tree, i64 0, i64 %105
  %107 = getelementptr inbounds %struct.Node, ptr %106, i32 0, i32 7
  %108 = load i32, ptr %107, align 4, !tbaa !12
  %109 = icmp ne i32 %108, 0
  %110 = xor i1 %109, true
  br i1 %110, label %111, label %130

111:                                              ; preds = %103
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [200001 x %struct.Node], ptr @tree, i64 0, i64 %113
  %115 = getelementptr inbounds %struct.Node, ptr %114, i32 0, i32 8
  %116 = load i32, ptr %115, align 4, !tbaa !16
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [200001 x i32], ptr @ord, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = load i32, ptr @cnt, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr @cnt, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [200001 x i32], ptr @out, i64 0, i64 %122
  store i32 %119, ptr %123, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %111
  %125 = load i32, ptr %6, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [200001 x %struct.Node], ptr @tree, i64 0, i64 %126
  %128 = getelementptr inbounds %struct.Node, ptr %127, i32 0, i32 8
  %129 = load i32, ptr %128, align 4, !tbaa !16
  call void @_Z6kd_setii(i32 noundef %129, i32 noundef 1061109567)
  br label %103, !llvm.loop !17

130:                                              ; preds = %103
  %131 = load i32, ptr @cnt, align 4, !tbaa !5
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %161

133:                                              ; preds = %130
  %134 = load i32, ptr @cnt, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds i32, ptr @out, i64 %135
  %137 = getelementptr inbounds i32, ptr %136, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @out, i64 1), ptr noundef %137)
  %138 = load i32, ptr %7, align 4, !tbaa !5
  %139 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %138)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %140

140:                                              ; preds = %151, %133
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = load i32, ptr @cnt, align 4, !tbaa !5
  %143 = icmp sle i32 %141, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %140
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %159

145:                                              ; preds = %140
  %146 = load i32, ptr %9, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [200001 x i32], ptr @out, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %149)
  br label %151

151:                                              ; preds = %145
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %9, align 4, !tbaa !5
  %154 = sext i32 %152 to i64
  %155 = getelementptr inbounds [200001 x i32], ptr @out, i64 0, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !5
  %157 = load i32, ptr %8, align 4, !tbaa !5
  %158 = xor i32 %157, %156
  store i32 %158, ptr %8, align 4, !tbaa !5
  br label %140, !llvm.loop !18

159:                                              ; preds = %144
  %160 = call i32 @puts(ptr noundef @.str.6)
  br label %161

161:                                              ; preds = %159, %130
  br label %162

162:                                              ; preds = %161, %84
  br label %163

163:                                              ; preds = %162
  %164 = load i32, ptr %7, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %7, align 4, !tbaa !5
  br label %72, !llvm.loop !19

166:                                              ; preds = %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %167

167:                                              ; preds = %166
  %168 = load i32, ptr %2, align 4, !tbaa !5
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !20

170:                                              ; preds = %15
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #4

declare i32 @puts(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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !6, i64 40}
!13 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 12, !7, i64 20, !7, i64 28, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48}
!14 = !{!13, !6, i64 36}
!15 = !{!13, !6, i64 48}
!16 = !{!13, !6, i64 44}
!17 = distinct !{!17, !11}
!18 = distinct !{!18, !11}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11}


; 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.Node = type { i32, i32, i32, [2 x i32], [2 x i32], [2 x i32], i32, i32, i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@que = external dso_local global [200001 x [3 x i32]], align 16
@pos = external dso_local local_unnamed_addr global [200001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@ord = external dso_local local_unnamed_addr global [200001 x i32], align 16
@tree = external dso_local local_unnamed_addr global [200001 x %struct.Node], align 16
@cnt = external dso_local local_unnamed_addr global i32, align 4
@out = external dso_local global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8kd_buildiiii(i32 noundef, i32 noundef, i32 noundef, 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 void @_Z6kd_setii(i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca [3 x i8], align 1
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %3 = load i32, ptr @t, align 4, !tbaa !5
  %.not57 = icmp slt i32 %3, 1
  br i1 %.not57, label %._crit_edge61, label %.lr.ph60

._crit_edge61:                                    ; preds = %._crit_edge56, %0
  ret i32 0

.lr.ph60:                                         ; preds = %0, %._crit_edge56
  %.02958 = phi i32 [ %32, %._crit_edge56 ], [ 1, %0 ]
  store i32 0, ptr @tot, align 4, !tbaa !5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not3339 = icmp slt i32 %5, 1
  br i1 %.not3339, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %29, %.lr.ph60
  %6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %.02958)
  %7 = load i32, ptr @tot, align 4, !tbaa !5
  %8 = call noundef i32 @_Z8kd_buildiiii(i32 noundef 1, i32 noundef %7, i32 noundef 0, i32 noundef 0)
  store i32 1061109567, ptr getelementptr inbounds (i8, ptr @tree, i64 40), align 8, !tbaa !9
  store i32 1061109567, ptr getelementptr inbounds (i8, ptr @tree, i64 36), align 4, !tbaa !11
  store i32 0, ptr getelementptr inbounds (i8, ptr @tree, i64 48), align 16, !tbaa !12
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %.not3451 = icmp slt i32 %9, 1
  br i1 %.not3451, label %._crit_edge56, label %.lr.ph55

.lr.ph55:                                         ; preds = %._crit_edge
  %10 = sext i32 %8 to i64
  %11 = getelementptr inbounds [200001 x %struct.Node], ptr @tree, i64 0, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 40
  %13 = getelementptr inbounds i8, ptr %11, i64 44
  br label %34

.lr.ph:                                           ; preds = %.lr.ph60, %29
  %indvars.iv = phi i64 [ %indvars.iv.next, %29 ], [ 1, %.lr.ph60 ]
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %1) #5
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1)
  %15 = load i8, ptr %1, align 1, !tbaa !13
  %16 = icmp eq i8 %15, 67
  %17 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %indvars.iv
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  br i1 %16, label %19, label %27

19:                                               ; preds = %.lr.ph
  %20 = getelementptr inbounds i8, ptr %17, i64 4
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %17, ptr noundef nonnull %20, ptr noundef nonnull %18)
  %22 = load i32, ptr @tot, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @tot, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [200001 x i32], ptr @ord, i64 0, i64 %24
  %26 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %26, ptr %25, align 4, !tbaa !5
  br label %29

27:                                               ; preds = %.lr.ph
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %17)
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %27, %19
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %1) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %.not33.not = icmp slt i64 %indvars.iv, %31
  br i1 %.not33.not, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge56:                                    ; preds = %._crit_edge44.thread, %._crit_edge
  %32 = add nuw nsw i32 %.02958, 1
  %33 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.02958, %33
  br i1 %.not.not, label %.lr.ph60, label %._crit_edge61, !llvm.loop !16

34:                                               ; preds = %.lr.ph55, %._crit_edge44.thread
  %indvars.iv66 = phi i64 [ 1, %.lr.ph55 ], [ %indvars.iv.next67, %._crit_edge44.thread ]
  %.02753 = phi i32 [ 0, %.lr.ph55 ], [ %.2, %._crit_edge44.thread ]
  %35 = getelementptr inbounds [200001 x [3 x i32]], ptr @que, i64 0, i64 %indvars.iv66
  %36 = getelementptr inbounds i8, ptr %35, i64 8
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %.not35 = icmp eq i32 %37, 0
  br i1 %.not35, label %41, label %38

38:                                               ; preds = %34
  %39 = getelementptr inbounds [200001 x i32], ptr @pos, i64 0, i64 %indvars.iv66
  %40 = load i32, ptr %39, align 4, !tbaa !5
  call void @_Z6kd_setii(i32 noundef %40, i32 noundef %37)
  br label %._crit_edge44.thread

41:                                               ; preds = %34
  %42 = load i32, ptr %35, align 4, !tbaa !5
  %43 = xor i32 %42, %.02753
  call void @_Z6kd_updiii(i32 noundef %8, i32 noundef %43, i32 noundef -1)
  store i32 0, ptr @cnt, align 4, !tbaa !5
  %44 = load i32, ptr %12, align 4, !tbaa !9
  %.not3641 = icmp eq i32 %44, 0
  br i1 %.not3641, label %.lr.ph43, label %._crit_edge44.thread

.lr.ph43:                                         ; preds = %41, %.lr.ph43
  %45 = load i32, ptr %13, align 4, !tbaa !17
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [200001 x i32], ptr @ord, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = load i32, ptr @cnt, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr @cnt, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [200001 x i32], ptr @out, i64 0, i64 %51
  store i32 %48, ptr %52, align 4, !tbaa !5
  call void @_Z6kd_setii(i32 noundef %45, i32 noundef 1061109567)
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %.not36 = icmp eq i32 %53, 0
  br i1 %.not36, label %.lr.ph43, label %._crit_edge44, !llvm.loop !18

._crit_edge44:                                    ; preds = %.lr.ph43
  %.pre = load i32, ptr @cnt, align 4, !tbaa !5
  %.not37 = icmp eq i32 %.pre, 0
  br i1 %.not37, label %._crit_edge44.thread, label %54

54:                                               ; preds = %._crit_edge44
  %55 = sext i32 %.pre to i64
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @out, i64 4), i64 %55
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @out, i64 4), ptr noundef nonnull %gep)
  %56 = trunc nuw nsw i64 %indvars.iv66 to i32
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %56)
  %58 = load i32, ptr @cnt, align 4, !tbaa !5
  %.not3845 = icmp slt i32 %58, 1
  br i1 %.not3845, label %._crit_edge50, label %.lr.ph49

._crit_edge50:                                    ; preds = %.lr.ph49, %54
  %.1.lcssa = phi i32 [ %.02753, %54 ], [ %64, %.lr.ph49 ]
  %59 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.6)
  br label %._crit_edge44.thread

.lr.ph49:                                         ; preds = %54, %.lr.ph49
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %.lr.ph49 ], [ 1, %54 ]
  %.146 = phi i32 [ %64, %.lr.ph49 ], [ %.02753, %54 ]
  %60 = getelementptr inbounds [200001 x i32], ptr @out, i64 0, i64 %indvars.iv63
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %61)
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %63 = load i32, ptr %60, align 4, !tbaa !5
  %64 = xor i32 %63, %.146
  %65 = load i32, ptr @cnt, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %.not38.not = icmp slt i64 %indvars.iv63, %66
  br i1 %.not38.not, label %.lr.ph49, label %._crit_edge50, !llvm.loop !19

._crit_edge44.thread:                             ; preds = %41, %38, %._crit_edge50, %._crit_edge44
  %.2 = phi i32 [ %.02753, %38 ], [ %.1.lcssa, %._crit_edge50 ], [ %.02753, %._crit_edge44 ], [ %.02753, %41 ]
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %.not34.not = icmp slt i64 %indvars.iv66, %68
  br i1 %.not34.not, label %34, label %._crit_edge56, !llvm.loop !20
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @puts(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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 12, !7, i64 20, !7, i64 28, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48}
!11 = !{!10, !6, i64 36}
!12 = !{!10, !6, i64 48}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!10, !6, i64 44}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15}


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