; LLVM IR from DionysiosB/CodeForces :: 0001-0099 (27A-NextTest)

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

10:                                               ; preds = %20, %0
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %23

15:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [3002 x i8], ptr %3, i64 0, i64 %18
  store i8 1, ptr %19, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %20

20:                                               ; preds = %15
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %5, align 4, !tbaa !5
  br label %10, !llvm.loop !11

23:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %38, %23
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 3002
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 5, ptr %8, align 4
  br label %41

28:                                               ; preds = %24
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [3002 x i8], ptr %3, i64 0, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !9, !range !13, !noundef !14
  %33 = trunc i8 %32 to i1
  br i1 %33, label %37, label %34

34:                                               ; preds = %28
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %35)
  store i32 5, ptr %8, align 4
  br label %41

37:                                               ; preds = %28
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 4, !tbaa !5
  br label %24, !llvm.loop !15

41:                                               ; preds = %34, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %42

42:                                               ; preds = %41
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 3002, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %43 = load i32, ptr %1, align 4
  ret i32 %43
}

; 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i8 0, i8 2}
!14 = !{}
!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 [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [3002 x i8], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 3002, ptr nonnull %1) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(3002) %1, i8 0, i64 3002, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %.preheader.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.079 = phi i32 [ %11, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %9
  store i8 1, ptr %10, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  %11 = add nuw nsw i32 %.079, 1
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %.lr.ph, label %.preheader.preheader, !llvm.loop !11

.preheader.preheader:                             ; preds = %.lr.ph, %0
  br label %.preheader

.preheader:                                       ; preds = %42, %.preheader.preheader
  %indvars.iv = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next.7, %42 ]
  %14 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv
  %15 = load i8, ptr %14, align 1, !tbaa !9, !range !13, !noundef !14
  %16 = trunc nuw i8 %15 to i1
  br i1 %16, label %20, label %17

17:                                               ; preds = %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader
  %indvars.iv.lcssa = phi i64 [ %indvars.iv, %.preheader ], [ %indvars.iv.next, %.preheader.1 ], [ %indvars.iv.next.1, %.preheader.2 ], [ %indvars.iv.next.2, %.preheader.3 ], [ %indvars.iv.next.3, %.preheader.4 ], [ %indvars.iv.next.4, %.preheader.5 ], [ %indvars.iv.next.5, %.preheader.6 ], [ %indvars.iv.next.6, %.preheader.7 ]
  %18 = trunc nuw nsw i64 %indvars.iv.lcssa to i32
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %18)
  br label %.loopexit

20:                                               ; preds = %.preheader
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 3002
  br i1 %exitcond.not, label %.loopexit, label %.preheader.1, !llvm.loop !15

.preheader.1:                                     ; preds = %20
  %21 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv.next
  %22 = load i8, ptr %21, align 1, !tbaa !9, !range !13, !noundef !14
  %23 = trunc nuw i8 %22 to i1
  br i1 %23, label %.preheader.2, label %17

.preheader.2:                                     ; preds = %.preheader.1
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %24 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv.next.1
  %25 = load i8, ptr %24, align 1, !tbaa !9, !range !13, !noundef !14
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %.preheader.3, label %17

.preheader.3:                                     ; preds = %.preheader.2
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %27 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv.next.2
  %28 = load i8, ptr %27, align 1, !tbaa !9, !range !13, !noundef !14
  %29 = trunc nuw i8 %28 to i1
  br i1 %29, label %.preheader.4, label %17

.preheader.4:                                     ; preds = %.preheader.3
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %30 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv.next.3
  %31 = load i8, ptr %30, align 1, !tbaa !9, !range !13, !noundef !14
  %32 = trunc nuw i8 %31 to i1
  br i1 %32, label %.preheader.5, label %17

.preheader.5:                                     ; preds = %.preheader.4
  %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
  %33 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv.next.4
  %34 = load i8, ptr %33, align 1, !tbaa !9, !range !13, !noundef !14
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %.preheader.6, label %17

.preheader.6:                                     ; preds = %.preheader.5
  %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
  %36 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv.next.5
  %37 = load i8, ptr %36, align 1, !tbaa !9, !range !13, !noundef !14
  %38 = trunc nuw i8 %37 to i1
  br i1 %38, label %.preheader.7, label %17

.preheader.7:                                     ; preds = %.preheader.6
  %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
  %39 = getelementptr inbounds [3002 x i8], ptr %1, i64 0, i64 %indvars.iv.next.6
  %40 = load i8, ptr %39, align 1, !tbaa !9, !range !13, !noundef !14
  %41 = trunc nuw i8 %40 to i1
  br i1 %41, label %42, label %17

42:                                               ; preds = %.preheader.7
  %indvars.iv.next.7 = add nuw nsw i64 %indvars.iv, 8
  br label %.preheader

.loopexit:                                        ; preds = %20, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 3002, 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !12}


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