; LLVM IR from tangjz/acm-icpc :: 51nod (1109)

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

@n = external dso_local global i32, align 4
@que = external dso_local global [1000001 x i32], align 16
@pre = external dso_local global [1000001 x i32], align 16
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@vis = external dso_local global [1000001 x i8], align 16
@ans = external dso_local global [1000001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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, ptr noundef @n)
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %12, label %14

12:                                               ; preds = %0
  %13 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  br label %184

14:                                               ; preds = %0
  %15 = load i32, ptr @R, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %16
  store i32 1, ptr %17, align 4, !tbaa !5
  store i8 1, ptr getelementptr inbounds ([1000001 x i8], ptr @vis, i64 0, i64 1), align 1, !tbaa !9
  %18 = load i32, ptr @R, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr @R, align 4, !tbaa !5
  %20 = sext i32 %18 to i64
  %21 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %20
  store i32 -1, ptr %21, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %159, %14
  %23 = load i32, ptr @L, align 4, !tbaa !5
  %24 = load i32, ptr @R, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %162

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %27 = load i32, ptr @L, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = mul nsw i32 %30, 10
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = srem i32 %31, %32
  store i32 %33, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = srem i32 %35, %36
  store i32 %37, ptr %3, align 4, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %78, label %40

40:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %41 = load i32, ptr @L, align 4, !tbaa !5
  store i32 %41, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %42 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %42, ptr %5, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %64, %40
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = icmp ne i32 %44, -1
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %73

47:                                               ; preds = %43
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = mul nsw i32 %51, 10
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = srem i32 %52, %53
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = icmp ne i32 %54, %55
  %57 = zext i1 %56 to i32
  %58 = add nsw i32 48, %57
  %59 = trunc i32 %58 to i8
  %60 = load i32, ptr @tot, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr @tot, align 4, !tbaa !5
  %62 = sext i32 %60 to i64
  %63 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %62
  store i8 %59, ptr %63, align 1, !tbaa !11
  br label %64

64:                                               ; preds = %47
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  store i32 %68, ptr %5, align 4, !tbaa !5
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  store i32 %72, ptr %4, align 4, !tbaa !5
  br label %43, !llvm.loop !12

73:                                               ; preds = %46
  %74 = load i32, ptr @tot, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr @tot, align 4, !tbaa !5
  %76 = sext i32 %74 to i64
  %77 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %76
  store i8 49, ptr %77, align 1, !tbaa !11
  br label %98

78:                                               ; preds = %26
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %80
  %82 = load i8, ptr %81, align 1, !tbaa !9, !range !14, !noundef !15
  %83 = trunc i8 %82 to i1
  br i1 %83, label %97, label %84

84:                                               ; preds = %78
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = load i32, ptr @R, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %87
  store i32 %85, ptr %88, align 4, !tbaa !5
  %89 = load i32, ptr %2, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %90
  store i8 1, ptr %91, align 1, !tbaa !9
  %92 = load i32, ptr @L, align 4, !tbaa !5
  %93 = load i32, ptr @R, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr @R, align 4, !tbaa !5
  %95 = sext i32 %93 to i64
  %96 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %95
  store i32 %92, ptr %96, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %84, %78
  br label %98

98:                                               ; preds = %97, %73
  %99 = load i32, ptr %3, align 4, !tbaa !5
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %139, label %101

101:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %102 = load i32, ptr @L, align 4, !tbaa !5
  store i32 %102, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %103 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %103, ptr %7, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %125, %101
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = icmp ne i32 %105, -1
  br i1 %106, label %108, label %107

107:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %134

108:                                              ; preds = %104
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = mul nsw i32 %112, 10
  %114 = load i32, ptr @n, align 4, !tbaa !5
  %115 = srem i32 %113, %114
  %116 = load i32, ptr %7, align 4, !tbaa !5
  %117 = icmp ne i32 %115, %116
  %118 = zext i1 %117 to i32
  %119 = add nsw i32 48, %118
  %120 = trunc i32 %119 to i8
  %121 = load i32, ptr @tot, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr @tot, align 4, !tbaa !5
  %123 = sext i32 %121 to i64
  %124 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %123
  store i8 %120, ptr %124, align 1, !tbaa !11
  br label %125

125:                                              ; preds = %108
  %126 = load i32, ptr %6, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  store i32 %129, ptr %7, align 4, !tbaa !5
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  store i32 %133, ptr %6, align 4, !tbaa !5
  br label %104, !llvm.loop !16

134:                                              ; preds = %107
  %135 = load i32, ptr @tot, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr @tot, align 4, !tbaa !5
  %137 = sext i32 %135 to i64
  %138 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %137
  store i8 49, ptr %138, align 1, !tbaa !11
  br label %159

139:                                              ; preds = %98
  %140 = load i32, ptr %3, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %141
  %143 = load i8, ptr %142, align 1, !tbaa !9, !range !14, !noundef !15
  %144 = trunc i8 %143 to i1
  br i1 %144, label %158, label %145

145:                                              ; preds = %139
  %146 = load i32, ptr %3, align 4, !tbaa !5
  %147 = load i32, ptr @R, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %148
  store i32 %146, ptr %149, align 4, !tbaa !5
  %150 = load i32, ptr %3, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %151
  store i8 1, ptr %152, align 1, !tbaa !9
  %153 = load i32, ptr @L, align 4, !tbaa !5
  %154 = load i32, ptr @R, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr @R, align 4, !tbaa !5
  %156 = sext i32 %154 to i64
  %157 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %156
  store i32 %153, ptr %157, align 4, !tbaa !5
  br label %158

158:                                              ; preds = %145, %139
  br label %159

159:                                              ; preds = %158, %134
  %160 = load i32, ptr @L, align 4, !tbaa !5
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr @L, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %22, !llvm.loop !17

162:                                              ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %163

163:                                              ; preds = %179, %162
  %164 = load i32, ptr %8, align 4, !tbaa !5
  %165 = load i32, ptr @tot, align 4, !tbaa !5
  %166 = ashr i32 %165, 1
  %167 = icmp slt i32 %164, %166
  br i1 %167, label %169, label %168

168:                                              ; preds = %163
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %182

169:                                              ; preds = %163
  %170 = load i32, ptr %8, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %171
  %173 = load i32, ptr @tot, align 4, !tbaa !5
  %174 = sub nsw i32 %173, 1
  %175 = load i32, ptr %8, align 4, !tbaa !5
  %176 = sub nsw i32 %174, %175
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %177
  call void @_ZSt4swapIcENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1) %172, ptr noundef nonnull align 1 dereferenceable(1) %178) #4
  br label %179

179:                                              ; preds = %169
  %180 = load i32, ptr %8, align 4, !tbaa !5
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %8, align 4, !tbaa !5
  br label %163, !llvm.loop !18

182:                                              ; preds = %168
  %183 = call i32 @puts(ptr noundef @ans)
  store i32 0, ptr %1, align 4
  br label %184

184:                                              ; preds = %182, %12
  %185 = load i32, ptr %1, align 4
  ret i32 %185
}

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

declare i32 @puts(ptr noundef) #1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIcENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) #3

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


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

@n = external dso_local global i32, align 4
@que = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@pre = external dso_local local_unnamed_addr global [1000001 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
@tot = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [1000001 x i8], align 16
@ans = external dso_local global [1000001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp eq i32 %2, 1
  br i1 %3, label %._crit_edge68, label %4

4:                                                ; preds = %0
  %5 = load i32, ptr @R, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %6
  store i32 1, ptr %7, align 4, !tbaa !5
  store i8 1, ptr getelementptr inbounds (i8, ptr @vis, i64 1), align 1, !tbaa !9
  %8 = add nsw i32 %5, 1
  store i32 %8, ptr @R, align 4, !tbaa !5
  %9 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %6
  store i32 -1, ptr %9, align 4, !tbaa !5
  %L.promoted = load i32, ptr @L, align 4, !tbaa !5
  %tot.promoted55 = load i32, ptr @tot, align 4, !tbaa !5
  %.not69 = icmp sgt i32 %L.promoted, %5
  br i1 %.not69, label %.preheader, label %.lr.ph64.preheader

.lr.ph64.preheader:                               ; preds = %4
  %10 = sext i32 %L.promoted to i64
  br label %.lr.ph64

..preheader_crit_edge:                            ; preds = %78
  %11 = trunc nsw i64 %indvars.iv.next77 to i32
  store i32 %11, ptr @L, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %..preheader_crit_edge, %4
  %12 = phi i32 [ %.lcssa5357, %..preheader_crit_edge ], [ %tot.promoted55, %4 ]
  %13 = icmp sgt i32 %12, 1
  br i1 %13, label %.lr.ph67, label %._crit_edge68

.lr.ph64:                                         ; preds = %.lr.ph64.preheader, %78
  %indvars.iv76 = phi i64 [ %10, %.lr.ph64.preheader ], [ %indvars.iv.next77, %78 ]
  %14 = phi i32 [ %8, %.lr.ph64.preheader ], [ %79, %78 ]
  %.lcssa535661 = phi i32 [ %tot.promoted55, %.lr.ph64.preheader ], [ %.lcssa5357, %78 ]
  %15 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %indvars.iv76
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = mul nsw i32 %16, 10
  %18 = srem i32 %17, %2
  %19 = add nsw i32 %18, 1
  %20 = srem i32 %19, %2
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %.preheader42, label %38

.preheader42:                                     ; preds = %.lr.ph64
  %21 = icmp eq i64 %indvars.iv76, -1
  br i1 %21, label %25, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader42
  %22 = sext i32 %.lcssa535661 to i64
  %23 = trunc nsw i64 %indvars.iv76 to i32
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %24 = trunc nsw i64 %indvars.iv.next to i32
  br label %25

25:                                               ; preds = %._crit_edge, %.preheader42
  %.lcssa5360 = phi i32 [ %24, %._crit_edge ], [ %.lcssa535661, %.preheader42 ]
  %26 = add nsw i32 %.lcssa5360, 1
  store i32 %26, ptr @tot, align 4, !tbaa !5
  %27 = sext i32 %.lcssa5360 to i64
  %28 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %27
  store i8 49, ptr %28, align 1, !tbaa !11
  br label %49

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %22, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.02845 = phi i32 [ 0, %.lr.ph.preheader ], [ %31, %.lr.ph ]
  %.02944 = phi i32 [ %23, %.lr.ph.preheader ], [ %37, %.lr.ph ]
  %29 = sext i32 %.02944 to i64
  %30 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = mul nsw i32 %31, 10
  %33 = srem i32 %32, %2
  %.not37 = icmp eq i32 %33, %.02845
  %34 = select i1 %.not37, i8 48, i8 49
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %35 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %indvars.iv
  store i8 %34, ptr %35, align 1, !tbaa !11
  %36 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %29
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %.not36 = icmp eq i32 %37, -1
  br i1 %.not36, label %._crit_edge, label %.lr.ph, !llvm.loop !12

38:                                               ; preds = %.lr.ph64
  %39 = sext i32 %18 to i64
  %40 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !9, !range !14, !noundef !15
  %42 = trunc nuw i8 %41 to i1
  br i1 %42, label %49, label %43

43:                                               ; preds = %38
  %44 = sext i32 %14 to i64
  %45 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %44
  store i32 %18, ptr %45, align 4, !tbaa !5
  store i8 1, ptr %40, align 1, !tbaa !9
  %46 = add nsw i32 %14, 1
  store i32 %46, ptr @R, align 4, !tbaa !5
  %47 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %44
  %48 = trunc nsw i64 %indvars.iv76 to i32
  store i32 %48, ptr %47, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %38, %43, %25
  %.lcssa5358 = phi i32 [ %.lcssa535661, %38 ], [ %.lcssa535661, %43 ], [ %26, %25 ]
  %50 = phi i32 [ %14, %38 ], [ %46, %43 ], [ %14, %25 ]
  %.not38 = icmp eq i32 %20, 0
  br i1 %.not38, label %.preheader41, label %67

.preheader41:                                     ; preds = %49
  %51 = icmp eq i64 %indvars.iv76, -1
  br i1 %51, label %55, label %.lr.ph51.preheader

.lr.ph51.preheader:                               ; preds = %.preheader41
  %52 = sext i32 %.lcssa5358 to i64
  %53 = trunc nsw i64 %indvars.iv76 to i32
  br label %.lr.ph51

._crit_edge52:                                    ; preds = %.lr.ph51
  %54 = trunc nsw i64 %indvars.iv.next74 to i32
  br label %55

55:                                               ; preds = %._crit_edge52, %.preheader41
  %.lcssa5359 = phi i32 [ %54, %._crit_edge52 ], [ %.lcssa5358, %.preheader41 ]
  %56 = add nsw i32 %.lcssa5359, 1
  store i32 %56, ptr @tot, align 4, !tbaa !5
  %57 = sext i32 %.lcssa5359 to i64
  %58 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %57
  store i8 49, ptr %58, align 1, !tbaa !11
  br label %78

.lr.ph51:                                         ; preds = %.lr.ph51.preheader, %.lr.ph51
  %indvars.iv73 = phi i64 [ %52, %.lr.ph51.preheader ], [ %indvars.iv.next74, %.lr.ph51 ]
  %.02750 = phi i32 [ %53, %.lr.ph51.preheader ], [ %.027, %.lr.ph51 ]
  %.02649 = phi i32 [ 0, %.lr.ph51.preheader ], [ %61, %.lr.ph51 ]
  %59 = sext i32 %.02750 to i64
  %60 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = mul nsw i32 %61, 10
  %63 = srem i32 %62, %2
  %.not40 = icmp eq i32 %63, %.02649
  %64 = select i1 %.not40, i8 48, i8 49
  %indvars.iv.next74 = add nsw i64 %indvars.iv73, 1
  %65 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %indvars.iv73
  store i8 %64, ptr %65, align 1, !tbaa !11
  %66 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %59
  %.027 = load i32, ptr %66, align 4, !tbaa !5
  %.not39 = icmp eq i32 %.027, -1
  br i1 %.not39, label %._crit_edge52, label %.lr.ph51, !llvm.loop !16

67:                                               ; preds = %49
  %68 = sext i32 %20 to i64
  %69 = getelementptr inbounds [1000001 x i8], ptr @vis, i64 0, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !9, !range !14, !noundef !15
  %71 = trunc nuw i8 %70 to i1
  br i1 %71, label %78, label %72

72:                                               ; preds = %67
  %73 = sext i32 %50 to i64
  %74 = getelementptr inbounds [1000001 x i32], ptr @que, i64 0, i64 %73
  store i32 %20, ptr %74, align 4, !tbaa !5
  store i8 1, ptr %69, align 1, !tbaa !9
  %75 = add nsw i32 %50, 1
  store i32 %75, ptr @R, align 4, !tbaa !5
  %76 = getelementptr inbounds [1000001 x i32], ptr @pre, i64 0, i64 %73
  %77 = trunc nsw i64 %indvars.iv76 to i32
  store i32 %77, ptr %76, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %67, %72, %55
  %.lcssa5357 = phi i32 [ %.lcssa5358, %67 ], [ %.lcssa5358, %72 ], [ %56, %55 ]
  %79 = phi i32 [ %50, %67 ], [ %75, %72 ], [ %50, %55 ]
  %indvars.iv.next77 = add nsw i64 %indvars.iv76, 1
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv.next77, %80
  br i1 %81, label %.lr.ph64, label %..preheader_crit_edge, !llvm.loop !17

.lr.ph67:                                         ; preds = %.preheader, %.lr.ph67
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %.lr.ph67 ], [ 0, %.preheader ]
  %82 = phi i32 [ %89, %.lr.ph67 ], [ %12, %.preheader ]
  %83 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %indvars.iv79
  %84 = trunc nuw nsw i64 %indvars.iv79 to i32
  %85 = xor i32 %84, -1
  %86 = add i32 %82, %85
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1000001 x i8], ptr @ans, i64 0, i64 %87
  tail call void @_ZSt4swapIcENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1) %83, ptr noundef nonnull align 1 dereferenceable(1) %88) #3
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %89 = load i32, ptr @tot, align 4, !tbaa !5
  %90 = ashr i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = icmp slt i64 %indvars.iv.next80, %91
  br i1 %92, label %.lr.ph67, label %._crit_edge68, !llvm.loop !18

._crit_edge68:                                    ; preds = %.lr.ph67, %.preheader, %0
  %ans.sink = phi ptr [ @.str.1, %0 ], [ @ans, %.preheader ], [ @ans, %.lr.ph67 ]
  %93 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %ans.sink)
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIcENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}
!18 = distinct !{!18, !13}


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