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

; 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.GumboInternalUtf8Iterator = type { ptr, ptr, ptr, i32, i32, %struct.GumboSourcePosition, %struct.GumboSourcePosition, ptr }
%struct.GumboSourcePosition = type { i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @utf8iterator_init(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %8, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %10, i32 0, i32 0
  store ptr %9, ptr %11, align 8, !tbaa !11
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %12, i64 %13
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %15, i32 0, i32 2
  store ptr %14, ptr %16, align 8, !tbaa !15
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %17, i32 0, i32 4
  store i32 0, ptr %18, align 4, !tbaa !16
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %19, i32 0, i32 5
  %21 = getelementptr inbounds %struct.GumboSourcePosition, ptr %20, i32 0, i32 0
  store i32 1, ptr %21, align 8, !tbaa !17
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %22, i32 0, i32 5
  %24 = getelementptr inbounds %struct.GumboSourcePosition, ptr %23, i32 0, i32 1
  store i32 1, ptr %24, align 4, !tbaa !18
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %25, i32 0, i32 5
  %27 = getelementptr inbounds %struct.GumboSourcePosition, ptr %26, i32 0, i32 2
  store i32 0, ptr %27, align 8, !tbaa !19
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %29, i32 0, i32 7
  store ptr %28, ptr %30, align 8, !tbaa !20
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %4
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  call void @read_char(ptr noundef %34)
  br label %38

35:                                               ; preds = %4
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %36, i32 0, i32 3
  store i32 -1, ptr %37, align 8, !tbaa !21
  br label %38

38:                                               ; preds = %35, %33
  ret void
}

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

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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"GumboInternalUtf8Iterator", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !13, i64 28, !14, i64 32, !14, i64 44, !6, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !13, i64 28}
!17 = !{!12, !13, i64 32}
!18 = !{!12, !13, i64 36}
!19 = !{!12, !13, i64 40}
!20 = !{!12, !6, i64 56}
!21 = !{!12, !13, i64 24}


; 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 void @utf8iterator_init(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  store ptr %1, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 %2
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %5, ptr %6, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %3, i64 28
  store <4 x i32> <i32 0, i32 1, i32 1, i32 0>, ptr %7, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %3, i64 56
  store ptr %0, ptr %8, align 8, !tbaa !14
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %10, label %9

9:                                                ; preds = %4
  tail call void @read_char(ptr noundef nonnull %3)
  br label %12

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 -1, ptr %11, align 8, !tbaa !15
  br label %12

12:                                               ; preds = %10, %9
  ret void
}

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

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, !7, i64 0}
!6 = !{!"GumboInternalUtf8Iterator", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !11, i64 32, !11, i64 44, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!12 = !{!6, !7, i64 16}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !7, i64 56}
!15 = !{!6, !10, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass