; 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
declare dso_local void @utf8iterator_next(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @utf8iterator_maybe_consume_match(ptr noundef %0, ptr noundef %1, i64 noundef %2, i1 noundef zeroext %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  %13 = zext i1 %3 to i8
  store i8 %13, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = load i64, ptr %8, align 8, !tbaa !9
  %18 = getelementptr inbounds i8, ptr %16, i64 %17
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = icmp ule ptr %18, %21
  br i1 %22, label %23, label %49

23:                                               ; preds = %4
  %24 = load i8, ptr %9, align 1, !tbaa !11, !range !18, !noundef !19
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %36

26:                                               ; preds = %23
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = call i32 @strncmp(ptr noundef %29, ptr noundef %30, i64 noundef %31) #4
  %33 = icmp ne i32 %32, 0
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  br label %46

36:                                               ; preds = %23
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.GumboInternalUtf8Iterator, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load i64, ptr %8, align 8, !tbaa !9
  %42 = call i32 @strncasecmp(ptr noundef %39, ptr noundef %40, i64 noundef %41) #4
  %43 = icmp ne i32 %42, 0
  %44 = xor i1 %43, true
  %45 = zext i1 %44 to i32
  br label %46

46:                                               ; preds = %36, %26
  %47 = phi i32 [ %35, %26 ], [ %45, %36 ]
  %48 = icmp ne i32 %47, 0
  br label %49

49:                                               ; preds = %46, %4
  %50 = phi i1 [ false, %4 ], [ %48, %46 ]
  %51 = zext i1 %50 to i8
  store i8 %51, ptr %10, align 1, !tbaa !11
  %52 = load i8, ptr %10, align 1, !tbaa !11, !range !18, !noundef !19
  %53 = trunc i8 %52 to i1
  br i1 %53, label %54, label %67

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !20
  br label %55

55:                                               ; preds = %63, %54
  %56 = load i32, ptr %11, align 4, !tbaa !20
  %57 = sext i32 %56 to i64
  %58 = load i64, ptr %8, align 8, !tbaa !9
  %59 = icmp ult i64 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %66

61:                                               ; preds = %55
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  call void @utf8iterator_next(ptr noundef %62)
  br label %63

63:                                               ; preds = %61
  %64 = load i32, ptr %11, align 4, !tbaa !20
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %11, align 4, !tbaa !20
  br label %55, !llvm.loop !21

66:                                               ; preds = %60
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %68

67:                                               ; preds = %49
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %68

68:                                               ; preds = %67, %66
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  %69 = load i1, ptr %5, align 1
  ret i1 %69
}

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"GumboInternalUtf8Iterator", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !15, i64 28, !16, i64 32, !16, i64 44, !6, i64 56}
!15 = !{!"int", !7, i64 0}
!16 = !{!"", !15, i64 0, !15, i64 4, !15, i64 8}
!17 = !{!14, !6, i64 16}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!15, !15, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @utf8iterator_maybe_consume_match(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 %2
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %.not = icmp ugt ptr %6, %8
  br i1 %.not, label %.thread, label %9

9:                                                ; preds = %4
  br i1 %3, label %10, label %12

10:                                               ; preds = %9
  %11 = tail call i32 @strncmp(ptr noundef %5, ptr noundef %1, i64 noundef %2) #3
  br label %14

12:                                               ; preds = %9
  %13 = tail call i32 @strncasecmp(ptr noundef %5, ptr noundef %1, i64 noundef %2) #3
  br label %14

14:                                               ; preds = %10, %12
  %.in.in = phi i32 [ %11, %10 ], [ %13, %12 ]
  %.in = icmp eq i32 %.in.in, 0
  br i1 %.in, label %.preheader, label %.thread

.preheader:                                       ; preds = %14
  %.not19 = icmp eq i64 %2, 0
  br i1 %.not19, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  tail call void @utf8iterator_next(ptr noundef nonnull %0)
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %2
  br i1 %exitcond.not, label %.thread, label %.lr.ph, !llvm.loop !13

.thread:                                          ; preds = %.lr.ph, %.preheader, %4, %14
  %15 = phi i1 [ false, %14 ], [ false, %4 ], [ true, %.preheader ], [ true, %.lr.ph ]
  ret i1 %15
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @strncasecmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

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 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 willreturn memory(read) }

!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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass