; LLVM IR from clibs/clib :: deps/gumbo-text-content (gumbo-text-content)

; 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.text_nodes_t = type { [1024 x ptr], i64 }

; Function Attrs: nounwind uwtable
define dso_local ptr @gumbo_text_content(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !11
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call ptr @get_text_nodes(ptr noundef %10)
  store ptr %11, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %1
  br label %81

15:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %32, %15
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.text_nodes_t, ptr %18, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !13
  %21 = icmp ult i64 %17, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %35

23:                                               ; preds = %16
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.text_nodes_t, ptr %24, i32 0, i32 0
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = getelementptr inbounds [1024 x ptr], ptr %25, i64 0, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = call i64 @strlen(ptr noundef %28) #6
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = add i64 %30, %29
  store i64 %31, ptr %5, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %23
  %33 = load i64, ptr %7, align 8, !tbaa !9
  %34 = add i64 %33, 1
  store i64 %34, ptr %7, align 8, !tbaa !9
  br label %16, !llvm.loop !15

35:                                               ; preds = %22
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = call noalias ptr @malloc(i64 noundef %36) #7
  store ptr %37, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  br label %81

41:                                               ; preds = %35
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  store i8 0, ptr %42, align 1, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %77, %41
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.text_nodes_t, ptr %45, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !13
  %48 = icmp ult i64 %44, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %80

50:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.text_nodes_t, ptr %51, i32 0, i32 0
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = getelementptr inbounds [1024 x ptr], ptr %52, i64 0, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = call i64 @strlen(ptr noundef %55) #6
  store i64 %56, ptr %9, align 8, !tbaa !9
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load i32, ptr %6, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %57, i64 %59
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.text_nodes_t, ptr %61, i32 0, i32 0
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = getelementptr inbounds [1024 x ptr], ptr %62, i64 0, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load i64, ptr %9, align 8, !tbaa !9
  %67 = call ptr @strncat(ptr noundef %60, ptr noundef %65, i64 noundef %66) #5
  %68 = load i64, ptr %9, align 8, !tbaa !9
  %69 = load i32, ptr %6, align 4, !tbaa !11
  %70 = sext i32 %69 to i64
  %71 = add i64 %70, %68
  %72 = trunc i64 %71 to i32
  store i32 %72, ptr %6, align 4, !tbaa !11
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i8, ptr %73, i64 %75
  store i8 0, ptr %76, align 1, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %77

77:                                               ; preds = %50
  %78 = load i64, ptr %8, align 8, !tbaa !9
  %79 = add i64 %78, 1
  store i64 %79, ptr %8, align 8, !tbaa !9
  br label %43, !llvm.loop !18

80:                                               ; preds = %49
  br label %81

81:                                               ; preds = %80, %40, %14
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %82) #5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret ptr %83
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @get_text_nodes(ptr noundef) #0

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind
declare ptr @strncat(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 allocsize(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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 8192}
!14 = !{!"", !7, i64 0, !10, i64 8192}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !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: nounwind uwtable
define dso_local noundef ptr @gumbo_text_content(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call ptr @get_text_nodes(ptr noundef %0)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %1
  %3 = getelementptr inbounds i8, ptr %2, i64 8192
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not40 = icmp eq i64 %4, 0
  br i1 %.not40, label %._crit_edge.thread, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %5 = tail call noalias ptr @malloc(i64 noundef %10) #5
  %.not32 = icmp eq ptr %5, null
  br i1 %.not32, label %.loopexit, label %.lr.ph39.preheader

._crit_edge.thread:                               ; preds = %.preheader
  %6 = tail call noalias dereferenceable_or_null(1) ptr @malloc(i64 noundef 1) #5
  %.not3243 = icmp eq ptr %6, null
  br i1 %.not3243, label %.loopexit, label %.thread

.thread:                                          ; preds = %._crit_edge.thread
  store i8 0, ptr %6, align 1, !tbaa !10
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.02635 = phi i64 [ %11, %.lr.ph ], [ 0, %.preheader ]
  %.02834 = phi i64 [ %10, %.lr.ph ], [ 1, %.preheader ]
  %7 = getelementptr inbounds [1024 x ptr], ptr %2, i64 0, i64 %.02635
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %8) #6
  %10 = add i64 %9, %.02834
  %11 = add nuw i64 %.02635, 1
  %exitcond.not = icmp eq i64 %11, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

.lr.ph39.preheader:                               ; preds = %._crit_edge
  store i8 0, ptr %5, align 1, !tbaa !10
  br label %.lr.ph39

.lr.ph39:                                         ; preds = %.lr.ph39.preheader, %.lr.ph39
  %.037 = phi i64 [ %21, %.lr.ph39 ], [ 0, %.lr.ph39.preheader ]
  %.02736 = phi i64 [ %18, %.lr.ph39 ], [ 0, %.lr.ph39.preheader ]
  %12 = getelementptr inbounds [1024 x ptr], ptr %2, i64 0, i64 %.037
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %13) #6
  %sext = shl i64 %.02736, 32
  %15 = ashr exact i64 %sext, 32
  %16 = getelementptr inbounds i8, ptr %5, i64 %15
  %17 = tail call ptr @strncat(ptr noundef nonnull dereferenceable(1) %16, ptr noundef %13, i64 noundef %14) #7
  %18 = add i64 %14, %15
  %sext33 = shl i64 %18, 32
  %19 = ashr exact i64 %sext33, 32
  %20 = getelementptr inbounds i8, ptr %5, i64 %19
  store i8 0, ptr %20, align 1, !tbaa !10
  %21 = add nuw i64 %.037, 1
  %22 = icmp ult i64 %21, %4
  br i1 %22, label %.lr.ph39, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph39, %.thread, %._crit_edge.thread, %._crit_edge, %1
  %.029 = phi ptr [ null, %._crit_edge ], [ null, %1 ], [ null, %._crit_edge.thread ], [ %6, %.thread ], [ %5, %.lr.ph39 ]
  tail call void @free(ptr noundef %2) #7
  ret ptr %.029
}

; Function Attrs: nounwind uwtable
declare hidden ptr @get_text_nodes(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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, !9, i64 8192}
!6 = !{!"", !7, i64 0, !9, i64 8192}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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