; LLVM IR from DionysiosB/CodeForces :: 1200-1299 (1204B-MisloveHasLostAnArray)

; 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 [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 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 i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = sub nsw i64 %10, %11
  %13 = add nsw i64 %12, 1
  store i64 %13, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 1, ptr %6, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %26, %0
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = load i64, ptr %3, align 8, !tbaa !5
  %17 = icmp slt i64 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %29

19:                                               ; preds = %14
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = trunc i64 %20 to i32
  %22 = shl i32 1, %21
  %23 = sext i32 %22 to i64
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = add nsw i64 %24, %23
  store i64 %25, ptr %5, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %19
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = add nsw i64 %27, 1
  store i64 %28, ptr %6, align 8, !tbaa !9
  br label %14, !llvm.loop !11

29:                                               ; preds = %18
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %31 = add nsw i64 %30, -1
  store i64 %31, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %52, %29
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = load i64, ptr %2, align 8, !tbaa !5
  %35 = icmp slt i64 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %55

37:                                               ; preds = %32
  %38 = load i64, ptr %8, align 8, !tbaa !9
  %39 = load i64, ptr %4, align 8, !tbaa !5
  %40 = icmp slt i64 %38, %39
  br i1 %40, label %41, label %43

41:                                               ; preds = %37
  %42 = load i64, ptr %8, align 8, !tbaa !9
  br label %45

43:                                               ; preds = %37
  %44 = load i64, ptr %4, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %43, %41
  %46 = phi i64 [ %42, %41 ], [ %44, %43 ]
  %47 = trunc i64 %46 to i32
  %48 = shl i32 1, %47
  %49 = sext i32 %48 to i64
  %50 = load i64, ptr %7, align 8, !tbaa !5
  %51 = add nsw i64 %50, %49
  store i64 %51, ptr %7, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %45
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %8, align 8, !tbaa !9
  br label %32, !llvm.loop !13

55:                                               ; preds = %36
  %56 = load i64, ptr %5, align 8, !tbaa !5
  %57 = load i64, ptr %7, align 8, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %56, i64 noundef %57)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  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 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 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !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 [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1

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

.lr.ph.preheader:                                 ; preds = %0
  %10 = add nsw i64 %6, -1
  %11 = add nsw i64 %6, -2
  %xtraiter = and i64 %10, 3
  %12 = icmp ult i64 %11, 3
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %10, -4
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa26.ph = phi i64 [ poison, %.lr.ph.preheader ], [ %40, %.lr.ph ]
  %.01215.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %41, %.lr.ph ]
  %.01314.unr = phi i64 [ %8, %.lr.ph.preheader ], [ %40, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.01215.epil = phi i64 [ %17, %.lr.ph.epil ], [ %.01215.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01314.epil = phi i64 [ %16, %.lr.ph.epil ], [ %.01314.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %13 = trunc i64 %.01215.epil to i32
  %14 = shl nuw i32 1, %13
  %15 = sext i32 %14 to i64
  %16 = add nsw i64 %.01314.epil, %15
  %17 = add nuw nsw i64 %.01215.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !9

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %0
  %.013.lcssa = phi i64 [ %8, %0 ], [ %.lcssa26.ph, %._crit_edge.loopexit.unr-lcssa ], [ %16, %.lr.ph.epil ]
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = add nsw i64 %18, -1
  store i64 %19, ptr %3, align 8, !tbaa !5
  %20 = icmp sgt i64 %5, 0
  br i1 %20, label %.lr.ph19.preheader, label %._crit_edge20

.lr.ph19.preheader:                               ; preds = %._crit_edge
  %xtraiter28 = and i64 %5, 3
  %21 = icmp ult i64 %5, 4
  br i1 %21, label %._crit_edge20.loopexit.unr-lcssa, label %.lr.ph19.preheader.new

.lr.ph19.preheader.new:                           ; preds = %.lr.ph19.preheader
  %unroll_iter32 = and i64 %5, 9223372036854775804
  br label %.lr.ph19

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.01215 = phi i64 [ 1, %.lr.ph.preheader.new ], [ %41, %.lr.ph ]
  %.01314 = phi i64 [ %8, %.lr.ph.preheader.new ], [ %40, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %22 = trunc i64 %.01215 to i32
  %23 = shl nuw i32 1, %22
  %24 = sext i32 %23 to i64
  %25 = add nsw i64 %.01314, %24
  %26 = trunc i64 %.01215 to i32
  %27 = add i32 %26, 1
  %28 = shl nuw i32 1, %27
  %29 = sext i32 %28 to i64
  %30 = add nsw i64 %25, %29
  %31 = trunc i64 %.01215 to i32
  %32 = add i32 %31, 2
  %33 = shl nuw i32 1, %32
  %34 = sext i32 %33 to i64
  %35 = add nsw i64 %30, %34
  %36 = trunc i64 %.01215 to i32
  %37 = add i32 %36, 3
  %38 = shl nuw i32 1, %37
  %39 = sext i32 %38 to i64
  %40 = add nsw i64 %35, %39
  %41 = add nuw nsw i64 %.01215, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge20.loopexit.unr-lcssa:                 ; preds = %.lr.ph19, %.lr.ph19.preheader
  %.lcssa.ph = phi i64 [ poison, %.lr.ph19.preheader ], [ %71, %.lr.ph19 ]
  %.017.unr = phi i64 [ 0, %.lr.ph19.preheader ], [ %72, %.lr.ph19 ]
  %.01116.unr = phi i64 [ 0, %.lr.ph19.preheader ], [ %71, %.lr.ph19 ]
  %lcmp.mod30.not = icmp eq i64 %xtraiter28, 0
  br i1 %lcmp.mod30.not, label %._crit_edge20, label %.lr.ph19.epil

.lr.ph19.epil:                                    ; preds = %._crit_edge20.loopexit.unr-lcssa, %.lr.ph19.epil
  %.017.epil = phi i64 [ %47, %.lr.ph19.epil ], [ %.017.unr, %._crit_edge20.loopexit.unr-lcssa ]
  %.01116.epil = phi i64 [ %46, %.lr.ph19.epil ], [ %.01116.unr, %._crit_edge20.loopexit.unr-lcssa ]
  %epil.iter29 = phi i64 [ %epil.iter29.next, %.lr.ph19.epil ], [ 0, %._crit_edge20.loopexit.unr-lcssa ]
  %42 = call i64 @llvm.smin.i64(i64 %.017.epil, i64 %19)
  %43 = trunc i64 %42 to i32
  %44 = shl nuw i32 1, %43
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %.01116.epil, %45
  %47 = add nuw nsw i64 %.017.epil, 1
  %epil.iter29.next = add i64 %epil.iter29, 1
  %epil.iter29.cmp.not = icmp eq i64 %epil.iter29.next, %xtraiter28
  br i1 %epil.iter29.cmp.not, label %._crit_edge20, label %.lr.ph19.epil, !llvm.loop !13

._crit_edge20:                                    ; preds = %._crit_edge20.loopexit.unr-lcssa, %.lr.ph19.epil, %._crit_edge
  %.011.lcssa = phi i64 [ 0, %._crit_edge ], [ %.lcssa.ph, %._crit_edge20.loopexit.unr-lcssa ], [ %46, %.lr.ph19.epil ]
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.013.lcssa, i64 noundef %.011.lcssa)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret i32 0

.lr.ph19:                                         ; preds = %.lr.ph19, %.lr.ph19.preheader.new
  %.017 = phi i64 [ 0, %.lr.ph19.preheader.new ], [ %72, %.lr.ph19 ]
  %.01116 = phi i64 [ 0, %.lr.ph19.preheader.new ], [ %71, %.lr.ph19 ]
  %niter33 = phi i64 [ 0, %.lr.ph19.preheader.new ], [ %niter33.next.3, %.lr.ph19 ]
  %49 = call i64 @llvm.smin.i64(i64 %.017, i64 %19)
  %50 = trunc i64 %49 to i32
  %51 = shl nuw i32 1, %50
  %52 = sext i32 %51 to i64
  %53 = add nsw i64 %.01116, %52
  %54 = or disjoint i64 %.017, 1
  %55 = call i64 @llvm.smin.i64(i64 %54, i64 %19)
  %56 = trunc i64 %55 to i32
  %57 = shl nuw i32 1, %56
  %58 = sext i32 %57 to i64
  %59 = add nsw i64 %53, %58
  %60 = or disjoint i64 %.017, 2
  %61 = call i64 @llvm.smin.i64(i64 %60, i64 %19)
  %62 = trunc i64 %61 to i32
  %63 = shl nuw i32 1, %62
  %64 = sext i32 %63 to i64
  %65 = add nsw i64 %59, %64
  %66 = or disjoint i64 %.017, 3
  %67 = call i64 @llvm.smin.i64(i64 %66, i64 %19)
  %68 = trunc i64 %67 to i32
  %69 = shl nuw i32 1, %68
  %70 = sext i32 %69 to i64
  %71 = add nsw i64 %65, %70
  %72 = add nuw nsw i64 %.017, 4
  %niter33.next.3 = add i64 %niter33, 4
  %niter33.ncmp.3 = icmp eq i64 %niter33.next.3, %unroll_iter32
  br i1 %niter33.ncmp.3, label %._crit_edge20.loopexit.unr-lcssa, label %.lr.ph19, !llvm.loop !14
}

; 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: 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) #3

attributes #0 = { mustprogress nofree 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !12}


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