; LLVM IR from tangjz/acm-icpc :: lydsy (1954)

; 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.Edge = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@lnk = external dso_local global [100001 x i32], align 16
@que = external dso_local global [100001 x i32], align 16
@dis = external dso_local global [100001 x i32], align 16
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@vis = external dso_local global [100001 x i8], align 16
@e = external dso_local global [200002 x %struct.Edge], align 16
@.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 nounwind uwtable
declare dso_local noundef i32 @_Z5queryi(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 nounwind uwtable
declare dso_local noundef i32 @_Z6inserti(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 i32, align 4
  %6 = alloca %struct.Edge, align 4
  %7 = alloca %struct.Edge, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %12 = load i32, ptr @tot, align 4, !tbaa !5
  %13 = add nsw i32 %12, 1
  store i32 %13, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %55, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @n, 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 %2) #5
  br label %58

19:                                               ; preds = %14
  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
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #5
  %21 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 0
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  store i32 %25, ptr %21, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 1
  %27 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %27, ptr %26, align 4, !tbaa !11
  %28 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 2
  %29 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %29, ptr %28, align 4, !tbaa !12
  %30 = load i32, ptr @tot, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %31
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 4 %6, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #5
  %33 = load i32, ptr @tot, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr @tot, align 4, !tbaa !5
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %36
  store i32 %33, ptr %37, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #5
  %38 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 0
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  store i32 %42, ptr %38, align 4, !tbaa !9
  %43 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 1
  %44 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %44, ptr %43, align 4, !tbaa !11
  %45 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 2
  %46 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %46, ptr %45, align 4, !tbaa !12
  %47 = load i32, ptr @tot, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %48
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %7, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #5
  %50 = load i32, ptr @tot, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr @tot, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %53
  store i32 %50, ptr %54, align 4, !tbaa !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
  br label %55

55:                                               ; preds = %19
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !14

58:                                               ; preds = %18
  store i32 1, ptr @tot, align 4, !tbaa !5
  %59 = load i32, ptr @R, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr @R, align 4, !tbaa !5
  %61 = sext i32 %59 to i64
  %62 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %61
  store i32 1, ptr %62, align 4, !tbaa !5
  %63 = call noundef i32 @_Z6inserti(i32 noundef 0)
  br label %64

64:                                               ; preds = %154, %58
  %65 = load i32, ptr @L, align 4, !tbaa !5
  %66 = load i32, ptr @R, align 4, !tbaa !5
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %68, label %155

68:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %69 = load i32, ptr @L, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr @L, align 4, !tbaa !5
  %71 = sext i32 %69 to i64
  %72 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  store i32 %73, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100001 x i32], ptr @dis, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = call noundef i32 @_Z5queryi(i32 noundef %77)
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100001 x i32], ptr @dis, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = xor i32 %78, %82
  store i32 %83, ptr %9, align 4, !tbaa !5
  %84 = load i32, ptr @ans, align 4, !tbaa !5
  %85 = load i32, ptr %9, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %87, label %89

87:                                               ; preds = %68
  %88 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %88, ptr @ans, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %87, %68
  %90 = load i32, ptr %8, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100001 x i32], ptr @dis, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = call noundef i32 @_Z6inserti(i32 noundef %93)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %95 = load i32, ptr %8, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  store i32 %98, ptr %10, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %148, %89
  %100 = load i32, ptr %10, align 4, !tbaa !5
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %103, label %102

102:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %154

103:                                              ; preds = %99
  %104 = load i32, ptr %10, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %105
  %107 = getelementptr inbounds %struct.Edge, ptr %106, i32 0, i32 1
  %108 = load i32, ptr %107, align 4, !tbaa !11
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %109
  %111 = load i8, ptr %110, align 1, !tbaa !16, !range !18, !noundef !19
  %112 = trunc i8 %111 to i1
  br i1 %112, label %147, label %113

113:                                              ; preds = %103
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100001 x i32], ptr @dis, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = load i32, ptr %10, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %119
  %121 = getelementptr inbounds %struct.Edge, ptr %120, i32 0, i32 2
  %122 = load i32, ptr %121, align 4, !tbaa !12
  %123 = xor i32 %117, %122
  %124 = load i32, ptr %10, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %125
  %127 = getelementptr inbounds %struct.Edge, ptr %126, i32 0, i32 1
  %128 = load i32, ptr %127, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [100001 x i32], ptr @dis, i64 0, i64 %129
  store i32 %123, ptr %130, align 4, !tbaa !5
  %131 = load i32, ptr %10, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %132
  %134 = getelementptr inbounds %struct.Edge, ptr %133, i32 0, i32 1
  %135 = load i32, ptr %134, align 4, !tbaa !11
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %136
  store i8 1, ptr %137, align 1, !tbaa !16
  %138 = load i32, ptr %10, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %139
  %141 = getelementptr inbounds %struct.Edge, ptr %140, i32 0, i32 1
  %142 = load i32, ptr %141, align 4, !tbaa !11
  %143 = load i32, ptr @R, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr @R, align 4, !tbaa !5
  %145 = sext i32 %143 to i64
  %146 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %145
  store i32 %142, ptr %146, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %113, %103
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %10, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %150
  %152 = getelementptr inbounds %struct.Edge, ptr %151, i32 0, i32 0
  %153 = load i32, ptr %152, align 4, !tbaa !9
  store i32 %153, ptr %10, align 4, !tbaa !5
  br label %99, !llvm.loop !20

154:                                              ; preds = %102
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %64, !llvm.loop !21

155:                                              ; preds = %64
  %156 = load i32, ptr @ans, align 4, !tbaa !5
  %157 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %156)
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 0}
!10 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !15}
!21 = distinct !{!21, !15}


; 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.Edge = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@lnk = external dso_local local_unnamed_addr global [100001 x i32], align 16
@que = external dso_local local_unnamed_addr global [100001 x i32], align 16
@dis = external dso_local local_unnamed_addr global [100001 x i32], align 16
@L = external dso_local local_unnamed_addr global i32, align 4
@R = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [100001 x i8], align 16
@e = external dso_local local_unnamed_addr global [200002 x %struct.Edge], align 16
@.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 nounwind uwtable
declare dso_local noundef i32 @_Z5queryi(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 nounwind uwtable
declare dso_local noundef i32 @_Z6inserti(i32 noundef) local_unnamed_addr #0

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

._crit_edge:                                      ; preds = %.lr.ph, %0
  store i32 1, ptr @tot, align 4, !tbaa !5
  %9 = load i32, ptr @R, align 4, !tbaa !5
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr @R, align 4, !tbaa !5
  %11 = sext i32 %9 to i64
  %12 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %11
  store i32 1, ptr %12, align 4, !tbaa !5
  %13 = call noundef i32 @_Z6inserti(i32 noundef 0)
  %14 = load i32, ptr @L, align 4, !tbaa !5
  %15 = load i32, ptr @R, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %.lr.ph29, label %._crit_edge30

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01922 = phi i32 [ %34, %.lr.ph ], [ 1, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = load i32, ptr @tot, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %25
  store i32 %21, ptr %26, align 4, !tbaa !5
  %.sroa.415.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 4
  store i32 %22, ptr %.sroa.415.0..sroa_idx, align 4, !tbaa !5
  %.sroa.516.0..sroa_idx = getelementptr inbounds i8, ptr %26, i64 8
  store i32 %23, ptr %.sroa.516.0..sroa_idx, align 4, !tbaa !5
  %27 = add nsw i32 %24, 1
  store i32 %24, ptr %20, align 4, !tbaa !5
  %28 = sext i32 %22 to i64
  %29 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %27 to i64
  %32 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %31
  store i32 %30, ptr %32, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %32, i64 4
  store i32 %18, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %32, i64 8
  store i32 %23, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  %33 = add nsw i32 %24, 2
  store i32 %33, ptr @tot, align 4, !tbaa !5
  store i32 %27, ptr %29, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %34 = add nuw nsw i32 %.01922, 1
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.loopexit:                                        ; preds = %75, %54
  %37 = phi i32 [ %R.promoted, %54 ], [ %76, %75 ]
  %38 = load i32, ptr @L, align 4, !tbaa !5
  %39 = icmp slt i32 %38, %37
  br i1 %39, label %.lr.ph29, label %._crit_edge30, !llvm.loop !11

.lr.ph29:                                         ; preds = %._crit_edge, %.loopexit
  %40 = phi i32 [ %38, %.loopexit ], [ %14, %._crit_edge ]
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr @L, align 4, !tbaa !5
  %42 = sext i32 %40 to i64
  %43 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100001 x i32], ptr @dis, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = call noundef i32 @_Z5queryi(i32 noundef %47)
  %49 = load i32, ptr %46, align 4, !tbaa !5
  %50 = xor i32 %49, %48
  %51 = load i32, ptr @ans, align 4, !tbaa !5
  %52 = icmp slt i32 %51, %50
  br i1 %52, label %53, label %54

53:                                               ; preds = %.lr.ph29
  store i32 %50, ptr @ans, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %53, %.lr.ph29
  %55 = call noundef i32 @_Z6inserti(i32 noundef %49)
  %56 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %45
  %R.promoted = load i32, ptr @R, align 4, !tbaa !5
  %.023 = load i32, ptr %56, align 4, !tbaa !5
  %.not24 = icmp eq i32 %.023, 0
  br i1 %.not24, label %.loopexit, label %.lr.ph27

.lr.ph27:                                         ; preds = %54, %75
  %.025 = phi i32 [ %.0, %75 ], [ %.023, %54 ]
  %57 = phi i32 [ %76, %75 ], [ %R.promoted, %54 ]
  %58 = sext i32 %.025 to i64
  %59 = getelementptr inbounds [200002 x %struct.Edge], ptr @e, i64 0, i64 %58
  %60 = getelementptr inbounds i8, ptr %59, i64 4
  %61 = load i32, ptr %60, align 4, !tbaa !12
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %62
  %64 = load i8, ptr %63, align 1, !tbaa !14, !range !16, !noundef !17
  %65 = trunc nuw i8 %64 to i1
  br i1 %65, label %75, label %66

66:                                               ; preds = %.lr.ph27
  %67 = load i32, ptr %46, align 4, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %59, i64 8
  %69 = load i32, ptr %68, align 4, !tbaa !18
  %70 = xor i32 %69, %67
  %71 = getelementptr inbounds [100001 x i32], ptr @dis, i64 0, i64 %62
  store i32 %70, ptr %71, align 4, !tbaa !5
  store i8 1, ptr %63, align 1, !tbaa !14
  %72 = add nsw i32 %57, 1
  store i32 %72, ptr @R, align 4, !tbaa !5
  %73 = sext i32 %57 to i64
  %74 = getelementptr inbounds [100001 x i32], ptr @que, i64 0, i64 %73
  store i32 %61, ptr %74, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %.lr.ph27, %66
  %76 = phi i32 [ %57, %.lr.ph27 ], [ %72, %66 ]
  %.0 = load i32, ptr %59, align 4, !tbaa !5
  %.not = icmp eq i32 %.0, 0
  br i1 %.not, label %.loopexit, label %.lr.ph27, !llvm.loop !19

._crit_edge30:                                    ; preds = %.loopexit, %._crit_edge
  %77 = load i32, ptr @ans, align 4, !tbaa !5
  %78 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %77)
  ret i32 0
}

; 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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse 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 = { 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 = { 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 4}
!13 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!13, !6, i64 8}
!19 = distinct !{!19, !10}


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