; LLVM IR from DionysiosB/CodeForces :: 0200-0299 (205A-LittleElephantAndRozdil)

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

15:                                               ; preds = %25, %0
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %28

20:                                               ; preds = %15
  %21 = load ptr, ptr %3, align 8, !tbaa !9
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds i64, ptr %21, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %23)
  br label %25

25:                                               ; preds = %20
  %26 = load i64, ptr %4, align 8, !tbaa !5
  %27 = add nsw i64 %26, 1
  store i64 %27, ptr %4, align 8, !tbaa !5
  br label %15, !llvm.loop !11

28:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 1000000001, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 -1, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %58, %28
  %30 = load i64, ptr %7, align 8, !tbaa !5
  %31 = load i64, ptr %2, align 8, !tbaa !5
  %32 = icmp slt i64 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %61

34:                                               ; preds = %29
  %35 = load ptr, ptr %3, align 8, !tbaa !9
  %36 = load i64, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds i64, ptr %35, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !5
  %39 = load i64, ptr %5, align 8, !tbaa !5
  %40 = icmp slt i64 %38, %39
  br i1 %40, label %41, label %48

41:                                               ; preds = %34
  %42 = load ptr, ptr %3, align 8, !tbaa !9
  %43 = load i64, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds i64, ptr %42, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !5
  store i64 %45, ptr %5, align 8, !tbaa !5
  %46 = load i64, ptr %7, align 8, !tbaa !5
  %47 = add nsw i64 %46, 1
  store i64 %47, ptr %6, align 8, !tbaa !5
  br label %57

48:                                               ; preds = %34
  %49 = load ptr, ptr %3, align 8, !tbaa !9
  %50 = load i64, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds i64, ptr %49, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !5
  %53 = load i64, ptr %5, align 8, !tbaa !5
  %54 = icmp eq i64 %52, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %48
  store i64 -1, ptr %6, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %55, %48
  br label %57

57:                                               ; preds = %56, %41
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %7, align 8, !tbaa !5
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %7, align 8, !tbaa !5
  br label %29, !llvm.loop !13

61:                                               ; preds = %33
  %62 = load i64, ptr %6, align 8, !tbaa !5
  %63 = icmp eq i64 %62, -1
  br i1 %63, label %64, label %66

64:                                               ; preds = %61
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %69

66:                                               ; preds = %61
  %67 = load i64, ptr %6, align 8, !tbaa !5
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %67)
  br label %69

69:                                               ; preds = %66, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 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, 2305843009213693951
  %5 = shl i64 %3, 3
  %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.thread

.preheader:                                       ; preds = %.lr.ph
  %9 = icmp sgt i64 %14, 0
  br i1 %9, label %.lr.ph26.preheader, label %._crit_edge.thread

.lr.ph26.preheader:                               ; preds = %.preheader
  %xtraiter = and i64 %14, 1
  %10 = icmp eq i64 %14, 1
  br i1 %10, label %._crit_edge.unr-lcssa, label %.lr.ph26.preheader.new

.lr.ph26.preheader.new:                           ; preds = %.lr.ph26.preheader
  %unroll_iter = and i64 %14, 9223372036854775806
  br label %.lr.ph26

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01922 = phi i64 [ %13, %.lr.ph ], [ 0, %0 ]
  %11 = getelementptr inbounds i64, ptr %7, i64 %.01922
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %11)
  %13 = add nuw nsw i64 %.01922, 1
  %14 = load i64, ptr %1, align 8, !tbaa !5
  %15 = icmp slt i64 %13, %14
  br i1 %15, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph26, %.lr.ph26.preheader
  %.1.lcssa.ph = phi i64 [ poison, %.lr.ph26.preheader ], [ %.1.1, %.lr.ph26 ]
  %.025.unr = phi i64 [ 0, %.lr.ph26.preheader ], [ %30, %.lr.ph26 ]
  %.01624.unr = phi i64 [ -1, %.lr.ph26.preheader ], [ %.1.1, %.lr.ph26 ]
  %.01723.unr = phi i64 [ 1000000001, %.lr.ph26.preheader ], [ %.118.1, %.lr.ph26 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph26.epil

.lr.ph26.epil:                                    ; preds = %._crit_edge.unr-lcssa
  %16 = getelementptr inbounds i64, ptr %7, i64 %.025.unr
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = icmp slt i64 %17, %.01723.unr
  %19 = add nuw nsw i64 %.025.unr, 1
  %20 = icmp eq i64 %17, %.01723.unr
  %spec.select.epil = select i1 %20, i64 -1, i64 %.01624.unr
  %.1.epil = select i1 %18, i64 %19, i64 %spec.select.epil
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph26.epil
  %.1.lcssa = phi i64 [ %.1.lcssa.ph, %._crit_edge.unr-lcssa ], [ %.1.epil, %.lr.ph26.epil ]
  %21 = icmp eq i64 %.1.lcssa, -1
  br i1 %21, label %._crit_edge.thread, label %33

.lr.ph26:                                         ; preds = %.lr.ph26, %.lr.ph26.preheader.new
  %.025 = phi i64 [ 0, %.lr.ph26.preheader.new ], [ %30, %.lr.ph26 ]
  %.01624 = phi i64 [ -1, %.lr.ph26.preheader.new ], [ %.1.1, %.lr.ph26 ]
  %.01723 = phi i64 [ 1000000001, %.lr.ph26.preheader.new ], [ %.118.1, %.lr.ph26 ]
  %niter = phi i64 [ 0, %.lr.ph26.preheader.new ], [ %niter.next.1, %.lr.ph26 ]
  %22 = getelementptr inbounds i64, ptr %7, i64 %.025
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = icmp slt i64 %23, %.01723
  %25 = or disjoint i64 %.025, 1
  %26 = icmp eq i64 %23, %.01723
  %spec.select = select i1 %26, i64 -1, i64 %.01624
  %.118 = call i64 @llvm.smin.i64(i64 %23, i64 %.01723)
  %.1 = select i1 %24, i64 %25, i64 %spec.select
  %27 = getelementptr inbounds i64, ptr %7, i64 %25
  %28 = load i64, ptr %27, align 8, !tbaa !5
  %29 = icmp slt i64 %28, %.118
  %30 = add nuw nsw i64 %.025, 2
  %31 = icmp eq i64 %28, %.118
  %spec.select.1 = select i1 %31, i64 -1, i64 %.1
  %.118.1 = call i64 @llvm.smin.i64(i64 %28, i64 %.118)
  %.1.1 = select i1 %29, i64 %30, i64 %spec.select.1
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.unr-lcssa, label %.lr.ph26, !llvm.loop !11

._crit_edge.thread:                               ; preds = %0, %.preheader, %._crit_edge
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %35

33:                                               ; preds = %._crit_edge
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.1.lcssa)
  br label %35

35:                                               ; preds = %33, %._crit_edge.thread
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret i32 0
}

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

; Function Attrs: 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.smin.i64(i64, 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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