; LLVM IR from viveakrt/Competitive-programing :: SPOJ (dquery)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@root = external dso_local global [1000001 x i32], align 16
@res = external dso_local global [1000001 x i32], align 16
@lst = external dso_local global [1000001 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5clonei(i32 noundef) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4readiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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
  store i32 0, ptr %1, align 4
  %6 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %8 = getelementptr i8, ptr %7, i64 -24
  %9 = load i64, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %9
  %11 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %10, ptr noundef null)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !8
  br label %13

13:                                               ; preds = %23, %0
  %14 = load i32, ptr %2, align 4, !tbaa !8
  %15 = load i32, ptr @n, align 4, !tbaa !8
  %16 = icmp sle i32 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %26

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !8
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1000001 x i32], ptr @res, i64 0, i64 %20
  %22 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %21)
  br label %23

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !8
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !8
  br label %13, !llvm.loop !11

26:                                               ; preds = %17
  %27 = load i32, ptr @n, align 4, !tbaa !8
  call void @_Z5buildiii(i32 noundef 1, i32 noundef %27, i32 noundef 1)
  store i32 1, ptr @root, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !8
  br label %28

28:                                               ; preds = %96, %26
  %29 = load i32, ptr %3, align 4, !tbaa !8
  %30 = load i32, ptr @n, align 4, !tbaa !8
  %31 = icmp sle i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %99

33:                                               ; preds = %28
  %34 = load i32, ptr @n, align 4, !tbaa !8
  %35 = load i32, ptr %3, align 4, !tbaa !8
  %36 = mul nsw i32 %35, 2
  %37 = sub nsw i32 %36, 2
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !8
  %41 = load i32, ptr %3, align 4, !tbaa !8
  %42 = call noundef i32 @_Z6updateiiiii(i32 noundef 1, i32 noundef %34, i32 noundef %40, i32 noundef %41, i32 noundef 1)
  %43 = load i32, ptr %3, align 4, !tbaa !8
  %44 = mul nsw i32 %43, 2
  %45 = sub nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %46
  store i32 %42, ptr %47, align 4, !tbaa !8
  %48 = load i32, ptr %3, align 4, !tbaa !8
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1000001 x i32], ptr @res, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !8
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1000001 x i32], ptr @lst, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !8
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %76

56:                                               ; preds = %33
  %57 = load i32, ptr @n, align 4, !tbaa !8
  %58 = load i32, ptr %3, align 4, !tbaa !8
  %59 = mul nsw i32 %58, 2
  %60 = sub nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !8
  %64 = load i32, ptr %3, align 4, !tbaa !8
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1000001 x i32], ptr @res, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !8
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1000001 x i32], ptr @lst, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !8
  %71 = call noundef i32 @_Z6updateiiiii(i32 noundef 1, i32 noundef %57, i32 noundef %63, i32 noundef %70, i32 noundef -1)
  %72 = load i32, ptr %3, align 4, !tbaa !8
  %73 = mul nsw i32 %72, 2
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %74
  store i32 %71, ptr %75, align 4, !tbaa !8
  br label %88

76:                                               ; preds = %33
  %77 = load i32, ptr %3, align 4, !tbaa !8
  %78 = mul nsw i32 %77, 2
  %79 = sub nsw i32 %78, 1
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !8
  %83 = call noundef i32 @_Z5clonei(i32 noundef %82)
  %84 = load i32, ptr %3, align 4, !tbaa !8
  %85 = mul nsw i32 %84, 2
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %86
  store i32 %83, ptr %87, align 4, !tbaa !8
  br label %88

88:                                               ; preds = %76, %56
  %89 = load i32, ptr %3, align 4, !tbaa !8
  %90 = load i32, ptr %3, align 4, !tbaa !8
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1000001 x i32], ptr @res, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !8
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [1000001 x i32], ptr @lst, i64 0, i64 %94
  store i32 %89, ptr %95, align 4, !tbaa !8
  br label %96

96:                                               ; preds = %88
  %97 = load i32, ptr %3, align 4, !tbaa !8
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %3, align 4, !tbaa !8
  br label %28, !llvm.loop !13

99:                                               ; preds = %32
  %100 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @q)
  br label %101

101:                                              ; preds = %105, %99
  %102 = load i32, ptr @q, align 4, !tbaa !8
  %103 = add nsw i32 %102, -1
  store i32 %103, ptr @q, align 4, !tbaa !8
  %104 = icmp ne i32 %102, 0
  br i1 %104, label %105, label %119

105:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %106 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %107 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %106, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %108 = load i32, ptr @n, align 4, !tbaa !8
  %109 = load i32, ptr %5, align 4, !tbaa !8
  %110 = mul nsw i32 %109, 2
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !8
  %114 = load i32, ptr %4, align 4, !tbaa !8
  %115 = load i32, ptr %5, align 4, !tbaa !8
  %116 = call noundef i32 @_Z4readiiiii(i32 noundef 1, i32 noundef %108, i32 noundef %113, i32 noundef %114, i32 noundef %115)
  %117 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %116)
  %118 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %117, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %101, !llvm.loop !14

119:                                              ; preds = %101
  %120 = load i32, ptr %1, align 4
  ret i32 %120
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #4

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #0 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@root = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@res = external dso_local global [1000001 x i32], align 16
@lst = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiii(i32 noundef, i32 noundef, i32 noundef) 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %4 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %6
  %8 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %7, ptr noundef null)
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %10 = load i32, ptr @n, align 4, !tbaa !8
  %.not24 = icmp slt i32 %10, 1
  br i1 %.not24, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i32 [ %10, %0 ], [ %14, %.lr.ph ]
  tail call void @_Z5buildiii(i32 noundef 1, i32 noundef %.lcssa, i32 noundef 1)
  store i32 1, ptr @root, align 16, !tbaa !8
  %11 = load i32, ptr @n, align 4, !tbaa !8
  %.not2126 = icmp slt i32 %11, 1
  br i1 %.not2126, label %._crit_edge30, label %.lr.ph29

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %12 = getelementptr inbounds [1000001 x i32], ptr @res, i64 0, i64 %indvars.iv
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr @n, align 4, !tbaa !8
  %15 = sext i32 %14 to i64
  %.not.not = icmp slt i64 %indvars.iv, %15
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge30:                                    ; preds = %38, %._crit_edge
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @q)
  %17 = load i32, ptr @q, align 4, !tbaa !8
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr @q, align 4, !tbaa !8
  %.not2231 = icmp eq i32 %17, 0
  br i1 %.not2231, label %._crit_edge34, label %.lr.ph33

.lr.ph29:                                         ; preds = %._crit_edge, %38
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %38 ], [ 1, %._crit_edge ]
  %19 = phi i32 [ %43, %38 ], [ %11, %._crit_edge ]
  %20 = shl nuw nsw i64 %indvars.iv37, 1
  %21 = add nsw i64 %20, -2
  %22 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %21
  %23 = load i32, ptr %22, align 8, !tbaa !8
  %24 = trunc nuw nsw i64 %indvars.iv37 to i32
  %25 = tail call noundef i32 @_Z6updateiiiii(i32 noundef 1, i32 noundef %19, i32 noundef %23, i32 noundef %24, i32 noundef 1)
  %26 = add nsw i64 %20, -1
  %27 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %26
  store i32 %25, ptr %27, align 4, !tbaa !8
  %28 = getelementptr inbounds [1000001 x i32], ptr @res, i64 0, i64 %indvars.iv37
  %29 = load i32, ptr %28, align 4, !tbaa !8
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [1000001 x i32], ptr @lst, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !8
  %.not23 = icmp eq i32 %32, 0
  br i1 %.not23, label %36, label %33

33:                                               ; preds = %.lr.ph29
  %34 = load i32, ptr @n, align 4, !tbaa !8
  %35 = tail call noundef i32 @_Z6updateiiiii(i32 noundef 1, i32 noundef %34, i32 noundef %25, i32 noundef %32, i32 noundef -1)
  br label %38

36:                                               ; preds = %.lr.ph29
  %37 = tail call noundef i32 @_Z5clonei(i32 noundef %25)
  br label %38

38:                                               ; preds = %36, %33
  %.sink = phi i32 [ %37, %36 ], [ %35, %33 ]
  %39 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %20
  store i32 %.sink, ptr %39, align 8
  %40 = load i32, ptr %28, align 4, !tbaa !8
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [1000001 x i32], ptr @lst, i64 0, i64 %41
  store i32 %24, ptr %42, align 4, !tbaa !8
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %43 = load i32, ptr @n, align 4, !tbaa !8
  %44 = sext i32 %43 to i64
  %.not21.not = icmp slt i64 %indvars.iv37, %44
  br i1 %.not21.not, label %.lr.ph29, label %._crit_edge30, !llvm.loop !13

.lr.ph33:                                         ; preds = %._crit_edge30, %.lr.ph33
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %45, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %47 = load i32, ptr @n, align 4, !tbaa !8
  %48 = load i32, ptr %2, align 4, !tbaa !8
  %49 = shl nsw i32 %48, 1
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1000001 x i32], ptr @root, i64 0, i64 %50
  %52 = load i32, ptr %51, align 8, !tbaa !8
  %53 = load i32, ptr %1, align 4, !tbaa !8
  %54 = call noundef i32 @_Z4readiiiii(i32 noundef 1, i32 noundef %47, i32 noundef %52, i32 noundef %53, i32 noundef %48)
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %54)
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %55, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %57 = load i32, ptr @q, align 4, !tbaa !8
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr @q, align 4, !tbaa !8
  %.not22 = icmp eq i32 %57, 0
  br i1 %.not22, label %._crit_edge34, label %.lr.ph33, !llvm.loop !14

._crit_edge34:                                    ; preds = %.lr.ph33, %._crit_edge30
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #0 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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