; LLVM IR from bartobri/data-structures-c :: symbol-table/skip-list (st)

; 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.STnode = type { ptr, ptr, i32 }
%struct.anon = type { i8, i32 }

@z = external hidden global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @STsearchR(ptr noundef %0, i8 noundef signext %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !10
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr @z, align 8, !tbaa !5
  %10 = icmp eq ptr %8, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %79

12:                                               ; preds = %3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.STnode, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %32

17:                                               ; preds = %12
  %18 = load i8, ptr %6, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.STnode, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = getelementptr inbounds %struct.anon, ptr %22, i32 0, i32 0
  %24 = load i8, ptr %23, align 4, !tbaa !14
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %19, %25
  br i1 %26, label %27, label %31

27:                                               ; preds = %17
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.STnode, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !12
  store ptr %30, ptr %4, align 8
  br label %79

31:                                               ; preds = %17
  br label %32

32:                                               ; preds = %31, %12
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.STnode, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = load i32, ptr %7, align 4, !tbaa !10
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %35, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load ptr, ptr @z, align 8, !tbaa !5
  %41 = icmp eq ptr %39, %40
  br i1 %41, label %58, label %42

42:                                               ; preds = %32
  %43 = load i8, ptr %6, align 1, !tbaa !9
  %44 = sext i8 %43 to i32
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.STnode, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = load i32, ptr %7, align 4, !tbaa !10
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.STnode, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !12
  %54 = getelementptr inbounds %struct.anon, ptr %53, i32 0, i32 0
  %55 = load i8, ptr %54, align 4, !tbaa !14
  %56 = sext i8 %55 to i32
  %57 = icmp slt i32 %44, %56
  br i1 %57, label %58, label %68

58:                                               ; preds = %42, %32
  %59 = load i32, ptr %7, align 4, !tbaa !10
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %58
  store ptr null, ptr %4, align 8
  br label %79

62:                                               ; preds = %58
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i8, ptr %6, align 1, !tbaa !9
  %65 = load i32, ptr %7, align 4, !tbaa !10
  %66 = sub nsw i32 %65, 1
  %67 = call ptr @STsearchR(ptr noundef %63, i8 noundef signext %64, i32 noundef %66)
  store ptr %67, ptr %4, align 8
  br label %79

68:                                               ; preds = %42
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.STnode, ptr %69, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !16
  %72 = load i32, ptr %7, align 4, !tbaa !10
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds ptr, ptr %71, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = load i8, ptr %6, align 1, !tbaa !9
  %77 = load i32, ptr %7, align 4, !tbaa !10
  %78 = call ptr @STsearchR(ptr noundef %75, i8 noundef signext %76, i32 noundef %77)
  store ptr %78, ptr %4, align 8
  br label %79

79:                                               ; preds = %68, %62, %61, %27, %11
  %80 = load ptr, ptr %4, align 8
  ret ptr %80
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"STnode", !6, i64 0, !6, i64 8, !11, i64 16}
!14 = !{!15, !7, i64 0}
!15 = !{!"", !7, i64 0, !11, i64 4}
!16 = !{!13, !6, i64 8}


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

@z = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @STsearchR(ptr noundef readonly %0, i8 noundef signext %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr @z, align 8, !tbaa !5
  %5 = icmp eq ptr %4, %0
  br i1 %5, label %tailrecurse.outer._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %.pre = load ptr, ptr %0, align 8, !tbaa !9
  br label %.lr.ph

tailrecurse.outer.loopexit:                       ; preds = %27, %14
  %6 = phi ptr [ %15, %14 ], [ %28, %27 ]
  %.us-phi.in = phi i64 [ %indvars.iv63, %14 ], [ %indvars.iv, %27 ]
  %.us-phi30 = phi ptr [ %12, %14 ], [ %25, %27 ]
  %.us-phi = trunc i64 %.us-phi.in to i32
  br label %.lr.ph

.lr.ph:                                           ; preds = %tailrecurse.outer.loopexit, %.lr.ph.preheader
  %7 = phi ptr [ %6, %tailrecurse.outer.loopexit ], [ %.pre, %.lr.ph.preheader ]
  %.tr23.ph48 = phi i32 [ %.us-phi, %tailrecurse.outer.loopexit ], [ %2, %.lr.ph.preheader ]
  %.tr.ph47 = phi ptr [ %.us-phi30, %tailrecurse.outer.loopexit ], [ %0, %.lr.ph.preheader ]
  %.not = icmp eq ptr %7, null
  %8 = getelementptr inbounds i8, ptr %.tr.ph47, i64 8
  br i1 %.not, label %.lr.ph.split.us.split.preheader, label %.lr.ph.split

.lr.ph.split.us.split.preheader:                  ; preds = %.lr.ph
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = sext i32 %.tr23.ph48 to i64
  br label %.lr.ph.split.us.split

.lr.ph.split.us.split:                            ; preds = %.lr.ph.split.us.split.preheader, %tailrecurse.us
  %indvars.iv63 = phi i64 [ %10, %.lr.ph.split.us.split.preheader ], [ %indvars.iv.next64, %tailrecurse.us ]
  %11 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv63
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = icmp eq ptr %12, %4
  br i1 %13, label %18, label %14

14:                                               ; preds = %.lr.ph.split.us.split
  %15 = load ptr, ptr %12, align 8, !tbaa !9
  %16 = load i8, ptr %15, align 4, !tbaa !13
  %17 = icmp sgt i8 %16, %1
  br i1 %17, label %18, label %tailrecurse.outer.loopexit

18:                                               ; preds = %14, %.lr.ph.split.us.split
  %19 = icmp eq i64 %indvars.iv63, 0
  br i1 %19, label %tailrecurse.outer._crit_edge, label %tailrecurse.us

tailrecurse.us:                                   ; preds = %18
  %indvars.iv.next64 = add nsw i64 %indvars.iv63, -1
  br label %.lr.ph.split.us.split

.lr.ph.split:                                     ; preds = %.lr.ph
  %20 = load i8, ptr %7, align 4, !tbaa !13
  %21 = icmp eq i8 %20, %1
  br i1 %21, label %tailrecurse.outer._crit_edge, label %.lr.ph.split.split.split.preheader

.lr.ph.split.split.split.preheader:               ; preds = %.lr.ph.split
  %22 = load ptr, ptr %8, align 8, !tbaa !12
  %23 = sext i32 %.tr23.ph48 to i64
  br label %.lr.ph.split.split.split

.lr.ph.split.split.split:                         ; preds = %.lr.ph.split.split.split.preheader, %tailrecurse
  %indvars.iv = phi i64 [ %23, %.lr.ph.split.split.split.preheader ], [ %indvars.iv.next, %tailrecurse ]
  %24 = getelementptr inbounds ptr, ptr %22, i64 %indvars.iv
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = icmp eq ptr %25, %4
  br i1 %26, label %31, label %27

27:                                               ; preds = %.lr.ph.split.split.split
  %28 = load ptr, ptr %25, align 8, !tbaa !9
  %29 = load i8, ptr %28, align 4, !tbaa !13
  %30 = icmp sgt i8 %29, %1
  br i1 %30, label %31, label %tailrecurse.outer.loopexit

31:                                               ; preds = %27, %.lr.ph.split.split.split
  %32 = icmp eq i64 %indvars.iv, 0
  br i1 %32, label %tailrecurse.outer._crit_edge, label %tailrecurse

tailrecurse:                                      ; preds = %31
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  br label %.lr.ph.split.split.split

tailrecurse.outer._crit_edge:                     ; preds = %.lr.ph.split, %31, %18, %3
  %.0 = phi ptr [ null, %3 ], [ null, %18 ], [ null, %31 ], [ %7, %.lr.ph.split ]
  ret ptr %.0
}

attributes #0 = { nofree norecurse nosync nounwind 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"STnode", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !7, i64 0}
!14 = !{!"", !7, i64 0, !11, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass