; LLVM IR from mwarning/KadNode :: src (utils)

; 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.gconf_t = type { i64, i64, ptr, ptr, ptr, ptr, ptr, i8, i8, i32, i32, i32, i32, ptr, i8, [8 x i8], i64, i64, i64, [8 x i32], [8 x i32] }

@gconf = external global ptr, align 8

; 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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @has_tld(ptr noundef, ptr noundef) #2

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

19:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %64

20:                                               ; preds = %4
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 1 %21, i8 0, i64 %22, i1 false)
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %44, %20
  %24 = load i64, ptr %11, align 8, !tbaa !9
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = icmp ule i64 %24, %25
  br i1 %26, label %27, label %47

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %28 = call ptr @__ctype_tolower_loc() #6
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %11, align 8, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = sext i8 %33 to i32
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr %29, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !12
  store i32 %37, ptr %13, align 4, !tbaa !12
  %38 = load i32, ptr %13, align 4, !tbaa !12
  store i32 %38, ptr %14, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %39 = load i32, ptr %14, align 4, !tbaa !12
  %40 = trunc i32 %39 to i8
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i64, ptr %11, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  store i8 %40, ptr %43, align 1, !tbaa !11
  br label %44

44:                                               ; preds = %27
  %45 = load i64, ptr %11, align 8, !tbaa !9
  %46 = add i64 %45, 1
  store i64 %46, ptr %11, align 8, !tbaa !9
  br label %23, !llvm.loop !14

47:                                               ; preds = %23
  %48 = load ptr, ptr @gconf, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.gconf_t, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  store ptr %50, ptr %10, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = call zeroext i1 @has_tld(ptr noundef %51, ptr noundef %52)
  br i1 %53, label %54, label %63

54:                                               ; preds = %47
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = call i64 @strlen(ptr noundef %55) #7
  %57 = add i64 1, %56
  %58 = load i64, ptr %9, align 8, !tbaa !9
  %59 = sub i64 %58, %57
  store i64 %59, ptr %9, align 8, !tbaa !9
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load i64, ptr %9, align 8, !tbaa !9
  %62 = getelementptr inbounds i8, ptr %60, i64 %61
  store i8 0, ptr %62, align 1, !tbaa !11
  br label %63

63:                                               ; preds = %54, %47
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %64

64:                                               ; preds = %63, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %65 = load i1, ptr %5, align 1
  ret i1 %65
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind willreturn memory(none) "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(none) }
attributes #7 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !6, i64 24}
!17 = !{!"gconf_t", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !18, i64 56, !18, i64 57, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !6, i64 80, !7, i64 88, !7, i64 89, !10, i64 104, !10, i64 112, !10, i64 120, !7, i64 128, !7, i64 160}
!18 = !{!"_Bool", !7, i64 0}


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

@gconf = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @has_tld(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @query_sanitize(ptr noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, i64 noundef %3) local_unnamed_addr #1 {
  %5 = add i64 %3, 1
  %6 = icmp ule i64 %5, %1
  br i1 %6, label %7, label %64

7:                                                ; preds = %4
  tail call void @llvm.memset.p0.i64(ptr align 1 %0, i8 0, i64 %1, i1 false)
  %8 = tail call ptr @__ctype_tolower_loc() #5
  %umax = tail call i64 @llvm.umax.i64(i64 %5, i64 1)
  %xtraiter = and i64 %umax, 3
  %9 = icmp ult i64 %5, 4
  br i1 %9, label %.unr-lcssa, label %.new

.new:                                             ; preds = %7
  %unroll_iter = and i64 %umax, -4
  br label %10

10:                                               ; preds = %10, %.new
  %.01922 = phi i64 [ 0, %.new ], [ %46, %10 ]
  %niter = phi i64 [ 0, %.new ], [ %niter.next.3, %10 ]
  %11 = load ptr, ptr %8, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %2, i64 %.01922
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = sext i8 %13 to i64
  %15 = getelementptr inbounds i32, ptr %11, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !10
  %17 = trunc i32 %16 to i8
  %18 = getelementptr inbounds i8, ptr %0, i64 %.01922
  store i8 %17, ptr %18, align 1, !tbaa !9
  %19 = or disjoint i64 %.01922, 1
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %2, i64 %19
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = sext i8 %22 to i64
  %24 = getelementptr inbounds i32, ptr %20, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !10
  %26 = trunc i32 %25 to i8
  %27 = getelementptr inbounds i8, ptr %0, i64 %19
  store i8 %26, ptr %27, align 1, !tbaa !9
  %28 = or disjoint i64 %.01922, 2
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %2, i64 %28
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = sext i8 %31 to i64
  %33 = getelementptr inbounds i32, ptr %29, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !10
  %35 = trunc i32 %34 to i8
  %36 = getelementptr inbounds i8, ptr %0, i64 %28
  store i8 %35, ptr %36, align 1, !tbaa !9
  %37 = or disjoint i64 %.01922, 3
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %2, i64 %37
  %40 = load i8, ptr %39, align 1, !tbaa !9
  %41 = sext i8 %40 to i64
  %42 = getelementptr inbounds i32, ptr %38, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !10
  %44 = trunc i32 %43 to i8
  %45 = getelementptr inbounds i8, ptr %0, i64 %37
  store i8 %44, ptr %45, align 1, !tbaa !9
  %46 = add nuw i64 %.01922, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.unr-lcssa, label %10, !llvm.loop !12

.unr-lcssa:                                       ; preds = %10, %7
  %.01922.unr = phi i64 [ 0, %7 ], [ %46, %10 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.epilog-lcssa, label %.epil.preheader

.epil.preheader:                                  ; preds = %.unr-lcssa, %.epil.preheader
  %.01922.epil = phi i64 [ %55, %.epil.preheader ], [ %.01922.unr, %.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.unr-lcssa ]
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %2, i64 %.01922.epil
  %49 = load i8, ptr %48, align 1, !tbaa !9
  %50 = sext i8 %49 to i64
  %51 = getelementptr inbounds i32, ptr %47, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !10
  %53 = trunc i32 %52 to i8
  %54 = getelementptr inbounds i8, ptr %0, i64 %.01922.epil
  store i8 %53, ptr %54, align 1, !tbaa !9
  %55 = add nuw i64 %.01922.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.epilog-lcssa, label %.epil.preheader, !llvm.loop !14

.epilog-lcssa:                                    ; preds = %.epil.preheader, %.unr-lcssa
  %56 = load ptr, ptr @gconf, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 24
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  %59 = tail call zeroext i1 @has_tld(ptr noundef nonnull %0, ptr noundef %58)
  br i1 %59, label %60, label %64

60:                                               ; preds = %.epilog-lcssa
  %61 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %58) #6
  %.neg = xor i64 %61, -1
  %62 = getelementptr i8, ptr %0, i64 %.neg
  %63 = getelementptr i8, ptr %62, i64 %3
  store i8 0, ptr %63, align 1, !tbaa !9
  br label %64

64:                                               ; preds = %.epilog-lcssa, %60, %4
  ret i1 %6
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #4

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind willreturn memory(none) }
attributes #6 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}
!16 = !{!17, !6, i64 24}
!17 = !{!"gconf_t", !18, i64 0, !18, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !19, i64 56, !19, i64 57, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !6, i64 80, !7, i64 88, !7, i64 89, !18, i64 104, !18, i64 112, !18, i64 120, !7, i64 128, !7, i64 160}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_Bool", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass