; LLVM IR from VAR-solutions/Algorithms :: Graphs/LCA/lca1.ll (Z3lcaxx)

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

@dp = external dso_local global [200010 x [20 x i64]], align 16
@euler = external dso_local global [200010 x i64], align 16
@level = external dso_local global [200010 x i64], align 16
@first = external dso_local global [100005 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 uwtable
define dso_local noundef i64 @_Z3lcaxx(i64 noundef %0, i64 noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %11 = load i64, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds [100005 x i64], ptr @first, i64 0, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !5
  store i64 %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %14 = load i64, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds [100005 x i64], ptr @first, i64 0, i64 %14
  %16 = load i64, ptr %15, align 8, !tbaa !5
  store i64 %16, ptr %7, align 8, !tbaa !5
  %17 = load i64, ptr %6, align 8, !tbaa !5
  %18 = load i64, ptr %7, align 8, !tbaa !5
  %19 = icmp sgt i64 %17, %18
  br i1 %19, label %20, label %21

20:                                               ; 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) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  br label %21

21:                                               ; preds = %20, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %22 = load i64, ptr %7, align 8, !tbaa !5
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = sub nsw i64 %22, %23
  store i64 %24, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %25 = load i64, ptr %8, align 8, !tbaa !5
  %26 = call noundef double @_ZSt4log2IxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %25)
  %27 = fptosi double %26 to i64
  store i64 %27, ptr %9, align 8, !tbaa !5
  %28 = load i64, ptr %6, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !5
  %30 = icmp eq i64 %28, %29
  br i1 %30, label %31, label %35

31:                                               ; preds = %21
  %32 = load i64, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds [200010 x i64], ptr @euler, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !5
  store i64 %34, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %79

35:                                               ; preds = %21
  %36 = load i64, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds [200010 x [20 x i64]], ptr @dp, i64 0, i64 %36
  %38 = load i64, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds [20 x i64], ptr %37, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = getelementptr inbounds [200010 x i64], ptr @level, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !5
  %43 = load i64, ptr %7, align 8, !tbaa !5
  %44 = load i64, ptr %9, align 8, !tbaa !5
  %45 = trunc i64 %44 to i32
  %46 = shl i32 1, %45
  %47 = sext i32 %46 to i64
  %48 = sub nsw i64 %43, %47
  %49 = add nsw i64 %48, 1
  %50 = getelementptr inbounds [200010 x [20 x i64]], ptr @dp, i64 0, i64 %49
  %51 = load i64, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds [20 x i64], ptr %50, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !5
  %54 = getelementptr inbounds [200010 x i64], ptr @level, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !5
  %56 = icmp sgt i64 %42, %55
  br i1 %56, label %57, label %71

57:                                               ; preds = %35
  %58 = load i64, ptr %7, align 8, !tbaa !5
  %59 = load i64, ptr %9, align 8, !tbaa !5
  %60 = trunc i64 %59 to i32
  %61 = shl i32 1, %60
  %62 = sext i32 %61 to i64
  %63 = sub nsw i64 %58, %62
  %64 = add nsw i64 %63, 1
  %65 = getelementptr inbounds [200010 x [20 x i64]], ptr @dp, i64 0, i64 %64
  %66 = load i64, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds [20 x i64], ptr %65, i64 0, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !5
  %69 = getelementptr inbounds [200010 x i64], ptr @euler, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !5
  store i64 %70, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %79

71:                                               ; preds = %35
  %72 = load i64, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds [200010 x [20 x i64]], ptr @dp, i64 0, i64 %72
  %74 = load i64, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds [20 x i64], ptr %73, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !5
  %77 = getelementptr inbounds [200010 x i64], ptr @euler, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !5
  store i64 %78, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %79

79:                                               ; preds = %71, %57, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %80 = load i64, ptr %3, align 8
  ret i64 %80
}

; 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4log2IxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) #3

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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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

@dp = external dso_local local_unnamed_addr global [200010 x [20 x i64]], align 16
@euler = external dso_local local_unnamed_addr global [200010 x i64], align 16
@level = external dso_local local_unnamed_addr global [200010 x i64], align 16
@first = external dso_local local_unnamed_addr global [100005 x i64], align 16

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

; Function Attrs: mustprogress 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 i64 @_Z3lcaxx(i64 noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %5 = getelementptr inbounds [100005 x i64], ptr @first, i64 0, i64 %0
  %6 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %6, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %7 = getelementptr inbounds [100005 x i64], ptr @first, i64 0, i64 %1
  %8 = load i64, ptr %7, align 8, !tbaa !5
  store i64 %8, ptr %4, align 8, !tbaa !5
  %9 = icmp sgt 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) #3
  %.pre = load i64, ptr %4, align 8, !tbaa !5
  %.pre12 = load i64, ptr %3, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %10, %2
  %12 = phi i64 [ %.pre12, %10 ], [ %6, %2 ]
  %13 = phi i64 [ %.pre, %10 ], [ %8, %2 ]
  %14 = sub nsw i64 %13, %12
  %15 = call noundef double @_ZSt4log2IxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %14)
  %16 = load i64, ptr %3, align 8, !tbaa !5
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = icmp eq i64 %16, %17
  br i1 %18, label %35, label %19

19:                                               ; preds = %11
  %20 = fptosi double %15 to i64
  %21 = getelementptr inbounds [200010 x [20 x i64]], ptr @dp, i64 0, i64 %16, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds [200010 x i64], ptr @level, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = trunc i64 %20 to i32
  %26 = shl nuw i32 1, %25
  %27 = sext i32 %26 to i64
  %28 = add i64 %17, 1
  %29 = sub i64 %28, %27
  %30 = getelementptr inbounds [200010 x [20 x i64]], ptr @dp, i64 0, i64 %29, i64 %20
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds [200010 x i64], ptr @level, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = icmp sgt i64 %24, %33
  %. = select i1 %34, i64 %31, i64 %22
  br label %35

35:                                               ; preds = %19, %11
  %.sink = phi i64 [ %16, %11 ], [ %., %19 ]
  %36 = getelementptr inbounds [200010 x i64], ptr @euler, i64 0, i64 %.sink
  %.0 = load i64, ptr %36, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i64 %.0
}

; 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 #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4log2IxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) local_unnamed_addr #1

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass