; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd/1113.ll (Z5judgei)

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

@now = external dso_local global [20 x i32], align 16
@seq = external dso_local global [150 x i32], align 16
@all = external dso_local global [40 x i32], align 16
@wan = external dso_local global [40 x i32], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z9matchlessv() #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z9sevenpairv() #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5checki(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7rebuildv() #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5judgei(i32 noundef %0) #2 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @all, i8 0, i64 160, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @wan, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %19, %1
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 13
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [20 x i32], ptr @now, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %16, align 4, !tbaa !5
  br label %19

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

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

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

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

28:                                               ; preds = %23
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [150 x i32], ptr @seq, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %34, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %28
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 4, !tbaa !5
  br label %23, !llvm.loop !11

40:                                               ; preds = %27
  %41 = call noundef zeroext i1 @_Z9matchlessv()
  br i1 %41, label %49, label %42

42:                                               ; preds = %40
  call void @_Z7rebuildv()
  %43 = call noundef zeroext i1 @_Z9sevenpairv()
  br i1 %43, label %48, label %44

44:                                               ; preds = %42
  call void @_Z7rebuildv()
  %45 = call noundef zeroext i1 @_Z5checki(i32 noundef 0)
  br i1 %45, label %47, label %46

46:                                               ; preds = %44
  store i1 false, ptr %2, align 1
  br label %50

47:                                               ; preds = %44
  br label %48

48:                                               ; preds = %47, %42
  br label %49

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

50:                                               ; preds = %49, %46
  %51 = load i1, ptr %2, align 1
  ret i1 %51
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!11, !10}


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

@now = external dso_local local_unnamed_addr global [20 x i32], align 16
@seq = external dso_local local_unnamed_addr global [150 x i32], align 16
@all = external dso_local local_unnamed_addr global [40 x i32], align 16
@wan = external dso_local local_unnamed_addr global [40 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z9matchlessv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z9sevenpairv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5checki(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7rebuildv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5judgei(i32 noundef %0) local_unnamed_addr #1 {
.preheader:
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(160) @all, i8 0, i64 160, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(160) @wan, i8 0, i64 160, i1 false)
  %1 = load i32, ptr @now, align 16, !tbaa !5
  %2 = sext i32 %1 to i64
  %3 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %2
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = add nsw i32 %4, 1
  store i32 %5, ptr %3, align 4, !tbaa !5
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 4), align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr %8, align 4, !tbaa !5
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 8), align 8, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %13, align 4, !tbaa !5
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 12), align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %18, align 4, !tbaa !5
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 16), align 16, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %23, align 4, !tbaa !5
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 20), align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 4, !tbaa !5
  %31 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 24), align 8, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %33, align 4, !tbaa !5
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 28), align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %38, align 4, !tbaa !5
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 32), align 16, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %43, align 4, !tbaa !5
  %46 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 36), align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %48, align 4, !tbaa !5
  %51 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 40), align 8, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %53, align 4, !tbaa !5
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 44), align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %58, align 4, !tbaa !5
  %61 = load i32, ptr getelementptr inbounds (i8, ptr @now, i64 48), align 16, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %63, align 4, !tbaa !5
  %66 = icmp sgt i32 %0, 0
  br i1 %66, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %0 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %67 = icmp ult i32 %0, 4
  br i1 %67, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %68 = getelementptr inbounds [150 x i32], ptr @seq, i64 0, i64 %indvars.iv.epil
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %71, align 4, !tbaa !5
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !9

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader
  %74 = tail call noundef zeroext i1 @_Z9matchlessv()
  br i1 %74, label %103, label %99

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %75 = getelementptr inbounds [150 x i32], ptr @seq, i64 0, i64 %indvars.iv
  %76 = load i32, ptr %75, align 16, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %78, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %81 = getelementptr inbounds [150 x i32], ptr @seq, i64 0, i64 %indvars.iv.next
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %84, align 4, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %87 = getelementptr inbounds [150 x i32], ptr @seq, i64 0, i64 %indvars.iv.next.1
  %88 = load i32, ptr %87, align 8, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %90, align 4, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %93 = getelementptr inbounds [150 x i32], ptr @seq, i64 0, i64 %indvars.iv.next.2
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [40 x i32], ptr @all, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %96, align 4, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

99:                                               ; preds = %._crit_edge
  tail call void @_Z7rebuildv()
  %100 = tail call noundef zeroext i1 @_Z9sevenpairv()
  br i1 %100, label %103, label %101

101:                                              ; preds = %99
  tail call void @_Z7rebuildv()
  %102 = tail call noundef zeroext i1 @_Z5checki(i32 noundef 0)
  br i1 %102, label %103, label %104

103:                                              ; preds = %99, %101, %._crit_edge
  br label %104

104:                                              ; preds = %101, %103
  %.08 = phi i1 [ true, %103 ], [ false, %101 ]
  ret i1 %.08
}

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

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 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass