; LLVM IR from DionysiosB/CodeForces :: 0800-0899 (825B-FiveInARow)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef, i32 noundef, i32 noundef) #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

8:                                                ; preds = %19, %0
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = icmp sle i32 %9, 10
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %22

12:                                               ; preds = %8
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [15 x [15 x i8]], ptr %2, i64 0, i64 %14
  %16 = getelementptr inbounds [15 x i8], ptr %15, i64 0, i64 0
  %17 = getelementptr inbounds i8, ptr %16, i64 1
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %17)
  br label %19

19:                                               ; preds = %12
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %3, align 4, !tbaa !5
  br label %8, !llvm.loop !9

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

23:                                               ; preds = %43, %22
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = icmp sle i32 %24, 10
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %46

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

28:                                               ; preds = %39, %27
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = icmp sle i32 %29, 10
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %42

32:                                               ; preds = %28
  %33 = getelementptr inbounds [15 x [15 x i8]], ptr %2, i64 0, i64 0
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef %33, i32 noundef %34, i32 noundef %35)
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  store i8 1, ptr %4, align 1, !tbaa !11
  br label %38

38:                                               ; preds = %37, %32
  br label %39

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

42:                                               ; preds = %31
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %5, align 4, !tbaa !5
  br label %23, !llvm.loop !14

46:                                               ; preds = %26
  %47 = load i8, ptr %4, align 1, !tbaa !11, !range !15, !noundef !16
  %48 = trunc i8 %47 to i1
  %49 = zext i1 %48 to i64
  %50 = select i1 %48, ptr @.str.1, ptr @.str.2
  %51 = call i32 @puts(ptr noundef %50)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 225, ptr %2) #4
  %52 = load i32, ptr %1, align 4
  ret i32 %52
}

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

declare i32 @puts(ptr noundef) #3

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = !{i8 0, i8 2}
!16 = !{}


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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
.preheader.preheader:
  %0 = alloca [15 x [15 x i8]], align 16
  call void @llvm.lifetime.start.p0(i64 225, ptr nonnull %0) #4
  %1 = getelementptr inbounds i8, ptr %0, i64 16
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = getelementptr inbounds i8, ptr %0, i64 31
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  %5 = getelementptr inbounds i8, ptr %0, i64 46
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 61
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %7)
  %9 = getelementptr inbounds i8, ptr %0, i64 76
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %9)
  %11 = getelementptr inbounds i8, ptr %0, i64 91
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 106
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %13)
  %15 = getelementptr inbounds i8, ptr %0, i64 121
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %15)
  %17 = getelementptr inbounds i8, ptr %0, i64 136
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 151
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %19)
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.01119 = phi i32 [ %40, %.preheader ], [ 1, %.preheader.preheader ]
  %.01218 = phi i1 [ %spec.select.9, %.preheader ], [ false, %.preheader.preheader ]
  %21 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 1)
  %22 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 2)
  %23 = or i1 %22, %21
  %24 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 3)
  %25 = or i1 %24, %23
  %26 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 4)
  %27 = or i1 %26, %25
  %28 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 5)
  %29 = or i1 %28, %27
  %30 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 6)
  %31 = or i1 %30, %29
  %32 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 7)
  %33 = or i1 %32, %31
  %34 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 8)
  %35 = or i1 %34, %33
  %36 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 9)
  %37 = or i1 %36, %35
  %38 = call noundef zeroext i1 @_Z5checkPA15_cii(ptr noundef nonnull %0, i32 noundef %.01119, i32 noundef 10)
  %39 = select i1 %38, i1 true, i1 %37
  %spec.select.9 = select i1 %39, i1 true, i1 %.01218
  %40 = add nuw nsw i32 %.01119, 1
  %exitcond.not = icmp eq i32 %40, 11
  br i1 %exitcond.not, label %41, label %.preheader, !llvm.loop !5

41:                                               ; preds = %.preheader
  %42 = select i1 %spec.select.9, ptr @.str.1, ptr @.str.2
  %43 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %42)
  call void @llvm.lifetime.end.p0(i64 225, ptr nonnull %0) #4
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

attributes #0 = { mustprogress 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 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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