; 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.GumboInternalParser = type { ptr, ptr, ptr, ptr }
%struct.GumboInternalTokenizerState = type { i32, i8, i8, i32, %struct.GumboStringBuffer, ptr, %struct.GumboStringBuffer, ptr, %struct.GumboSourcePosition, %struct.GumboInternalTagState, %struct.GumboInternalTokenDocType, %struct.GumboInternalUtf8Iterator }
%struct.GumboStringBuffer = type { ptr, i64, i64 }
%struct.GumboSourcePosition = type { i32, i32, i32 }
%struct.GumboInternalTagState = type { %struct.GumboStringBuffer, ptr, i32, %struct.GumboSourcePosition, %struct.GumboVector, i8, i32, i32, i8, i8 }
%struct.GumboVector = type { ptr, i32, i32 }
%struct.GumboInternalTokenDocType = type { ptr, ptr, ptr, i8, i8, i8 }
%struct.GumboInternalUtf8Iterator = type { ptr, ptr, ptr, i32, i32, %struct.GumboSourcePosition, %struct.GumboSourcePosition, ptr }

@.str.5 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @gumbo_tokenizer_set_is_current_node_foreign(ptr noundef %0, i1 noundef zeroext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = zext i1 %1 to i8
  store i8 %5, ptr %4, align 1, !tbaa !9
  %6 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc i8 %6 to i1
  %8 = zext i1 %7 to i32
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.GumboInternalParser, ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds %struct.GumboInternalTokenizerState, ptr %11, i32 0, i32 2
  %13 = load i8, ptr %12, align 1, !tbaa !15, !range !11, !noundef !12
  %14 = trunc i8 %13 to i1
  %15 = zext i1 %14 to i32
  %16 = icmp ne i32 %8, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %2
  %18 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %19 = trunc i8 %18 to i1
  %20 = zext i1 %19 to i64
  %21 = select i1 %19, ptr @.str.6, ptr @.str.7
  call void (ptr, ...) @gumbo_debug(ptr noundef @.str.5, ptr noundef %21)
  br label %22

22:                                               ; preds = %17, %2
  %23 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %24 = trunc i8 %23 to i1
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.GumboInternalParser, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds %struct.GumboInternalTokenizerState, ptr %27, i32 0, i32 2
  %29 = zext i1 %24 to i8
  store i8 %29, ptr %28, align 1, !tbaa !15
  ret void
}

declare void @gumbo_debug(ptr noundef, ...) #1

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 = { "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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 16}
!14 = !{!"GumboInternalParser", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!16, !10, i64 5}
!16 = !{!"GumboInternalTokenizerState", !17, i64 0, !10, i64 4, !10, i64 5, !17, i64 8, !18, i64 16, !6, i64 40, !18, i64 48, !6, i64 72, !20, i64 80, !21, i64 96, !23, i64 176, !24, i64 208}
!17 = !{!"int", !7, i64 0}
!18 = !{!"", !6, i64 0, !19, i64 8, !19, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!"", !17, i64 0, !17, i64 4, !17, i64 8}
!21 = !{!"GumboInternalTagState", !18, i64 0, !6, i64 24, !17, i64 32, !20, i64 36, !22, i64 48, !10, i64 64, !17, i64 68, !17, i64 72, !10, i64 76, !10, i64 77}
!22 = !{!"", !6, i64 0, !17, i64 8, !17, i64 12}
!23 = !{!"GumboInternalTokenDocType", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 25, !10, i64 26}
!24 = !{!"GumboInternalUtf8Iterator", !6, i64 0, !6, i64 8, !6, i64 16, !17, i64 24, !17, i64 28, !20, i64 32, !20, i64 44, !6, i64 56}


; 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.5 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @gumbo_tokenizer_set_is_current_node_foreign(ptr nocapture noundef readonly %0, i1 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 5
  %6 = load i8, ptr %5, align 1, !tbaa !10, !range !21, !noundef !22
  %7 = zext i1 %1 to i8
  %.not = icmp eq i8 %6, %7
  br i1 %.not, label %10, label %8

8:                                                ; preds = %2
  %9 = select i1 %1, ptr @.str.6, ptr @.str.7
  tail call void (ptr, ...) @gumbo_debug(ptr noundef nonnull @.str.5, ptr noundef nonnull %9) #2
  %.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %8, %2
  %11 = phi ptr [ %.pre, %8 ], [ %4, %2 ]
  %12 = getelementptr inbounds i8, ptr %11, i64 5
  store i8 %7, ptr %12, align 1, !tbaa !10
  ret void
}

declare void @gumbo_debug(ptr noundef, ...) local_unnamed_addr #1

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 = { "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 16}
!6 = !{!"GumboInternalParser", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !13, i64 5}
!11 = !{!"GumboInternalTokenizerState", !12, i64 0, !13, i64 4, !13, i64 5, !12, i64 8, !14, i64 16, !7, i64 40, !14, i64 48, !7, i64 72, !16, i64 80, !17, i64 96, !19, i64 176, !20, i64 208}
!12 = !{!"int", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!"", !7, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"long", !8, i64 0}
!16 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!17 = !{!"GumboInternalTagState", !14, i64 0, !7, i64 24, !12, i64 32, !16, i64 36, !18, i64 48, !13, i64 64, !12, i64 68, !12, i64 72, !13, i64 76, !13, i64 77}
!18 = !{!"", !7, i64 0, !12, i64 8, !12, i64 12}
!19 = !{!"GumboInternalTokenDocType", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !13, i64 25, !13, i64 26}
!20 = !{!"GumboInternalUtf8Iterator", !7, i64 0, !7, i64 8, !7, i64 16, !12, i64 24, !12, i64 28, !16, i64 32, !16, i64 44, !7, i64 56}
!21 = !{i8 0, i8 2}
!22 = !{}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass