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

; 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] }
%struct.search_t = type { ptr, [20 x i8], [256 x i8], i8, i64, ptr, ptr }

@g_searches = external hidden global ptr, align 8
@gconf = external global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @searches_find_by_id(ptr noundef) #0

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @parse_query(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @searches_start(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca [256 x i8], align 16
  %5 = alloca [20 x i8], align 16
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 20, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %10 = getelementptr inbounds [20 x i8], ptr %5, i64 0, i64 0
  %11 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = call i32 @parse_query(ptr noundef %10, ptr noundef %11, ptr noundef null, ptr noundef %12)
  store i32 %13, ptr %8, align 4, !tbaa !9
  %14 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %14, label %17 [
    i32 0, label %15
    i32 3, label %16
  ]

15:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %58

16:                                               ; preds = %1
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %19

17:                                               ; preds = %1
  %18 = load i32, ptr %8, align 4, !tbaa !9
  call void (i32, ptr, ...) @log_print(i32 noundef 3, ptr noundef @.str.13, i32 noundef %18)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %58

19:                                               ; preds = %16
  %20 = getelementptr inbounds [20 x i8], ptr %5, i64 0, i64 0
  %21 = call ptr @searches_find_by_id(ptr noundef %20)
  store ptr %21, ptr %7, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %36

23:                                               ; preds = %19
  %24 = load ptr, ptr @gconf, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.gconf_t, ptr %24, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.search_t, ptr %27, i32 0, i32 4
  %29 = load i64, ptr %28, align 8, !tbaa !15
  %30 = sub nsw i64 %26, %29
  %31 = icmp sgt i64 %30, 600
  br i1 %31, label %32, label %34

32:                                               ; preds = %23
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  call void @search_restart(ptr noundef %33)
  br label %34

34:                                               ; preds = %32, %23
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %35, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %58

36:                                               ; preds = %19
  %37 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 312) #6
  store ptr %37, ptr %7, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.search_t, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds [20 x i8], ptr %39, i64 0, i64 0
  %41 = getelementptr inbounds [20 x i8], ptr %5, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %40, ptr align 16 %41, i64 20, i1 false)
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.search_t, ptr %43, i32 0, i32 6
  store ptr %42, ptr %44, align 8, !tbaa !17
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.search_t, ptr %45, i32 0, i32 2
  %47 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %46, ptr align 16 %47, i64 256, i1 false)
  %48 = load ptr, ptr @gconf, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.gconf_t, ptr %48, i32 0, i32 0
  %50 = load i64, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.search_t, ptr %51, i32 0, i32 4
  store i64 %50, ptr %52, align 8, !tbaa !15
  %53 = load ptr, ptr @g_searches, align 8, !tbaa !5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.search_t, ptr %54, i32 0, i32 0
  store ptr %53, ptr %55, align 8, !tbaa !18
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %56, ptr @g_searches, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %57, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %58

58:                                               ; preds = %36, %34, %17, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 20, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %4) #5
  %59 = load ptr, ptr %2, align 8
  ret ptr %59
}

declare void @log_print(i32 noundef, ptr noundef, ...) #3

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { nounwind allocsize(0,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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"gconf_t", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !14, i64 56, !14, i64 57, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !6, i64 80, !7, i64 88, !7, i64 89, !13, i64 104, !13, i64 112, !13, i64 120, !7, i64 128, !7, i64 160}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !13, i64 288}
!16 = !{!"search_t", !6, i64 0, !7, i64 8, !7, i64 28, !14, i64 284, !13, i64 288, !6, i64 296, !6, i64 304}
!17 = !{!16, !6, i64 304}
!18 = !{!16, !6, 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"

@g_searches = external hidden local_unnamed_addr global ptr, align 8
@gconf = external local_unnamed_addr global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @parse_query(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @searches_start(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca [256 x i8], align 16
  %3 = alloca [20 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %3) #5
  %4 = call i32 @parse_query(ptr noundef nonnull %3, ptr noundef nonnull %2, ptr noundef null, ptr noundef %0)
  switch i32 %4, label %7 [
    i32 0, label %24
    i32 3, label %5
  ]

5:                                                ; preds = %1
  %6 = call ptr @searches_find_by_id(ptr noundef nonnull %3)
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %16, label %8

7:                                                ; preds = %1
  call void (i32, ptr, ...) @log_print(i32 noundef 3, ptr noundef nonnull @.str.13, i32 noundef %4) #5
  br label %24

8:                                                ; preds = %5
  %9 = load ptr, ptr @gconf, align 8, !tbaa !5
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %6, i64 288
  %12 = load i64, ptr %11, align 8, !tbaa !14
  %13 = sub nsw i64 %10, %12
  %14 = icmp sgt i64 %13, 600
  br i1 %14, label %15, label %24

15:                                               ; preds = %8
  call void @search_restart(ptr noundef nonnull %6)
  br label %24

16:                                               ; preds = %5
  %17 = call noalias dereferenceable_or_null(312) ptr @calloc(i64 noundef 1, i64 noundef 312) #6
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %18, ptr noundef nonnull align 16 dereferenceable(20) %3, i64 20, i1 false)
  %19 = getelementptr inbounds i8, ptr %17, i64 28
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(256) %19, ptr noundef nonnull align 16 dereferenceable(256) %2, i64 256, i1 false)
  %20 = load ptr, ptr @gconf, align 8, !tbaa !5
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %17, i64 288
  store i64 %21, ptr %22, align 8, !tbaa !14
  %23 = load ptr, ptr @g_searches, align 8, !tbaa !5
  store ptr %23, ptr %17, align 8, !tbaa !16
  store ptr %17, ptr @g_searches, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %8, %15, %1, %16, %7
  %.0 = phi ptr [ null, %7 ], [ %17, %16 ], [ null, %1 ], [ %6, %15 ], [ %6, %8 ]
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #5
  ret ptr %.0
}

declare void @log_print(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0,1) }

!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 = !{!"gconf_t", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 57, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !6, i64 80, !7, i64 88, !7, i64 89, !11, i64 104, !11, i64 112, !11, i64 120, !7, i64 128, !7, i64 160}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !11, i64 288}
!15 = !{!"search_t", !6, i64 0, !7, i64 8, !7, i64 28, !12, i64 284, !11, i64 288, !6, i64 296, !6, i64 304}
!16 = !{!15, !6, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass