; LLVM IR from eyangch/competitive-programming :: Codeforces/1527/d.ll (Z11is_ancestorxx)

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

@de = external dso_local global [200000 x i64], align 16
@up = external dso_local global [20 x [200000 x i64]], 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
define dso_local noundef zeroext i1 @_Z11is_ancestorxx(i64 noundef %0, i64 noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  %6 = load i64, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %6
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = load i64, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %9
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = icmp slt i64 %8, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  call void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  br label %14

14:                                               ; preds = %13, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 19, ptr %5, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %38, %14
  %16 = load i64, ptr %5, align 8, !tbaa !5
  %17 = icmp sge i64 %16, 0
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %41

19:                                               ; preds = %15
  %20 = load i64, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 %20
  %22 = load i64, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds [200000 x i64], ptr %21, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = load i64, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = icmp sge i64 %26, %29
  br i1 %30, label %31, label %37

31:                                               ; preds = %19
  %32 = load i64, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 %32
  %34 = load i64, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds [200000 x i64], ptr %33, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  store i64 %36, ptr %3, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %31, %19
  br label %38

38:                                               ; preds = %37
  %39 = load i64, ptr %5, align 8, !tbaa !5
  %40 = add nsw i64 %39, -1
  store i64 %40, ptr %5, align 8, !tbaa !5
  br label %15, !llvm.loop !9

41:                                               ; preds = %18
  %42 = load i64, ptr %3, align 8, !tbaa !5
  %43 = load i64, ptr %4, align 8, !tbaa !5
  %44 = icmp eq i64 %42, %43
  ret i1 %44
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

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 = { 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 = { 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 = !{!"long long", !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"

@de = external dso_local local_unnamed_addr global [200000 x i64], align 16
@up = external dso_local local_unnamed_addr global [20 x [200000 x i64]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z11is_ancestorxx(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %0
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %1
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = icmp slt i64 %6, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  call void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #2
  %.pre = load i64, ptr %4, align 8, !tbaa !5
  %.phi.trans.insert = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %.pre
  %.pre5 = load i64, ptr %.phi.trans.insert, align 8, !tbaa !5
  %.promoted.pre = load i64, ptr %3, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %10, %2
  %.promoted = phi i64 [ %.promoted.pre, %10 ], [ %0, %2 ]
  %12 = phi i64 [ %.pre5, %10 ], [ %8, %2 ]
  %13 = phi i64 [ %.pre, %10 ], [ %1, %2 ]
  %14 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 19, i64 %.promoted
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %.not = icmp slt i64 %17, %12
  %spec.select = select i1 %.not, i64 %.promoted, i64 %15
  %18 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 18, i64 %spec.select
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %.not.1 = icmp slt i64 %21, %12
  %22 = select i1 %.not.1, i64 %spec.select, i64 %19
  %23 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 17, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %.not.2 = icmp slt i64 %26, %12
  %27 = select i1 %.not.2, i64 %22, i64 %24
  %28 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 16, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !5
  %30 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %.not.3 = icmp slt i64 %31, %12
  %32 = select i1 %.not.3, i64 %27, i64 %29
  %33 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 15, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %.not.4 = icmp slt i64 %36, %12
  %37 = select i1 %.not.4, i64 %32, i64 %34
  %38 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 14, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %39
  %41 = load i64, ptr %40, align 8, !tbaa !5
  %.not.5 = icmp slt i64 %41, %12
  %42 = select i1 %.not.5, i64 %37, i64 %39
  %43 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 13, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %.not.6 = icmp slt i64 %46, %12
  %47 = select i1 %.not.6, i64 %42, i64 %44
  %48 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 12, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !5
  %.not.7 = icmp slt i64 %51, %12
  %52 = select i1 %.not.7, i64 %47, i64 %49
  %53 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 11, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !5
  %55 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !5
  %.not.8 = icmp slt i64 %56, %12
  %57 = select i1 %.not.8, i64 %52, i64 %54
  %58 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 10, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !5
  %60 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !5
  %.not.9 = icmp slt i64 %61, %12
  %62 = select i1 %.not.9, i64 %57, i64 %59
  %63 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 9, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !5
  %65 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %.not.10 = icmp slt i64 %66, %12
  %67 = select i1 %.not.10, i64 %62, i64 %64
  %68 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 8, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !5
  %70 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !5
  %.not.11 = icmp slt i64 %71, %12
  %72 = select i1 %.not.11, i64 %67, i64 %69
  %73 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 7, i64 %72
  %74 = load i64, ptr %73, align 8, !tbaa !5
  %75 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %.not.12 = icmp slt i64 %76, %12
  %77 = select i1 %.not.12, i64 %72, i64 %74
  %78 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 6, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !5
  %80 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !5
  %.not.13 = icmp slt i64 %81, %12
  %82 = select i1 %.not.13, i64 %77, i64 %79
  %83 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 5, i64 %82
  %84 = load i64, ptr %83, align 8, !tbaa !5
  %85 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %84
  %86 = load i64, ptr %85, align 8, !tbaa !5
  %.not.14 = icmp slt i64 %86, %12
  %87 = select i1 %.not.14, i64 %82, i64 %84
  %88 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 4, i64 %87
  %89 = load i64, ptr %88, align 8, !tbaa !5
  %90 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !5
  %.not.15 = icmp slt i64 %91, %12
  %92 = select i1 %.not.15, i64 %87, i64 %89
  %93 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 3, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !5
  %95 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %94
  %96 = load i64, ptr %95, align 8, !tbaa !5
  %.not.16 = icmp slt i64 %96, %12
  %97 = select i1 %.not.16, i64 %92, i64 %94
  %98 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 2, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !5
  %100 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %99
  %101 = load i64, ptr %100, align 8, !tbaa !5
  %.not.17 = icmp slt i64 %101, %12
  %102 = select i1 %.not.17, i64 %97, i64 %99
  %103 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 1, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !5
  %105 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %104
  %106 = load i64, ptr %105, align 8, !tbaa !5
  %.not.18 = icmp slt i64 %106, %12
  %107 = select i1 %.not.18, i64 %102, i64 %104
  %108 = getelementptr inbounds [20 x [200000 x i64]], ptr @up, i64 0, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !5
  %110 = getelementptr inbounds [200000 x i64], ptr @de, i64 0, i64 %109
  %111 = load i64, ptr %110, align 8, !tbaa !5
  %.not.19 = icmp slt i64 %111, %12
  %112 = select i1 %.not.19, i64 %107, i64 %109
  %113 = icmp eq i64 %112, %13
  ret i1 %113
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIxENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #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 = { 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 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass