; LLVM IR from viveakrt/Competitive-programing :: Codeforces (1362C_Johnny_and_Another_Rating_Drop)

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

12:                                               ; preds = %42, %0
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 65
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %45

16:                                               ; preds = %12
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [65 x i64], ptr %3, i64 0, i64 %20
  store i64 %18, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  store i32 %23, ptr %6, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %38, %16
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %41

28:                                               ; preds = %24
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [65 x i64], ptr %3, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [65 x i64], ptr %3, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = add nsw i64 %36, %32
  store i64 %37, ptr %35, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %28
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %6, align 4, !tbaa !9
  br label %24, !llvm.loop !11

41:                                               ; preds = %27
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %4, align 4, !tbaa !9
  br label %12, !llvm.loop !13

45:                                               ; preds = %15
  br label %46

46:                                               ; preds = %73, %45
  %47 = load i32, ptr %2, align 4, !tbaa !9
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %2, align 4, !tbaa !9
  %49 = icmp ne i32 %47, 0
  br i1 %49, label %50, label %76

50:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %70, %50
  %53 = load i64, ptr %7, align 8, !tbaa !5
  %54 = icmp ne i64 %53, 0
  br i1 %54, label %56, label %55

55:                                               ; preds = %52
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %73

56:                                               ; preds = %52
  %57 = load i64, ptr %7, align 8, !tbaa !5
  %58 = and i64 %57, 1
  %59 = icmp ne i64 %58, 0
  br i1 %59, label %60, label %67

60:                                               ; preds = %56
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [65 x i64], ptr %3, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !5
  %65 = load i64, ptr %8, align 8, !tbaa !5
  %66 = add nsw i64 %65, %64
  store i64 %66, ptr %8, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %60, %56
  %68 = load i64, ptr %7, align 8, !tbaa !5
  %69 = ashr i64 %68, 1
  store i64 %69, ptr %7, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %67
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %9, align 4, !tbaa !9
  br label %52, !llvm.loop !14

73:                                               ; preds = %55
  %74 = load i64, ptr %8, align 8, !tbaa !5
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %74)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %46, !llvm.loop !15

76:                                               ; preds = %46
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 520, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %77 = load i32, ptr %1, align 4
  ret i32 %77
}

; 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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 [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca [65 x i64], align 16
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 520, ptr nonnull %2) #4
  store i64 0, ptr %2, align 16, !tbaa !5
  br label %7

.preheader:                                       ; preds = %._crit_edge
  %5 = load i32, ptr %1, align 4, !tbaa !9
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr %1, align 4, !tbaa !9
  %.not29 = icmp eq i32 %5, 0
  br i1 %.not29, label %._crit_edge31, label %.lr.ph30

7:                                                ; preds = %0, %._crit_edge
  %indvar = phi i64 [ 0, %0 ], [ %indvar.next, %._crit_edge ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %._crit_edge ]
  %8 = getelementptr inbounds [65 x i64], ptr %2, i64 0, i64 %indvars.iv
  store i64 %indvars.iv, ptr %8, align 8, !tbaa !5
  %9 = icmp ugt i64 %indvars.iv, 1
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %7
  %min.iters.check = icmp ult i64 %indvar, 14
  br i1 %min.iters.check, label %.lr.ph.preheader44, label %vector.scevcheck

.lr.ph.preheader44:                               ; preds = %middle.block, %vector.scevcheck, %.lr.ph.preheader
  %indvars.iv32.ph = phi i64 [ %indvars.iv, %vector.scevcheck ], [ %indvars.iv, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %storemerge20.ph = phi i64 [ %indvars.iv, %vector.scevcheck ], [ %indvars.iv, %.lr.ph.preheader ], [ %25, %middle.block ]
  br label %.lr.ph

vector.scevcheck:                                 ; preds = %.lr.ph.preheader
  %10 = and i64 %indvar, 4294967295
  %11 = icmp eq i64 %10, 0
  %12 = add i64 %indvar, -4294967297
  %13 = icmp ult i64 %12, -4294967296
  %14 = or i1 %11, %13
  br i1 %14, label %.lr.ph.preheader44, label %vector.ph

vector.ph:                                        ; preds = %vector.scevcheck
  %n.vec = and i64 %indvar, 8589934588
  %ind.end = sub nsw i64 %indvars.iv, %n.vec
  %15 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %indvars.iv, i64 0
  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> [ %15, %vector.ph ], [ %22, %vector.body ]
  %vec.phi41 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %23, %vector.body ]
  %16 = xor i64 %index, -1
  %17 = add i64 %indvars.iv, %16
  %18 = and i64 %17, 4294967295
  %19 = getelementptr inbounds [65 x i64], ptr %2, i64 0, i64 %18
  %20 = getelementptr inbounds i8, ptr %19, i64 -8
  %21 = getelementptr inbounds i8, ptr %19, i64 -24
  %wide.load = load <2 x i64>, ptr %20, align 8, !tbaa !5
  %reverse = shufflevector <2 x i64> %wide.load, <2 x i64> poison, <2 x i32> <i32 1, i32 0>
  %wide.load42 = load <2 x i64>, ptr %21, align 8, !tbaa !5
  %reverse43 = shufflevector <2 x i64> %wide.load42, <2 x i64> poison, <2 x i32> <i32 1, i32 0>
  %22 = add <2 x i64> %reverse, %vec.phi
  %23 = add <2 x i64> %reverse43, %vec.phi41
  %index.next = add nuw i64 %index, 4
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %23, %22
  %25 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  store i64 %25, ptr %8, align 8, !tbaa !5
  %cmp.n = icmp eq i64 %indvar, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader44

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 65
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond.not, label %.preheader, label %7, !llvm.loop !15

.lr.ph:                                           ; preds = %.lr.ph.preheader44, %.lr.ph
  %indvars.iv32 = phi i64 [ %indvars.iv.next33, %.lr.ph ], [ %indvars.iv32.ph, %.lr.ph.preheader44 ]
  %storemerge20 = phi i64 [ %29, %.lr.ph ], [ %storemerge20.ph, %.lr.ph.preheader44 ]
  %indvars.iv.next33 = add nsw i64 %indvars.iv32, -1
  %26 = and i64 %indvars.iv.next33, 4294967295
  %27 = getelementptr inbounds [65 x i64], ptr %2, i64 0, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !5
  %29 = add nsw i64 %28, %storemerge20
  store i64 %29, ptr %8, align 8, !tbaa !5
  %30 = icmp sgt i64 %indvars.iv32, 2
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !16

.lr.ph30:                                         ; preds = %.preheader, %32
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %.pr = load i64, ptr %3, align 8, !tbaa !5
  %.not1823 = icmp eq i64 %.pr, 0
  br i1 %.not1823, label %32, label %.lr.ph27

._crit_edge28:                                    ; preds = %42
  store i64 %43, ptr %3, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %._crit_edge28, %.lr.ph30
  %.014.lcssa = phi i64 [ %.1, %._crit_edge28 ], [ 0, %.lr.ph30 ]
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.014.lcssa)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %34 = load i32, ptr %1, align 4, !tbaa !9
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %1, align 4, !tbaa !9
  %.not = icmp eq i32 %34, 0
  br i1 %.not, label %._crit_edge31, label %.lr.ph30, !llvm.loop !17

.lr.ph27:                                         ; preds = %.lr.ph30, %42
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %42 ], [ 1, %.lr.ph30 ]
  %.01424 = phi i64 [ %.1, %42 ], [ 0, %.lr.ph30 ]
  %36 = phi i64 [ %43, %42 ], [ %.pr, %.lr.ph30 ]
  %37 = and i64 %36, 1
  %.not19 = icmp eq i64 %37, 0
  br i1 %.not19, label %42, label %38

38:                                               ; preds = %.lr.ph27
  %39 = getelementptr inbounds [65 x i64], ptr %2, i64 0, i64 %indvars.iv37
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = add nsw i64 %40, %.01424
  br label %42

42:                                               ; preds = %38, %.lr.ph27
  %.1 = phi i64 [ %41, %38 ], [ %.01424, %.lr.ph27 ]
  %43 = ashr i64 %36, 1
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %.not18 = icmp ult i64 %36, 2
  br i1 %.not18, label %._crit_edge28, label %.lr.ph27, !llvm.loop !18

._crit_edge31:                                    ; preds = %32, %.preheader
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  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: 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>) #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 = !{!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, !13}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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