; LLVM IR from DionysiosB/CodeForces :: 0200-0299 (265B-RoadSideTreesSimplifiedEdition)

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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 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 i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = load i64, ptr %4, align 8, !tbaa !9
  %12 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %11, i64 4)
  %13 = extractvalue { i64, i1 } %12, 1
  %14 = extractvalue { i64, i1 } %12, 0
  %15 = select i1 %13, i64 -1, i64 %14
  %16 = call noalias noundef nonnull ptr @_Znam(i64 noundef %15) #6
  store ptr %16, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %27, %0
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = load i64, ptr %4, align 8, !tbaa !9
  %20 = icmp slt i64 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %30

22:                                               ; preds = %17
  %23 = load ptr, ptr %5, align 8, !tbaa !11
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = getelementptr inbounds i32, ptr %23, i64 %24
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %25)
  br label %27

27:                                               ; preds = %22
  %28 = load i64, ptr %6, align 8, !tbaa !9
  %29 = add nsw i64 %28, 1
  store i64 %29, ptr %6, align 8, !tbaa !9
  br label %17, !llvm.loop !13

30:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 -1, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %77, %30
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = load i64, ptr %4, align 8, !tbaa !9
  %35 = icmp slt i64 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %80

37:                                               ; preds = %31
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !11
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %39, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp sgt i32 %38, %43
  br i1 %44, label %45, label %57

45:                                               ; preds = %37
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !11
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sub nsw i32 %46, %51
  %53 = add nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr %8, align 8, !tbaa !9
  %56 = add nsw i64 %55, %54
  store i64 %56, ptr %8, align 8, !tbaa !9
  br label %69

57:                                               ; preds = %37
  %58 = load ptr, ptr %5, align 8, !tbaa !11
  %59 = load i32, ptr %9, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i32, ptr %58, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = add nsw i32 1, %62
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = sub nsw i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = load i64, ptr %8, align 8, !tbaa !9
  %68 = add nsw i64 %67, %66
  store i64 %68, ptr %8, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %57, %45
  %70 = load ptr, ptr %5, align 8, !tbaa !11
  %71 = load i32, ptr %9, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %70, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  store i32 %74, ptr %7, align 4, !tbaa !5
  %75 = load i64, ptr %8, align 8, !tbaa !9
  %76 = add nsw i64 %75, 1
  store i64 %76, ptr %8, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %69
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %9, align 4, !tbaa !5
  br label %31, !llvm.loop !15

80:                                               ; preds = %36
  %81 = load i64, ptr %8, align 8, !tbaa !9
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %81)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = icmp ugt i64 %3, 4611686018427387903
  %5 = shl i64 %3, 2
  %6 = select i1 %4, i64 -1, i64 %5
  %7 = call noalias noundef nonnull ptr @_Znam(i64 noundef %6) #6
  %8 = icmp sgt i64 %3, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %9 = icmp sgt i64 %37, 0
  br i1 %9, label %.lr.ph30.preheader, label %._crit_edge

.lr.ph30.preheader:                               ; preds = %.preheader
  %min.iters.check = icmp ult i64 %37, 4
  br i1 %min.iters.check, label %.lr.ph30.preheader40, label %vector.ph

.lr.ph30.preheader40:                             ; preds = %middle.block, %.lr.ph30.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph30.preheader ], [ %n.vec, %middle.block ]
  %.02028.ph = phi i64 [ -1, %.lr.ph30.preheader ], [ %33, %middle.block ]
  %.02127.ph = phi i32 [ 0, %.lr.ph30.preheader ], [ %vector.recur.extract, %middle.block ]
  br label %.lr.ph30

vector.ph:                                        ; preds = %.lr.ph30.preheader
  %n.vec = and i64 %37, 9223372036854775804
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ <i64 -1, i64 0>, %vector.ph ], [ %30, %vector.body ]
  %vec.phi38 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %31, %vector.body ]
  %vector.recur = phi <2 x i32> [ <i32 poison, i32 0>, %vector.ph ], [ %wide.load39, %vector.body ]
  %10 = getelementptr inbounds i32, ptr %7, i64 %index
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %wide.load = load <2 x i32>, ptr %10, align 4, !tbaa !9
  %wide.load39 = load <2 x i32>, ptr %11, align 4, !tbaa !9
  %12 = shufflevector <2 x i32> %vector.recur, <2 x i32> %wide.load, <2 x i32> <i32 1, i32 2>
  %13 = shufflevector <2 x i32> %wide.load, <2 x i32> %wide.load39, <2 x i32> <i32 1, i32 2>
  %14 = icmp sgt <2 x i32> %12, %wide.load
  %15 = icmp sgt <2 x i32> %13, %wide.load39
  %16 = add <2 x i32> %12, <i32 1, i32 1>
  %17 = add <2 x i32> %13, <i32 1, i32 1>
  %18 = sub <2 x i32> %16, %wide.load
  %19 = sub <2 x i32> %17, %wide.load39
  %20 = sub <2 x i32> %wide.load, %12
  %21 = sub <2 x i32> %wide.load39, %13
  %22 = add <2 x i32> %20, <i32 1, i32 1>
  %23 = add <2 x i32> %21, <i32 1, i32 1>
  %24 = select <2 x i1> %14, <2 x i32> %18, <2 x i32> %22
  %25 = select <2 x i1> %15, <2 x i32> %19, <2 x i32> %23
  %26 = sext <2 x i32> %24 to <2 x i64>
  %27 = sext <2 x i32> %25 to <2 x i64>
  %28 = add <2 x i64> %vec.phi, <i64 1, i64 1>
  %29 = add <2 x i64> %vec.phi38, <i64 1, i64 1>
  %30 = add <2 x i64> %28, %26
  %31 = add <2 x i64> %29, %27
  %index.next = add nuw i64 %index, 4
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %31, %30
  %33 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %vector.recur.extract = extractelement <2 x i32> %wide.load39, i64 1
  %cmp.n = icmp eq i64 %37, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph30.preheader40

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.02226 = phi i64 [ %36, %.lr.ph ], [ 0, %0 ]
  %34 = getelementptr inbounds i32, ptr %7, i64 %.02226
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %34)
  %36 = add nuw nsw i64 %.02226, 1
  %37 = load i64, ptr %1, align 8, !tbaa !5
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %.lr.ph, label %.preheader, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph30, %middle.block, %0, %.preheader
  %.020.lcssa = phi i64 [ -1, %.preheader ], [ -1, %0 ], [ %33, %middle.block ], [ %46, %.lr.ph30 ]
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.020.lcssa)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 0

.lr.ph30:                                         ; preds = %.lr.ph30.preheader40, %.lr.ph30
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph30 ], [ %indvars.iv.ph, %.lr.ph30.preheader40 ]
  %.02028 = phi i64 [ %46, %.lr.ph30 ], [ %.02028.ph, %.lr.ph30.preheader40 ]
  %.02127 = phi i32 [ %41, %.lr.ph30 ], [ %.02127.ph, %.lr.ph30.preheader40 ]
  %40 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = icmp sgt i32 %.02127, %41
  %43 = add i32 %.02127, 1
  %44 = sub i32 %43, %41
  %reass.sub = sub i32 %41, %.02127
  %45 = add i32 %reass.sub, 1
  %.pn.in = select i1 %42, i32 %44, i32 %45
  %.pn = sext i32 %.pn.in to i64
  %.1 = add i64 %.02028, 1
  %46 = add i64 %.1, %.pn
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %37
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph30, !llvm.loop !16
}

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #3

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #4

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nobuiltin allocsize(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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12, !14, !13}


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