; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/5799.ll (Z4moveii)

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

@dep = external dso_local global [100010 x i32], align 16
@in = external dso_local global [100010 x i8], align 16
@cross = external dso_local global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4moveii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = icmp eq i32 %5, %6
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %50

9:                                                ; preds = %2
  store i32 0, ptr @cross, align 4, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [100010 x i8], ptr @in, i64 0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !9, !range !11, !noundef !12
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %17

15:                                               ; preds = %9
  %16 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %16, ptr @cross, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %15, %9
  br label %18

18:                                               ; preds = %28, %17
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp sgt i32 %22, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %18
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %18, !llvm.loop !13

29:                                               ; preds = %18
  br label %30

30:                                               ; preds = %40, %29
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = icmp sgt i32 %34, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %30
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %4)
  br label %30, !llvm.loop !15

41:                                               ; preds = %30
  br label %42

42:                                               ; preds = %46, %41
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = icmp ne i32 %43, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %4)
  br label %42, !llvm.loop !16

47:                                               ; preds = %42
  %48 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z3invi(i32 noundef %48)
  %49 = load i32, ptr @cross, align 4, !tbaa !5
  call void @_Z3invi(i32 noundef %49)
  br label %50

50:                                               ; preds = %47, %8
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z3invi(i32 noundef) #1

attributes #0 = { 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 #1 = { inlinehint 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" }

!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 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !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"

@dep = external dso_local local_unnamed_addr global [100010 x i32], align 16
@in = external dso_local local_unnamed_addr global [100010 x i8], align 16
@cross = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4moveii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = icmp eq i32 %0, %1
  br i1 %5, label %41, label %6

6:                                                ; preds = %2
  %7 = sext i32 %1 to i64
  %8 = getelementptr inbounds [100010 x i8], ptr @in, i64 0, i64 %7
  %9 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = trunc nuw i8 %9 to i1
  %spec.store.select = select i1 %10, i32 %1, i32 0
  store i32 %spec.store.select, ptr @cross, align 4
  %11 = sext i32 %0 to i64
  %12 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %7
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp sgt i32 %13, %15
  br i1 %16, label %.lr.ph, label %.preheader1

.preheader1:                                      ; preds = %.lr.ph, %6
  %17 = phi i32 [ %13, %6 ], [ %24, %.lr.ph ]
  %18 = phi i32 [ %0, %6 ], [ %21, %.lr.ph ]
  %19 = phi i32 [ %15, %6 ], [ %25, %.lr.ph ]
  %20 = icmp sgt i32 %19, %17
  br i1 %20, label %.lr.ph2, label %.preheader

.lr.ph:                                           ; preds = %6, %.lr.ph
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %3)
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = load i32, ptr %14, align 4, !tbaa !5
  %26 = icmp sgt i32 %24, %25
  br i1 %26, label %.lr.ph, label %.preheader1, !llvm.loop !13

.preheader:                                       ; preds = %.lr.ph2, %.preheader1
  %27 = phi i32 [ %1, %.preheader1 ], [ %29, %.lr.ph2 ]
  %28 = phi i32 [ %18, %.preheader1 ], [ %33, %.lr.ph2 ]
  %.not3 = icmp eq i32 %28, %27
  br i1 %.not3, label %._crit_edge, label %.lr.ph4

.lr.ph2:                                          ; preds = %.preheader1, %.lr.ph2
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %4)
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100010 x i32], ptr @dep, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp sgt i32 %32, %36
  br i1 %37, label %.lr.ph2, label %.preheader, !llvm.loop !15

.lr.ph4:                                          ; preds = %.preheader, %.lr.ph4
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4) %4)
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %38, %39
  br i1 %.not, label %._crit_edge, label %.lr.ph4, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph4, %.preheader
  %.lcssa = phi i32 [ %27, %.preheader ], [ %38, %.lr.ph4 ]
  call void @_Z3invi(i32 noundef %.lcssa)
  %40 = load i32, ptr @cross, align 4, !tbaa !5
  call void @_Z3invi(i32 noundef %40)
  br label %41

41:                                               ; preds = %2, %._crit_edge
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z7move_upRi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z3invi(i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { inlinehint 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" }

!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 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SimplifyCFGPass