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

; 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.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@A = external dso_local global i32, align 4
@B = external dso_local global i32, align 4
@C = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@top = external dso_local global i32, align 4
@stk = external dso_local global [10000001 x i32], align 16
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@sL = external dso_local global i32, align 4
@sR = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@que = external dso_local global [10000001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 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 %"struct.std::pair", align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @A, ptr noundef @B, ptr noundef @C, ptr noundef @x, ptr noundef @a, ptr noundef @b, ptr noundef @p)
  br label %6

6:                                                ; preds = %157, %0
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr @n, align 4, !tbaa !5
  %9 = icmp ne i32 %7, 0
  br i1 %9, label %10, label %158

10:                                               ; preds = %6
  %11 = load i32, ptr @a, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = load i32, ptr @x, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = mul nsw i64 %12, %14
  %16 = load i32, ptr @b, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = add nsw i64 %15, %17
  %19 = load i32, ptr @p, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = srem i64 %18, %20
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr @x, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  %23 = load i32, ptr @x, align 4, !tbaa !5
  %24 = load i32, ptr @A, align 4, !tbaa !5
  %25 = load i32, ptr @B, align 4, !tbaa !5
  %26 = add nsw i32 %24, %25
  %27 = load i32, ptr @C, align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  %29 = srem i32 %23, %28
  store i32 %29, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr @top, align 4, !tbaa !5
  %31 = load i32, ptr @R, align 4, !tbaa !5
  %32 = add nsw i32 %30, %31
  %33 = load i32, ptr @L, align 4, !tbaa !5
  %34 = sub nsw i32 %32, %33
  %35 = icmp sle i32 %34, 1
  br i1 %35, label %40, label %36

36:                                               ; preds = %10
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = load i32, ptr @A, align 4, !tbaa !5
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %52

40:                                               ; preds = %36, %10
  %41 = load i32, ptr @top, align 4, !tbaa !5
  %42 = sub nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %43
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @x, ptr noundef nonnull align 4 dereferenceable(4) %44)
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr @top, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %48
  store i32 %46, ptr %49, align 4, !tbaa !5
  %50 = load i32, ptr @top, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr @top, align 4, !tbaa !5
  br label %108

52:                                               ; preds = %36
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = load i32, ptr @A, align 4, !tbaa !5
  %55 = load i32, ptr @B, align 4, !tbaa !5
  %56 = add nsw i32 %54, %55
  %57 = icmp slt i32 %53, %56
  br i1 %57, label %58, label %87

58:                                               ; preds = %52
  br label %59

59:                                               ; preds = %75, %58
  %60 = load i32, ptr @sL, align 4, !tbaa !5
  %61 = load i32, ptr @sR, align 4, !tbaa !5
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %63, label %72

63:                                               ; preds = %59
  %64 = load i32, ptr @sR, align 4, !tbaa !5
  %65 = sub nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %66
  %68 = getelementptr inbounds %"struct.std::pair", ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 8, !tbaa !9
  %70 = load i32, ptr @x, align 4, !tbaa !5
  %71 = icmp slt i32 %69, %70
  br label %72

72:                                               ; preds = %63, %59
  %73 = phi i1 [ false, %59 ], [ %71, %63 ]
  br i1 %73, label %74, label %78

74:                                               ; preds = %72
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr @sR, align 4, !tbaa !5
  %77 = add nsw i32 %76, -1
  store i32 %77, ptr @sR, align 4, !tbaa !5
  br label %59, !llvm.loop !11

78:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %79 = load i32, ptr @R, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr @R, align 4, !tbaa !5
  store i32 %79, ptr %4, align 4, !tbaa !5
  %81 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) @x, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store i64 %81, ptr %3, align 4
  %82 = load i32, ptr @sR, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr @sR, align 4, !tbaa !5
  %84 = sext i32 %82 to i64
  %85 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %84
  %86 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %85, ptr noundef nonnull align 4 dereferenceable(8) %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %107

87:                                               ; preds = %52
  %88 = load i32, ptr @top, align 4, !tbaa !5
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %93

90:                                               ; preds = %87
  %91 = load i32, ptr @top, align 4, !tbaa !5
  %92 = add nsw i32 %91, -1
  store i32 %92, ptr @top, align 4, !tbaa !5
  br label %106

93:                                               ; preds = %87
  %94 = load i32, ptr @sL, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %95
  %97 = getelementptr inbounds %"struct.std::pair", ptr %96, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !13
  %99 = load i32, ptr @L, align 4, !tbaa !5
  %100 = icmp eq i32 %98, %99
  %101 = zext i1 %100 to i32
  %102 = load i32, ptr @sL, align 4, !tbaa !5
  %103 = add nsw i32 %102, %101
  store i32 %103, ptr @sL, align 4, !tbaa !5
  %104 = load i32, ptr @L, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr @L, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %93, %90
  br label %107

107:                                              ; preds = %106, %78
  br label %108

108:                                              ; preds = %107, %40
  %109 = load i32, ptr @L, align 4, !tbaa !5
  %110 = load i32, ptr @R, align 4, !tbaa !5
  %111 = icmp eq i32 %109, %110
  br i1 %111, label %127, label %112

112:                                              ; preds = %108
  %113 = load i32, ptr @top, align 4, !tbaa !5
  %114 = icmp ne i32 %113, 0
  br i1 %114, label %115, label %142

115:                                              ; preds = %112
  %116 = load i32, ptr @top, align 4, !tbaa !5
  %117 = sub nsw i32 %116, 1
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = load i32, ptr @sL, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %122
  %124 = getelementptr inbounds %"struct.std::pair", ptr %123, i32 0, i32 0
  %125 = load i32, ptr %124, align 8, !tbaa !9
  %126 = icmp sgt i32 %120, %125
  br i1 %126, label %127, label %142

127:                                              ; preds = %115, %108
  %128 = load i32, ptr @top, align 4, !tbaa !5
  %129 = sub nsw i32 %128, 1
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = load i32, ptr @ans, align 4, !tbaa !5
  %134 = add nsw i32 %133, %132
  store i32 %134, ptr @ans, align 4, !tbaa !5
  %135 = icmp sge i32 %134, 1000000007
  br i1 %135, label %136, label %140

136:                                              ; preds = %127
  %137 = load i32, ptr @ans, align 4, !tbaa !5
  %138 = sub nsw i32 %137, 1000000007
  store i32 %138, ptr @ans, align 4, !tbaa !5
  %139 = icmp ne i32 %138, 0
  br label %140

140:                                              ; preds = %136, %127
  %141 = phi i1 [ false, %127 ], [ %139, %136 ]
  br label %157

142:                                              ; preds = %115, %112
  %143 = load i32, ptr @sL, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %144
  %146 = getelementptr inbounds %"struct.std::pair", ptr %145, i32 0, i32 0
  %147 = load i32, ptr %146, align 8, !tbaa !9
  %148 = load i32, ptr @ans, align 4, !tbaa !5
  %149 = add nsw i32 %148, %147
  store i32 %149, ptr @ans, align 4, !tbaa !5
  %150 = icmp sge i32 %149, 1000000007
  br i1 %150, label %151, label %155

151:                                              ; preds = %142
  %152 = load i32, ptr @ans, align 4, !tbaa !5
  %153 = sub nsw i32 %152, 1000000007
  store i32 %153, ptr @ans, align 4, !tbaa !5
  %154 = icmp ne i32 %153, 0
  br label %155

155:                                              ; preds = %151, %142
  %156 = phi i1 [ false, %142 ], [ %154, %151 ]
  br label %157

157:                                              ; preds = %155, %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %6, !llvm.loop !14

158:                                              ; preds = %6
  %159 = load i32, ptr @ans, align 4, !tbaa !5
  %160 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %159)
  ret i32 0
}

declare i32 @__isoc99_scanf(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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #5 align 2

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

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

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 = { 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 = { 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 = { 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 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !6, i64 4}
!14 = distinct !{!14, !12}


; 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.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@A = external dso_local global i32, align 4
@B = external dso_local global i32, align 4
@C = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@top = external dso_local local_unnamed_addr global i32, align 4
@stk = external dso_local global [10000001 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
@sL = external dso_local local_unnamed_addr global i32, align 4
@sR = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [10000001 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @A, ptr noundef nonnull @B, ptr noundef nonnull @C, ptr noundef nonnull @x, ptr noundef nonnull @a, ptr noundef nonnull @b, ptr noundef nonnull @p)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @n, align 4, !tbaa !5
  %.not10 = icmp eq i32 %4, 0
  br i1 %.not10, label %.._crit_edge_crit_edge, label %.lr.ph11.preheader

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre21 = load i32, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge

.lr.ph11.preheader:                               ; preds = %0
  %.pre = load i32, ptr @top, align 4, !tbaa !5
  %.pre13 = load i32, ptr @R, align 4, !tbaa !5
  %.pre14 = load i32, ptr @L, align 4, !tbaa !5
  br label %.lr.ph11

.lr.ph11:                                         ; preds = %.lr.ph11.preheader, %106
  %.pre1922 = phi i32 [ %.pre, %.lr.ph11.preheader ], [ %.pre1929, %106 ]
  %6 = phi i32 [ %.pre14, %.lr.ph11.preheader ], [ %108, %106 ]
  %7 = phi i32 [ %.pre13, %.lr.ph11.preheader ], [ %107, %106 ]
  %8 = load i32, ptr @a, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = load i32, ptr @x, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = mul nsw i64 %11, %9
  %13 = load i32, ptr @b, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = add nsw i64 %12, %14
  %16 = load i32, ptr @p, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = srem i64 %15, %17
  %19 = trunc nsw i64 %18 to i32
  store i32 %19, ptr @x, align 4, !tbaa !5
  %20 = load i32, ptr @A, align 4, !tbaa !5
  %21 = load i32, ptr @B, align 4, !tbaa !5
  %22 = add nsw i32 %21, %20
  %23 = load i32, ptr @C, align 4, !tbaa !5
  %24 = add nsw i32 %22, %23
  %25 = srem i32 %19, %24
  %26 = add nsw i32 %7, %.pre1922
  %27 = sub i32 %26, %6
  %28 = icmp slt i32 %27, 2
  %29 = icmp slt i32 %25, %20
  %or.cond = select i1 %28, i1 true, i1 %29
  br i1 %or.cond, label %30, label %40

30:                                               ; preds = %.lr.ph11
  %31 = add nsw i32 %.pre1922, -1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %32
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @x, ptr noundef nonnull align 4 dereferenceable(4) %33)
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = load i32, ptr @top, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %37
  store i32 %35, ptr %38, align 4, !tbaa !5
  %39 = add nsw i32 %36, 1
  store i32 %39, ptr @top, align 4, !tbaa !5
  br label %62

40:                                               ; preds = %.lr.ph11
  %41 = icmp slt i32 %25, %22
  br i1 %41, label %.preheader, label %59

.preheader:                                       ; preds = %40
  %42 = load i32, ptr @sL, align 4, !tbaa !5
  %sR.promoted = load i32, ptr @sR, align 4, !tbaa !5
  %43 = icmp slt i32 %42, %sR.promoted
  br i1 %43, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %.preheader
  %44 = sext i32 %sR.promoted to i64
  %45 = sext i32 %42 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %49
  %indvars.iv = phi i64 [ %44, %.lr.ph.preheader ], [ %indvars.iv.next, %49 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %46 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %indvars.iv.next
  %47 = load i32, ptr %46, align 8, !tbaa !9
  %48 = icmp slt i32 %47, %19
  br i1 %48, label %49, label %.critedge

49:                                               ; preds = %.lr.ph
  %50 = trunc nsw i64 %indvars.iv.next to i32
  store i32 %50, ptr @sR, align 4, !tbaa !5
  %51 = icmp sgt i64 %indvars.iv.next, %45
  br i1 %51, label %.lr.ph, label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %.lr.ph, %49, %.preheader
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %52 = add nsw i32 %7, 1
  store i32 %52, ptr @R, align 4, !tbaa !5
  store i32 %7, ptr %2, align 4, !tbaa !5
  %53 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) @x, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store i64 %53, ptr %1, align 8
  %54 = load i32, ptr @sR, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr @sR, align 4, !tbaa !5
  %56 = sext i32 %54 to i64
  %57 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %56
  %58 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %57, ptr noundef nonnull align 4 dereferenceable(8) %1) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %.pre19.pre = load i32, ptr @top, align 4, !tbaa !5
  br label %62

59:                                               ; preds = %40
  %.not7 = icmp eq i32 %.pre1922, 0
  br i1 %.not7, label %.thread, label %60

60:                                               ; preds = %59
  %61 = add nsw i32 %.pre1922, -1
  store i32 %61, ptr @top, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %.critedge, %60, %30
  %.pre19 = phi i32 [ %.pre19.pre, %.critedge ], [ %61, %60 ], [ %39, %30 ]
  %63 = load i32, ptr @L, align 4, !tbaa !5
  %64 = load i32, ptr @R, align 4, !tbaa !5
  %65 = icmp eq i32 %63, %64
  br i1 %65, label %._crit_edge20, label %78

.thread:                                          ; preds = %59
  %66 = load i32, ptr @sL, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %67, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !13
  %70 = icmp eq i32 %69, %6
  %71 = zext i1 %70 to i32
  %72 = add nsw i32 %66, %71
  store i32 %72, ptr @sL, align 4, !tbaa !5
  %73 = add nsw i32 %6, 1
  store i32 %73, ptr @L, align 4, !tbaa !5
  %74 = load i32, ptr @R, align 4, !tbaa !5
  %75 = icmp eq i32 %73, %74
  br i1 %75, label %._crit_edge20, label %.thread33

.thread33:                                        ; preds = %.thread
  %.pre1536 = load i32, ptr @sL, align 4, !tbaa !5
  br label %._crit_edge16

._crit_edge20:                                    ; preds = %.thread, %62
  %76 = phi i32 [ %74, %.thread ], [ %64, %62 ]
  %77 = phi i32 [ %73, %.thread ], [ %63, %62 ]
  %.pre1932 = phi i32 [ 0, %.thread ], [ %.pre19, %62 ]
  %.pre24 = add nsw i32 %.pre1932, -1
  %.pre25 = sext i32 %.pre24 to i64
  br label %90

78:                                               ; preds = %62
  %.not8 = icmp eq i32 %.pre19, 0
  %.pre15 = load i32, ptr @sL, align 4, !tbaa !5
  br i1 %.not8, label %._crit_edge16, label %81

._crit_edge16:                                    ; preds = %.thread33, %78
  %.pre1539 = phi i32 [ %.pre1536, %.thread33 ], [ %.pre15, %78 ]
  %79 = phi i32 [ %73, %.thread33 ], [ %63, %78 ]
  %80 = phi i32 [ %74, %.thread33 ], [ %64, %78 ]
  %.phi.trans.insert = sext i32 %.pre1539 to i64
  %.phi.trans.insert17 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %.phi.trans.insert
  %.pre18 = load i32, ptr %.phi.trans.insert17, align 8, !tbaa !9
  br label %98

81:                                               ; preds = %78
  %82 = add nsw i32 %.pre19, -1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = sext i32 %.pre15 to i64
  %87 = getelementptr inbounds [10000001 x %"struct.std::pair"], ptr @que, i64 0, i64 %86
  %88 = load i32, ptr %87, align 8, !tbaa !9
  %89 = icmp sgt i32 %85, %88
  br i1 %89, label %90, label %98

90:                                               ; preds = %._crit_edge20, %81
  %91 = phi i32 [ %76, %._crit_edge20 ], [ %64, %81 ]
  %92 = phi i32 [ %77, %._crit_edge20 ], [ %63, %81 ]
  %.pre1930 = phi i32 [ %.pre1932, %._crit_edge20 ], [ %.pre19, %81 ]
  %.pre-phi26 = phi i64 [ %.pre25, %._crit_edge20 ], [ %83, %81 ]
  %93 = getelementptr inbounds [10000001 x i32], ptr @stk, i64 0, i64 %.pre-phi26
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr @ans, align 4, !tbaa !5
  %96 = add nsw i32 %95, %94
  store i32 %96, ptr @ans, align 4, !tbaa !5
  %97 = icmp sgt i32 %96, 1000000006
  br i1 %97, label %.sink.split, label %106

98:                                               ; preds = %._crit_edge16, %81
  %.pre193137 = phi i32 [ 0, %._crit_edge16 ], [ %.pre19, %81 ]
  %99 = phi i32 [ %79, %._crit_edge16 ], [ %63, %81 ]
  %100 = phi i32 [ %80, %._crit_edge16 ], [ %64, %81 ]
  %101 = phi i32 [ %.pre18, %._crit_edge16 ], [ %88, %81 ]
  %102 = load i32, ptr @ans, align 4, !tbaa !5
  %103 = add nsw i32 %102, %101
  store i32 %103, ptr @ans, align 4, !tbaa !5
  %104 = icmp sgt i32 %103, 1000000006
  br i1 %104, label %.sink.split, label %106

.sink.split:                                      ; preds = %98, %90
  %.sink42 = phi i32 [ %96, %90 ], [ %103, %98 ]
  %.ph = phi i32 [ %91, %90 ], [ %100, %98 ]
  %.ph40 = phi i32 [ %92, %90 ], [ %99, %98 ]
  %.pre1929.ph = phi i32 [ %.pre1930, %90 ], [ %.pre193137, %98 ]
  %105 = add nsw i32 %.sink42, -1000000007
  store i32 %105, ptr @ans, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %.sink.split, %98, %90
  %107 = phi i32 [ %100, %98 ], [ %91, %90 ], [ %.ph, %.sink.split ]
  %108 = phi i32 [ %99, %98 ], [ %92, %90 ], [ %.ph40, %.sink.split ]
  %.pre1929 = phi i32 [ %.pre193137, %98 ], [ %.pre1930, %90 ], [ %.pre1929.ph, %.sink.split ]
  %109 = phi i32 [ %103, %98 ], [ %96, %90 ], [ %105, %.sink.split ]
  %110 = load i32, ptr @n, align 4, !tbaa !5
  %111 = add nsw i32 %110, -1
  store i32 %111, ptr @n, align 4, !tbaa !5
  %.not = icmp eq i32 %110, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph11, !llvm.loop !14

._crit_edge:                                      ; preds = %106, %.._crit_edge_crit_edge
  %112 = phi i32 [ %.pre21, %.._crit_edge_crit_edge ], [ %109, %106 ]
  %113 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %112)
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #5 align 2

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

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

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 = { 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 = { mustprogress 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 = { 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 = { 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 = { 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 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !6, i64 4}
!14 = distinct !{!14, !12}


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