; LLVM IR from IlyaGrebnov/libbsc :: libbsc/bwt/libsais (libsais)

; 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 @libsais_compute_phi_omp(ptr noalias noundef, ptr noalias noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @libsais_plcp_gsa(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  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 i32 %3, ptr %9, align 4, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %33, label %12

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

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

18:                                               ; preds = %15
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %33, label %21

21:                                               ; preds = %18
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %34

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

33:                                               ; preds = %24, %18, %15, %12, %4
  store i32 -1, ptr %5, align 4
  br label %52

34:                                               ; preds = %24, %21
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = icmp sle i32 %35, 1
  br i1 %36, label %37, label %44

37:                                               ; preds = %34
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %40, label %43

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

43:                                               ; preds = %40, %37
  store i32 0, ptr %5, align 4
  br label %52

44:                                               ; preds = %34
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i32, ptr %9, align 4, !tbaa !9
  call void @libsais_compute_phi_omp(ptr noundef %46, ptr noundef %47, i32 noundef %48, i32 noundef 1)
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i32, ptr %9, align 4, !tbaa !9
  call void @libsais_compute_plcp_gsa_omp(ptr noundef %49, ptr noundef %50, i32 noundef %51, i32 noundef 1)
  store i32 0, ptr %5, align 4
  br label %52

52:                                               ; preds = %45, %43, %33
  %53 = load i32, ptr %5, align 4
  ret i32 %53
}

; Function Attrs: nounwind uwtable
declare hidden void @libsais_compute_plcp_gsa_omp(ptr noalias noundef, ptr noalias noundef, i32 noundef, i32 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 = !{!"int", !7, i64 0}
!11 = !{!7, !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 @libsais_compute_phi_omp(ptr noalias noundef, ptr noalias noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @libsais_plcp_gsa(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 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 i32 %3, 0
  %or.cond5 = or i1 %or.cond3, %8
  br i1 %or.cond5, label %19, label %9

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

10:                                               ; preds = %9
  %11 = zext nneg i32 %3 to i64
  %12 = getelementptr i8, ptr %0, i64 %11
  %13 = getelementptr i8, ptr %12, i64 -1
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %.not = icmp eq i8 %14, 0
  br i1 %.not, label %15, label %19

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

17:                                               ; preds = %15
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %19

18:                                               ; preds = %15
  tail call void @libsais_compute_phi_omp(ptr noundef nonnull %1, ptr noundef nonnull %2, i32 noundef %3, i32 noundef 1)
  tail call void @libsais_compute_plcp_gsa_omp(ptr noundef nonnull %0, ptr noundef nonnull %2, i32 noundef %3, i32 noundef 1)
  br label %19

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

; Function Attrs: nounwind uwtable
declare hidden void @libsais_compute_plcp_gsa_omp(ptr noalias noundef, ptr noalias noundef, i32 noundef, i32 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}


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