; LLVM IR from clibs/clib :: deps/gumbo-parser (tokenizer)

; 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.GumboInternalToken = type { i32, %struct.GumboSourcePosition, %struct.GumboStringPiece, %union.anon }
%struct.GumboSourcePosition = type { i32, i32, i32 }
%struct.GumboStringPiece = type { ptr, i64 }
%union.anon = type { %struct.GumboInternalTokenDocType }
%struct.GumboInternalTokenDocType = type { ptr, ptr, ptr, i8, i8, i8 }
%struct.GumboInternalTokenStartTag = type { i32, %struct.GumboVector, i8 }
%struct.GumboVector = type { ptr, i32, i32 }

; 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 void @gumbo_parser_deallocate(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @gumbo_token_destroy(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  br label %72

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.GumboInternalToken, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !9
  switch i32 %13, label %71 [
    i32 0, label %14
    i32 1, label %30
    i32 3, label %66
  ]

14:                                               ; preds = %10
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.GumboInternalToken, ptr %16, i32 0, i32 3
  %18 = getelementptr inbounds %struct.GumboInternalTokenDocType, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  call void @gumbo_parser_deallocate(ptr noundef %15, ptr noundef %19)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.GumboInternalToken, ptr %21, i32 0, i32 3
  %23 = getelementptr inbounds %struct.GumboInternalTokenDocType, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  call void @gumbo_parser_deallocate(ptr noundef %20, ptr noundef %24)
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.GumboInternalToken, ptr %26, i32 0, i32 3
  %28 = getelementptr inbounds %struct.GumboInternalTokenDocType, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  call void @gumbo_parser_deallocate(ptr noundef %25, ptr noundef %29)
  br label %72

30:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !16
  br label %31

31:                                               ; preds = %56, %30
  %32 = load i32, ptr %5, align 4, !tbaa !16
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.GumboInternalToken, ptr %33, i32 0, i32 3
  %35 = getelementptr inbounds %struct.GumboInternalTokenStartTag, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds %struct.GumboVector, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = icmp ult i32 %32, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %59

40:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.GumboInternalToken, ptr %41, i32 0, i32 3
  %43 = getelementptr inbounds %struct.GumboInternalTokenStartTag, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.GumboVector, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = load i32, ptr %5, align 4, !tbaa !16
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds ptr, ptr %45, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  store ptr %49, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %55

52:                                               ; preds = %40
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  call void @gumbo_destroy_attribute(ptr noundef %53, ptr noundef %54)
  br label %55

55:                                               ; preds = %52, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %5, align 4, !tbaa !16
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %5, align 4, !tbaa !16
  br label %31, !llvm.loop !17

59:                                               ; preds = %39
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.GumboInternalToken, ptr %61, i32 0, i32 3
  %63 = getelementptr inbounds %struct.GumboInternalTokenStartTag, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.GumboVector, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !15
  call void @gumbo_parser_deallocate(ptr noundef %60, ptr noundef %65)
  br label %72

66:                                               ; preds = %10
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.GumboInternalToken, ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  call void @gumbo_parser_deallocate(ptr noundef %67, ptr noundef %70)
  br label %72

71:                                               ; preds = %10
  br label %72

72:                                               ; preds = %71, %66, %59, %14, %9
  ret void
}

declare void @gumbo_destroy_attribute(ptr noundef, ptr noundef) #1

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 = !{!"GumboInternalToken", !11, i64 0, !12, i64 4, !13, i64 16, !7, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!13 = !{!"", !6, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

declare void @gumbo_parser_deallocate(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @gumbo_token_destroy(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %26, label %3

3:                                                ; preds = %2
  %4 = load i32, ptr %1, align 8, !tbaa !5
  switch i32 %4, label %26 [
    i32 0, label %8
    i32 1, label %.preheader
    i32 3, label %23
  ]

.preheader:                                       ; preds = %3
  %5 = getelementptr inbounds i8, ptr %1, i64 40
  %6 = getelementptr inbounds i8, ptr %1, i64 48
  %7 = load i32, ptr %6, align 8, !tbaa !14
  %.not23 = icmp eq i32 %7, 0
  br i1 %.not23, label %.sink.split, label %.lr.ph

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %1, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  tail call void @gumbo_parser_deallocate(ptr noundef %0, ptr noundef %10) #2
  %11 = getelementptr inbounds i8, ptr %1, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  tail call void @gumbo_parser_deallocate(ptr noundef %0, ptr noundef %12) #2
  %13 = getelementptr inbounds i8, ptr %1, i64 48
  br label %.sink.split

.lr.ph:                                           ; preds = %.preheader, %19
  %14 = phi i32 [ %20, %19 ], [ %7, %.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %19 ], [ 0, %.preheader ]
  %15 = load ptr, ptr %5, align 8, !tbaa !14
  %16 = getelementptr inbounds ptr, ptr %15, i64 %indvars.iv
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %.not21 = icmp eq ptr %17, null
  br i1 %.not21, label %19, label %18

18:                                               ; preds = %.lr.ph
  tail call void @gumbo_destroy_attribute(ptr noundef %0, ptr noundef nonnull %17) #2
  %.pre = load i32, ptr %6, align 8, !tbaa !14
  br label %19

19:                                               ; preds = %18, %.lr.ph
  %20 = phi i32 [ %.pre, %18 ], [ %14, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = zext i32 %20 to i64
  %22 = icmp ult i64 %indvars.iv.next, %21
  br i1 %22, label %.lr.ph, label %.sink.split, !llvm.loop !16

23:                                               ; preds = %3
  %24 = getelementptr inbounds i8, ptr %1, i64 32
  br label %.sink.split

.sink.split:                                      ; preds = %19, %.preheader, %8, %23
  %.sink25 = phi ptr [ %24, %23 ], [ %13, %8 ], [ %5, %.preheader ], [ %5, %19 ]
  %25 = load ptr, ptr %.sink25, align 8, !tbaa !14
  tail call void @gumbo_parser_deallocate(ptr noundef %0, ptr noundef %25) #2
  br label %26

26:                                               ; preds = %.sink.split, %3, %2
  ret void
}

declare void @gumbo_destroy_attribute(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 #2 = { 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, !7, i64 0}
!6 = !{!"GumboInternalToken", !7, i64 0, !10, i64 4, !11, i64 16, !8, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!11 = !{!"", !12, i64 0, !13, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!8, !8, i64 0}
!15 = !{!12, !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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