; LLVM IR from IlyaGrebnov/libsais :: src (libsais16x64)

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

; Function Attrs: nounwind uwtable
declare hidden void @libsais16x64_compute_phi_omp(ptr noalias noundef, ptr noalias noundef, i64 noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i64 @libsais16x64_plcp_gsa(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %32, label %12

12:                                               ; preds = %4
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %32, label %15

15:                                               ; preds = %12
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %32, label %18

18:                                               ; preds = %15
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = icmp slt i64 %19, 0
  br i1 %20, label %32, label %21

21:                                               ; preds = %18
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = icmp sgt i64 %22, 0
  br i1 %23, label %24, label %33

24:                                               ; preds = %21
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i64, ptr %9, align 8, !tbaa !9
  %27 = sub nsw i64 %26, 1
  %28 = getelementptr inbounds i16, ptr %25, i64 %27
  %29 = load i16, ptr %28, align 2, !tbaa !11
  %30 = zext i16 %29 to i32
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %24, %18, %15, %12, %4
  store i64 -1, ptr %5, align 8
  br label %51

33:                                               ; preds = %24, %21
  %34 = load i64, ptr %9, align 8, !tbaa !9
  %35 = icmp sle i64 %34, 1
  br i1 %35, label %36, label %43

36:                                               ; preds = %33
  %37 = load i64, ptr %9, align 8, !tbaa !9
  %38 = icmp eq i64 %37, 1
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds i64, ptr %40, i64 0
  store i64 0, ptr %41, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %39, %36
  store i64 0, ptr %5, align 8
  br label %51

43:                                               ; preds = %33
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i64, ptr %9, align 8, !tbaa !9
  call void @libsais16x64_compute_phi_omp(ptr noundef %45, ptr noundef %46, i64 noundef %47, i64 noundef 1)
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load i64, ptr %9, align 8, !tbaa !9
  call void @libsais16x64_compute_plcp_gsa_omp(ptr noundef %48, ptr noundef %49, i64 noundef %50, i64 noundef 1)
  store i64 0, ptr %5, align 8
  br label %51

51:                                               ; preds = %44, %42, %32
  %52 = load i64, ptr %5, align 8
  ret i64 %52
}

; Function Attrs: nounwind uwtable
declare hidden void @libsais16x64_compute_plcp_gsa_omp(ptr noalias noundef, ptr noalias noundef, i64 noundef, i64 noundef) #0

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

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}


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

; Function Attrs: nounwind uwtable
declare hidden void @libsais16x64_compute_phi_omp(ptr noalias noundef, ptr noalias noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -1, 1) i64 @libsais16x64_plcp_gsa(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %0, null
  %6 = icmp eq ptr %1, null
  %or.cond = or i1 %5, %6
  %7 = icmp eq ptr %2, null
  %or.cond3 = or i1 %or.cond, %7
  %8 = icmp slt i64 %3, 0
  %or.cond5 = or i1 %or.cond3, %8
  br i1 %or.cond5, label %18, label %9

9:                                                ; preds = %4
  %.not26 = icmp eq i64 %3, 0
  br i1 %.not26, label %18, label %10

10:                                               ; preds = %9
  %11 = getelementptr i16, ptr %0, i64 %3
  %12 = getelementptr i8, ptr %11, i64 -2
  %13 = load i16, ptr %12, align 2, !tbaa !5
  %.not = icmp eq i16 %13, 0
  br i1 %.not, label %14, label %18

14:                                               ; preds = %10
  %15 = icmp eq i64 %3, 1
  br i1 %15, label %16, label %17

16:                                               ; preds = %14
  store i64 0, ptr %2, align 8, !tbaa !9
  br label %18

17:                                               ; preds = %14
  tail call void @libsais16x64_compute_phi_omp(ptr noundef nonnull %1, ptr noundef nonnull %2, i64 noundef %3, i64 noundef 1)
  tail call void @libsais16x64_compute_plcp_gsa_omp(ptr noundef nonnull %0, ptr noundef nonnull %2, i64 noundef %3, i64 noundef 1)
  br label %18

18:                                               ; preds = %9, %16, %4, %10, %17
  %.0 = phi i64 [ 0, %17 ], [ -1, %10 ], [ -1, %4 ], [ 0, %16 ], [ 0, %9 ]
  ret i64 %.0
}

; Function Attrs: nounwind uwtable
declare hidden void @libsais16x64_compute_plcp_gsa_omp(ptr noalias noundef, ptr noalias noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass