; LLVM IR from DionysiosB/CodeForces :: 0200-0299 (283A-CowsAndSequence-old)

; 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 [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [200001 x i64], align 16
  %3 = alloca i64, align 8
  %4 = alloca double, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 1600008, ptr %2) #4
  call void @llvm.memset.p0.i64(ptr align 16 %2, i8 0, i64 1600008, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %71, %0
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = add nsw i64 %13, -1
  store i64 %14, ptr %5, align 8, !tbaa !5
  %15 = icmp ne i64 %13, 0
  br i1 %15, label %16, label %77

16:                                               ; preds = %12
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9)
  %18 = load i32, ptr %9, align 4, !tbaa !11
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %45

20:                                               ; preds = %16
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %7, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %35, %20
  %23 = load i32, ptr %10, align 4, !tbaa !11
  %24 = sext i32 %23 to i64
  %25 = load i64, ptr %7, align 8, !tbaa !5
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %38

28:                                               ; preds = %22
  %29 = load i64, ptr %6, align 8, !tbaa !5
  %30 = load i32, ptr %10, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [200001 x i64], ptr %2, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = add nsw i64 %33, %29
  store i64 %34, ptr %32, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %28
  %36 = load i32, ptr %10, align 4, !tbaa !11
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %10, align 4, !tbaa !11
  br label %22, !llvm.loop !13

38:                                               ; preds = %27
  %39 = load i64, ptr %6, align 8, !tbaa !5
  %40 = load i64, ptr %7, align 8, !tbaa !5
  %41 = mul nsw i64 %39, %40
  %42 = sitofp i64 %41 to double
  %43 = load double, ptr %4, align 8, !tbaa !9
  %44 = fadd double %43, %42
  store double %44, ptr %4, align 8, !tbaa !9
  br label %71

45:                                               ; preds = %16
  %46 = load i32, ptr %9, align 4, !tbaa !11
  %47 = icmp eq i32 %46, 2
  br i1 %47, label %48, label %58

48:                                               ; preds = %45
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %8)
  %50 = load i64, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %3, align 8, !tbaa !5
  %52 = add nsw i64 %51, 1
  store i64 %52, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds [200001 x i64], ptr %2, i64 0, i64 %51
  store i64 %50, ptr %53, align 8, !tbaa !5
  %54 = load i64, ptr %8, align 8, !tbaa !5
  %55 = sitofp i64 %54 to double
  %56 = load double, ptr %4, align 8, !tbaa !9
  %57 = fadd double %56, %55
  store double %57, ptr %4, align 8, !tbaa !9
  br label %70

58:                                               ; preds = %45
  %59 = load i32, ptr %9, align 4, !tbaa !11
  %60 = icmp eq i32 %59, 3
  br i1 %60, label %61, label %69

61:                                               ; preds = %58
  %62 = load i64, ptr %3, align 8, !tbaa !5
  %63 = add nsw i64 %62, -1
  store i64 %63, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds [200001 x i64], ptr %2, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !5
  %66 = sitofp i64 %65 to double
  %67 = load double, ptr %4, align 8, !tbaa !9
  %68 = fsub double %67, %66
  store double %68, ptr %4, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %61, %58
  br label %70

70:                                               ; preds = %69, %48
  br label %71

71:                                               ; preds = %70, %38
  %72 = load double, ptr %4, align 8, !tbaa !9
  %73 = load i64, ptr %3, align 8, !tbaa !5
  %74 = sitofp i64 %73 to double
  %75 = fdiv double %72, %74
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %75)
  br label %12, !llvm.loop !15

77:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 1600008, ptr %2) #4
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = { 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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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 [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [200001 x i64], align 16
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1600008, ptr nonnull %1) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600008) %1, i8 0, i64 1600008, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store i64 0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = add nsw i64 %8, -1
  store i64 %9, ptr %2, align 8, !tbaa !5
  %.not16 = icmp eq i64 %8, 0
  br i1 %.not16, label %._crit_edge21, label %.lr.ph20

.lr.ph20:                                         ; preds = %0, %40
  %.0918 = phi double [ %.1, %40 ], [ 0.000000e+00, %0 ]
  %.01017 = phi i64 [ %.111, %40 ], [ 1, %0 ]
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %6)
  %11 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %11, label %40 [
    i32 1, label %12
    i32 2, label %27
    i32 3, label %34
  ]

12:                                               ; preds = %.lr.ph20
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %4, ptr noundef nonnull %3)
  %14 = load i64, ptr %4, align 8, !tbaa !5
  %15 = icmp sgt i64 %14, 0
  %.pre = load i64, ptr %3, align 8, !tbaa !5
  br i1 %15, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %12
  %min.iters.check = icmp ult i64 %14, 4
  br i1 %min.iters.check, label %.lr.ph.preheader24, label %vector.ph

.lr.ph.preheader24:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %14, 9223372036854775804
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %.pre, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %16 = getelementptr inbounds [200001 x i64], ptr %1, i64 0, i64 %index
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load = load <2 x i64>, ptr %16, align 16, !tbaa !5
  %wide.load23 = load <2 x i64>, ptr %17, align 16, !tbaa !5
  %18 = add nsw <2 x i64> %wide.load, %broadcast.splat
  %19 = add nsw <2 x i64> %wide.load23, %broadcast.splat
  store <2 x i64> %18, ptr %16, align 16, !tbaa !5
  store <2 x i64> %19, ptr %17, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %20 = icmp eq i64 %index.next, %n.vec
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %14, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader24

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %12
  %21 = mul nsw i64 %.pre, %14
  %22 = sitofp i64 %21 to double
  %23 = fadd double %.0918, %22
  br label %40

.lr.ph:                                           ; preds = %.lr.ph.preheader24, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader24 ]
  %24 = getelementptr inbounds [200001 x i64], ptr %1, i64 0, i64 %indvars.iv
  %25 = load i64, ptr %24, align 8, !tbaa !5
  %26 = add nsw i64 %25, %.pre
  store i64 %26, ptr %24, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %14
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

27:                                               ; preds = %.lr.ph20
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %5)
  %29 = load i64, ptr %5, align 8, !tbaa !5
  %30 = add nsw i64 %.01017, 1
  %31 = getelementptr inbounds [200001 x i64], ptr %1, i64 0, i64 %.01017
  store i64 %29, ptr %31, align 8, !tbaa !5
  %32 = sitofp i64 %29 to double
  %33 = fadd double %.0918, %32
  br label %40

34:                                               ; preds = %.lr.ph20
  %35 = add nsw i64 %.01017, -1
  %36 = getelementptr inbounds [200001 x i64], ptr %1, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = sitofp i64 %37 to double
  %39 = fsub double %.0918, %38
  br label %40

40:                                               ; preds = %.lr.ph20, %27, %34, %._crit_edge
  %.111 = phi i64 [ %.01017, %._crit_edge ], [ %30, %27 ], [ %35, %34 ], [ %.01017, %.lr.ph20 ]
  %.1 = phi double [ %23, %._crit_edge ], [ %33, %27 ], [ %39, %34 ], [ %.0918, %.lr.ph20 ]
  %41 = sitofp i64 %.111 to double
  %42 = fdiv double %.1, %41
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %42)
  %44 = load i64, ptr %2, align 8, !tbaa !5
  %45 = add nsw i64 %44, -1
  store i64 %45, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %44, 0
  br i1 %.not, label %._crit_edge21, label %.lr.ph20, !llvm.loop !16

._crit_edge21:                                    ; preds = %40, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  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 1600008, 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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", !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, !14, !13}
!16 = distinct !{!16, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass