; LLVM IR from tangjz/acm-icpc :: codeforces/887C.ll (Z5validv)

; 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"

@nxt = external dso_local global [25 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5validv() #0 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %45, %0
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 25
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  store i32 2, ptr %3, align 4
  br label %48

8:                                                ; preds = %4
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [25 x i32], ptr @nxt, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [25 x i32], ptr @nxt, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = icmp eq i32 %12, %17
  br i1 %18, label %19, label %43

19:                                               ; preds = %8
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [25 x i32], ptr @nxt, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 2
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [25 x i32], ptr @nxt, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp eq i32 %24, %29
  br i1 %30, label %31, label %43

31:                                               ; preds = %19
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, 2
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [25 x i32], ptr @nxt, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = add nsw i32 %37, 3
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [25 x i32], ptr @nxt, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = icmp eq i32 %36, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %31, %19, %8
  store i1 false, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %48

44:                                               ; preds = %31
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = add nsw i32 %46, 4
  store i32 %47, ptr %2, align 4, !tbaa !5
  br label %4, !llvm.loop !9

48:                                               ; preds = %43, %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  %49 = load i32, ptr %3, align 4
  switch i32 %49, label %53 [
    i32 2, label %50
    i32 1, label %51
  ]

50:                                               ; preds = %48
  store i1 true, ptr %1, align 1
  br label %51

51:                                               ; preds = %50, %48
  %52 = load i1, ptr %1, align 1
  ret i1 %52

53:                                               ; preds = %48
  unreachable
}

; 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

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 = { 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"}


; 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"

@nxt = external dso_local local_unnamed_addr global [25 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z5validv() local_unnamed_addr #0 {
  %1 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 4), align 4, !tbaa !5
  %2 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 8), align 8, !tbaa !5
  %3 = icmp eq i32 %1, %2
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 12), align 4
  %5 = icmp eq i32 %1, %4
  %or.cond34 = select i1 %3, i1 %5, i1 false
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 16), align 16
  %7 = icmp eq i32 %1, %6
  %or.cond36 = select i1 %or.cond34, i1 %7, i1 false
  br i1 %or.cond36, label %8, label %48

8:                                                ; preds = %0
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 20), align 4, !tbaa !5
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 24), align 8, !tbaa !5
  %11 = icmp eq i32 %9, %10
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 28), align 4
  %13 = icmp eq i32 %9, %12
  %or.cond = select i1 %11, i1 %13, i1 false
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 32), align 16
  %15 = icmp eq i32 %9, %14
  %or.cond16 = select i1 %or.cond, i1 %15, i1 false
  br i1 %or.cond16, label %16, label %48

16:                                               ; preds = %8
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 36), align 4, !tbaa !5
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 40), align 8, !tbaa !5
  %19 = icmp eq i32 %17, %18
  %20 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 44), align 4
  %21 = icmp eq i32 %17, %20
  %or.cond18 = select i1 %19, i1 %21, i1 false
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 48), align 16
  %23 = icmp eq i32 %17, %22
  %or.cond20 = select i1 %or.cond18, i1 %23, i1 false
  br i1 %or.cond20, label %24, label %48

24:                                               ; preds = %16
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 52), align 4, !tbaa !5
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 56), align 8, !tbaa !5
  %27 = icmp eq i32 %25, %26
  %28 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 60), align 4
  %29 = icmp eq i32 %25, %28
  %or.cond22 = select i1 %27, i1 %29, i1 false
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 64), align 16
  %31 = icmp eq i32 %25, %30
  %or.cond24 = select i1 %or.cond22, i1 %31, i1 false
  br i1 %or.cond24, label %32, label %48

32:                                               ; preds = %24
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 68), align 4, !tbaa !5
  %34 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 72), align 8, !tbaa !5
  %35 = icmp eq i32 %33, %34
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 76), align 4
  %37 = icmp eq i32 %33, %36
  %or.cond26 = select i1 %35, i1 %37, i1 false
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 80), align 16
  %39 = icmp eq i32 %33, %38
  %or.cond28 = select i1 %or.cond26, i1 %39, i1 false
  br i1 %or.cond28, label %40, label %48

40:                                               ; preds = %32
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 84), align 4, !tbaa !5
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 88), align 8, !tbaa !5
  %43 = icmp eq i32 %41, %42
  %44 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 92), align 4
  %45 = icmp eq i32 %41, %44
  %or.cond30 = select i1 %43, i1 %45, i1 false
  %46 = load i32, ptr getelementptr inbounds (i8, ptr @nxt, i64 96), align 16
  %47 = icmp eq i32 %41, %46
  %or.cond32 = select i1 %or.cond30, i1 %47, i1 false
  br label %48

48:                                               ; preds = %40, %32, %24, %16, %8, %0
  %.lcssa = phi i1 [ false, %0 ], [ false, %8 ], [ false, %16 ], [ false, %24 ], [ false, %32 ], [ %or.cond32, %40 ]
  ret i1 %.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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" }

!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass