; LLVM IR from brpapa/algorithms :: solutions/uri/1200.ll (Z3bstP4lldec)

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

%struct.llde = type { i8, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z3bstP4lldec(ptr noundef %0, i8 noundef signext %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %46

8:                                                ; preds = %2
  %9 = load i8, ptr %5, align 1, !tbaa !9
  %10 = sext i8 %9 to i32
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.llde, ptr %11, i32 0, i32 0
  %13 = load i8, ptr %12, align 8, !tbaa !10
  %14 = sext i8 %13 to i32
  %15 = icmp eq i32 %10, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %8
  store i1 true, ptr %3, align 1
  br label %47

17:                                               ; preds = %8
  %18 = load i8, ptr %5, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.llde, ptr %20, i32 0, i32 0
  %22 = load i8, ptr %21, align 8, !tbaa !10
  %23 = sext i8 %22 to i32
  %24 = icmp slt i32 %19, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %17
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.llde, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %29 = load i8, ptr %5, align 1, !tbaa !9
  %30 = call noundef zeroext i1 @_Z3bstP4lldec(ptr noundef %28, i8 noundef signext %29)
  store i1 %30, ptr %3, align 1
  br label %47

31:                                               ; preds = %17
  %32 = load i8, ptr %5, align 1, !tbaa !9
  %33 = sext i8 %32 to i32
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.llde, ptr %34, i32 0, i32 0
  %36 = load i8, ptr %35, align 8, !tbaa !10
  %37 = sext i8 %36 to i32
  %38 = icmp sgt i32 %33, %37
  br i1 %38, label %39, label %45

39:                                               ; preds = %31
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.llde, ptr %40, i32 0, i32 2
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = load i8, ptr %5, align 1, !tbaa !9
  %44 = call noundef zeroext i1 @_Z3bstP4lldec(ptr noundef %42, i8 noundef signext %43)
  store i1 %44, ptr %3, align 1
  br label %47

45:                                               ; preds = %31
  br label %46

46:                                               ; preds = %45, %2
  store i1 false, ptr %3, align 1
  br label %47

47:                                               ; preds = %46, %39, %25, %16
  %48 = load i1, ptr %3, align 1
  ret i1 %48
}

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

!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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 0}
!11 = !{!"_ZTS4llde", !7, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!11, !6, i64 8}
!13 = !{!11, !6, i64 16}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z3bstP4lldec(ptr noundef readonly %0, i8 noundef signext %1) local_unnamed_addr #0 {
  %.not15 = icmp eq ptr %0, null
  br i1 %.not15, label %tailrecurse._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %tailrecurse.backedge
  %.tr16 = phi ptr [ %.tr.be, %tailrecurse.backedge ], [ %0, %2 ]
  %3 = load i8, ptr %.tr16, align 8, !tbaa !5
  %4 = icmp eq i8 %3, %1
  br i1 %4, label %tailrecurse._crit_edge, label %5

5:                                                ; preds = %.lr.ph
  %6 = icmp sgt i8 %3, %1
  br i1 %6, label %tailrecurse.backedge, label %8

tailrecurse.backedge:                             ; preds = %5, %8
  %.sink = phi i64 [ 16, %8 ], [ 8, %5 ]
  %7 = getelementptr inbounds i8, ptr %.tr16, i64 %.sink
  %.tr.be = load ptr, ptr %7, align 8, !tbaa !10
  %.not = icmp eq ptr %.tr.be, null
  br i1 %.not, label %tailrecurse._crit_edge, label %.lr.ph

8:                                                ; preds = %5
  %9 = icmp slt i8 %3, %1
  br i1 %9, label %tailrecurse.backedge, label %tailrecurse._crit_edge

tailrecurse._crit_edge:                           ; preds = %.lr.ph, %8, %tailrecurse.backedge, %2
  %.0 = phi i1 [ false, %2 ], [ %4, %tailrecurse.backedge ], [ %4, %8 ], [ %4, %.lr.ph ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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, !7, i64 0}
!6 = !{!"_ZTS4llde", !7, i64 0, !9, i64 8, !9, i64 16}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!9, !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass