; LLVM IR from bartobri/data-structures-c :: symbol-table/extendable-hashing (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.anon = type { i32, i32 }
%struct.STnode = type { [6 x ptr], i32, i32 }

@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1

; 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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @STsplit(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @STinsertS(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.anon, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %10, ptr %7, align 4, !tbaa !12
  store i32 0, ptr %6, align 4, !tbaa !12
  br label %11

11:                                               ; preds = %30, %2
  %12 = load i32, ptr %6, align 4, !tbaa !12
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.STnode, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %16 = icmp slt i32 %12, %15
  br i1 %16, label %17, label %33

17:                                               ; preds = %11
  %18 = load i32, ptr %7, align 4, !tbaa !12
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.STnode, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %6, align 4, !tbaa !12
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [6 x ptr], ptr %20, i64 0, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.anon, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = icmp slt i32 %18, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %17
  br label %33

29:                                               ; preds = %17
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %6, align 4, !tbaa !12
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %6, align 4, !tbaa !12
  br label %11, !llvm.loop !15

33:                                               ; preds = %28, %11
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.STnode, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !13
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 8, !tbaa !13
  store i32 %36, ptr %5, align 4, !tbaa !12
  br label %38

38:                                               ; preds = %55, %33
  %39 = load i32, ptr %5, align 4, !tbaa !12
  %40 = load i32, ptr %6, align 4, !tbaa !12
  %41 = icmp sgt i32 %39, %40
  br i1 %41, label %42, label %58

42:                                               ; preds = %38
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.STnode, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %5, align 4, !tbaa !12
  %46 = sub nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [6 x ptr], ptr %44, i64 0, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.STnode, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %5, align 4, !tbaa !12
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [6 x ptr], ptr %51, i64 0, i64 %53
  store ptr %49, ptr %54, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %42
  %56 = load i32, ptr %5, align 4, !tbaa !12
  %57 = add nsw i32 %56, -1
  store i32 %57, ptr %5, align 4, !tbaa !12
  br label %38, !llvm.loop !17

58:                                               ; preds = %38
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.STnode, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %6, align 4, !tbaa !12
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [6 x ptr], ptr %61, i64 0, i64 %63
  store ptr %59, ptr %64, align 8, !tbaa !5
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.STnode, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !13
  %68 = icmp eq i32 %67, 6
  br i1 %68, label %69, label %73

69:                                               ; preds = %58
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = call ptr @STsplit(ptr noundef %71)
  br label %73

73:                                               ; preds = %69, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 48}
!14 = !{!"STnode", !7, i64 0, !11, i64 48, !11, i64 52}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !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"

@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @STsplit(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @STinsertS(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = load i32, ptr %4, align 8, !tbaa !10
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %11
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %11 ]
  %7 = getelementptr inbounds [6 x ptr], ptr %0, i64 0, i64 %indvars.iv
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp slt i32 %3, %9
  br i1 %10, label %._crit_edge, label %11

11:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.thread, label %.lr.ph, !llvm.loop !14

._crit_edge.thread:                               ; preds = %11, %2
  %.019.lcssa.ph = phi i32 [ 0, %2 ], [ %5, %11 ]
  %12 = add nsw i32 %5, 1
  store i32 %12, ptr %4, align 8, !tbaa !10
  br label %._crit_edge29

._crit_edge:                                      ; preds = %.lr.ph
  %13 = trunc nuw nsw i64 %indvars.iv to i32
  %14 = add nuw nsw i32 %5, 1
  store i32 %14, ptr %4, align 8, !tbaa !10
  %15 = icmp sgt i32 %5, %13
  br i1 %15, label %.lr.ph28.preheader, label %._crit_edge29

.lr.ph28.preheader:                               ; preds = %._crit_edge
  %16 = zext nneg i32 %5 to i64
  %sext = shl i64 %indvars.iv, 32
  %17 = ashr exact i64 %sext, 32
  %18 = sub nsw i64 %wide.trip.count, %indvars.iv
  %min.iters.check = icmp ult i64 %18, 4
  br i1 %min.iters.check, label %.lr.ph28.preheader45, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph28.preheader
  %n.vec = and i64 %18, -4
  %ind.end = sub i64 %16, %n.vec
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = sub i64 %16, %index
  %19 = add nsw i64 %offset.idx, -1
  %20 = getelementptr inbounds [6 x ptr], ptr %0, i64 0, i64 %19
  %21 = getelementptr inbounds i8, ptr %20, i64 -8
  %22 = getelementptr inbounds i8, ptr %20, i64 -24
  %wide.load = load <2 x ptr>, ptr %21, align 8, !tbaa !12
  %wide.load41 = load <2 x ptr>, ptr %22, align 8, !tbaa !12
  %23 = getelementptr inbounds [6 x ptr], ptr %0, i64 0, i64 %offset.idx
  %24 = getelementptr inbounds i8, ptr %23, i64 -8
  %25 = getelementptr inbounds i8, ptr %23, i64 -24
  store <2 x ptr> %wide.load, ptr %24, align 8, !tbaa !12
  store <2 x ptr> %wide.load41, ptr %25, align 8, !tbaa !12
  %index.next = add nuw i64 %index, 4
  %26 = icmp eq i64 %index.next, %n.vec
  br i1 %26, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %18, %n.vec
  br i1 %cmp.n, label %._crit_edge29, label %.lr.ph28.preheader45

.lr.ph28.preheader45:                             ; preds = %middle.block, %.lr.ph28.preheader
  %indvars.iv32.ph = phi i64 [ %16, %.lr.ph28.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph28

.lr.ph28:                                         ; preds = %.lr.ph28.preheader45, %.lr.ph28
  %indvars.iv32 = phi i64 [ %indvars.iv.next33, %.lr.ph28 ], [ %indvars.iv32.ph, %.lr.ph28.preheader45 ]
  %indvars.iv.next33 = add nsw i64 %indvars.iv32, -1
  %27 = getelementptr inbounds [6 x ptr], ptr %0, i64 0, i64 %indvars.iv.next33
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %29 = getelementptr inbounds [6 x ptr], ptr %0, i64 0, i64 %indvars.iv32
  store ptr %28, ptr %29, align 8, !tbaa !12
  %30 = icmp sgt i64 %indvars.iv.next33, %17
  br i1 %30, label %.lr.ph28, label %._crit_edge29, !llvm.loop !19

._crit_edge29:                                    ; preds = %.lr.ph28, %middle.block, %._crit_edge.thread, %._crit_edge
  %31 = phi i32 [ %12, %._crit_edge.thread ], [ %14, %._crit_edge ], [ %14, %middle.block ], [ %14, %.lr.ph28 ]
  %.019.lcssa36 = phi i32 [ %.019.lcssa.ph, %._crit_edge.thread ], [ %13, %._crit_edge ], [ %13, %middle.block ], [ %13, %.lr.ph28 ]
  %32 = zext nneg i32 %.019.lcssa36 to i64
  %33 = getelementptr inbounds [6 x ptr], ptr %0, i64 0, i64 %32
  store ptr %1, ptr %33, align 8, !tbaa !12
  %34 = icmp eq i32 %31, 6
  br i1 %34, label %35, label %38

35:                                               ; preds = %._crit_edge29
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %37 = tail call ptr @STsplit(ptr noundef nonnull %0)
  br label %38

38:                                               ; preds = %35, %._crit_edge29
  ret void
}

attributes #0 = { nofree nounwind "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 #1 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 48}
!11 = !{!"STnode", !8, i64 0, !7, i64 48, !7, i64 52}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15, !17, !18}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = distinct !{!19, !15, !18, !17}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass