; LLVM IR from tangjz/acm-icpc :: hdu/5539.ll (Z6color1v)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local global i32, align 4
@col = external dso_local global [1002001 x i32], align 16
@e = external dso_local global [1002001 x %"class.std::vector"], 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 uwtable
define dso_local noundef zeroext i1 @_Z6color1v() #1 {
  %1 = alloca i1, align 1
  %2 = alloca i8, align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #4
  store i8 1, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %45, %0
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = load i32, ptr @n, align 4, !tbaa !9
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %12, label %15

12:                                               ; preds = %8
  %13 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %14 = trunc i8 %13 to i1
  br label %15

15:                                               ; preds = %12, %8
  %16 = phi i1 [ false, %8 ], [ %14, %12 ]
  br i1 %16, label %18, label %17

17:                                               ; preds = %15
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %48

18:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %5, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %41, %18
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = load i32, ptr @n, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %25, label %28

25:                                               ; preds = %21
  %26 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %27 = trunc i8 %26 to i1
  br label %28

28:                                               ; preds = %25, %21
  %29 = phi i1 [ false, %21 ], [ %27, %25 ]
  br i1 %29, label %31, label %30

30:                                               ; preds = %28
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %44

31:                                               ; preds = %28
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = call noundef i32 @_Z3idxii(i32 noundef %32, i32 noundef %33)
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1002001 x %"class.std::vector"], ptr @e, i64 0, i64 %35
  %37 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %36) #4
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  store i8 0, ptr %2, align 1, !tbaa !5
  br label %40

40:                                               ; preds = %39, %31
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %5, align 4, !tbaa !9
  br label %21, !llvm.loop !13

44:                                               ; preds = %30
  br label %45

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

48:                                               ; preds = %17
  %49 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %50 = trunc i8 %49 to i1
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i1 false, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %89

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

53:                                               ; preds = %85, %52
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = load i32, ptr @n, align 4, !tbaa !9
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %88

58:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %7, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %81, %58
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = load i32, ptr @n, align 4, !tbaa !9
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %84

66:                                               ; preds = %61
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = call noundef i32 @_Z3idxii(i32 noundef %67, i32 noundef %68)
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1002001 x i32], ptr @col, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %80, label %74

74:                                               ; preds = %66
  %75 = load i32, ptr %6, align 4, !tbaa !9
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = call noundef i32 @_Z3idxii(i32 noundef %75, i32 noundef %76)
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1002001 x i32], ptr @col, i64 0, i64 %78
  store i32 1, ptr %79, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %74, %66
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %7, align 4, !tbaa !9
  br label %61, !llvm.loop !16

84:                                               ; preds = %65
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %6, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %6, align 4, !tbaa !9
  br label %53, !llvm.loop !17

88:                                               ; preds = %57
  store i1 true, ptr %1, align 1
  store i32 1, ptr %4, align 4
  br label %89

89:                                               ; preds = %88, %51
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #4
  %90 = load i1, ptr %1, align 1
  ret i1 %90
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@n = external dso_local local_unnamed_addr global i32, align 4
@col = external dso_local local_unnamed_addr global [1002001 x i32], align 16
@e = external dso_local global [1002001 x %"class.std::vector"], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z6color1v() local_unnamed_addr #0 {
  %1 = load i32, ptr @n, align 4
  %2 = icmp sgt i32 %1, 0
  br i1 %2, label %.lr.ph31, label %.loopexit25

.loopexit26:                                      ; preds = %.lr.ph, %.lr.ph31
  %.pre-phi = phi i1 [ %10, %.lr.ph31 ], [ %19, %.lr.ph ]
  %3 = phi i32 [ %7, %.lr.ph31 ], [ %17, %.lr.ph ]
  %.1.lcssa = phi i8 [ %.02229, %.lr.ph31 ], [ %spec.select, %.lr.ph ]
  %4 = icmp slt i32 %8, %3
  %5 = select i1 %4, i1 %.pre-phi, i1 false
  br i1 %5, label %.lr.ph31, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.loopexit26
  %6 = icmp sgt i32 %3, 0
  %or.cond = and i1 %.pre-phi, %6
  br i1 %or.cond, label %.lr.ph37, label %.loopexit25

.lr.ph31:                                         ; preds = %0, %.loopexit26
  %7 = phi i32 [ %3, %.loopexit26 ], [ %1, %0 ]
  %.02130 = phi i32 [ %8, %.loopexit26 ], [ 0, %0 ]
  %.02229 = phi i8 [ %.1.lcssa, %.loopexit26 ], [ 1, %0 ]
  %8 = add nuw nsw i32 %.02130, 1
  %9 = icmp slt i32 %8, %7
  %10 = trunc nuw i8 %.02229 to i1
  %11 = select i1 %9, i1 %10, i1 false
  br i1 %11, label %.lr.ph, label %.loopexit26

.lr.ph:                                           ; preds = %.lr.ph31, %.lr.ph
  %.02028 = phi i32 [ %16, %.lr.ph ], [ %8, %.lr.ph31 ]
  %.127 = phi i8 [ %spec.select, %.lr.ph ], [ %.02229, %.lr.ph31 ]
  %12 = tail call noundef i32 @_Z3idxii(i32 noundef %.02130, i32 noundef %.02028)
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [1002001 x %"class.std::vector"], ptr @e, i64 0, i64 %13
  %15 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #2
  %.not24 = icmp eq i64 %15, 0
  %spec.select = select i1 %.not24, i8 %.127, i8 0
  %16 = add nuw nsw i32 %.02028, 1
  %17 = load i32, ptr @n, align 4
  %18 = icmp slt i32 %16, %17
  %19 = trunc nuw i8 %spec.select to i1
  %20 = select i1 %18, i1 %19, i1 false
  br i1 %20, label %.lr.ph, label %.loopexit26, !llvm.loop !7

.loopexit:                                        ; preds = %34, %.lr.ph37
  %21 = phi i32 [ %23, %.lr.ph37 ], [ %36, %34 ]
  %22 = icmp slt i32 %24, %21
  br i1 %22, label %.lr.ph37, label %.loopexit25, !llvm.loop !8

.lr.ph37:                                         ; preds = %._crit_edge, %.loopexit
  %23 = phi i32 [ %21, %.loopexit ], [ %3, %._crit_edge ]
  %.01936 = phi i32 [ %24, %.loopexit ], [ 0, %._crit_edge ]
  %24 = add nuw nsw i32 %.01936, 1
  %25 = icmp slt i32 %24, %23
  br i1 %25, label %.lr.ph35, label %.loopexit

.lr.ph35:                                         ; preds = %.lr.ph37, %34
  %.033 = phi i32 [ %35, %34 ], [ %24, %.lr.ph37 ]
  %26 = tail call noundef i32 @_Z3idxii(i32 noundef %.01936, i32 noundef %.033)
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1002001 x i32], ptr @col, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %.not = icmp eq i32 %29, 0
  br i1 %.not, label %30, label %34

30:                                               ; preds = %.lr.ph35
  %31 = tail call noundef i32 @_Z3idxii(i32 noundef %.01936, i32 noundef %.033)
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1002001 x i32], ptr @col, i64 0, i64 %32
  store i32 1, ptr %33, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %.lr.ph35, %30
  %35 = add nuw nsw i32 %.033, 1
  %36 = load i32, ptr @n, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %.lr.ph35, label %.loopexit, !llvm.loop !13

.loopexit25:                                      ; preds = %.loopexit, %0, %._crit_edge
  %.lcssa42 = phi i1 [ %.pre-phi, %._crit_edge ], [ true, %0 ], [ %.pre-phi, %.loopexit ]
  ret i1 %.lcssa42
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 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 = { inlinehint 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 = { 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"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = distinct !{!13, !6}


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