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

; 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 uwtable
define dso_local void @searches_set_auth_state(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call ptr @searches_find_by_query(ptr noundef %9)
  store ptr %10, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %59

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.search_t, ptr %14, i32 0, i32 5
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %16, ptr %8, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %29, %13
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %33

20:                                               ; preds = %17
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.result_t, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call zeroext i1 @addr_equal(ptr noundef %22, ptr noundef %23)
  br i1 %24, label %25, label %29

25:                                               ; preds = %20
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.result_t, ptr %27, i32 0, i32 2
  store i32 %26, ptr %28, align 8, !tbaa !15
  br label %33

29:                                               ; preds = %20
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.result_t, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  store ptr %32, ptr %8, align 8, !tbaa !5
  br label %17, !llvm.loop !20

33:                                               ; preds = %25, %17
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %58

36:                                               ; preds = %33
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.search_t, ptr %37, i32 0, i32 3
  store i8 1, ptr %38, align 4, !tbaa !22
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.search_t, ptr %39, i32 0, i32 5
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  store ptr %41, ptr %8, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %53, %36
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %57

45:                                               ; preds = %42
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.result_t, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8, !tbaa !15
  %49 = icmp eq i32 %48, 6
  br i1 %49, label %50, label %53

50:                                               ; preds = %45
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.result_t, ptr %51, i32 0, i32 2
  store i32 4, ptr %52, align 8, !tbaa !15
  br label %53

53:                                               ; preds = %50, %45
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.result_t, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !19
  store ptr %56, ptr %8, align 8, !tbaa !5
  br label %42, !llvm.loop !23

57:                                               ; preds = %42
  br label %58

58:                                               ; preds = %57, %33
  br label %59

59:                                               ; preds = %58, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden ptr @searches_find_by_query(ptr noundef) #1

declare zeroext i1 @addr_equal(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !6, i64 296}
!12 = !{!"search_t", !6, i64 0, !7, i64 8, !7, i64 28, !13, i64 284, !14, i64 288, !6, i64 296, !6, i64 304}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !10, i64 136}
!16 = !{!"result_t", !6, i64 0, !17, i64 8, !10, i64 136}
!17 = !{!"sockaddr_storage", !18, i64 0, !7, i64 2, !14, i64 120}
!18 = !{!"short", !7, i64 0}
!19 = !{!16, !6, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !13, i64 284}
!23 = distinct !{!23, !21}


; 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 @searches_set_auth_state(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @searches_find_by_query(ptr noundef %0)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.loopexit, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %4, i64 296
  br label %7

7:                                                ; preds = %8, %5
  %.0.in = phi ptr [ %6, %5 ], [ %.0, %8 ]
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !5
  %.not16 = icmp eq ptr %.0, null
  br i1 %.not16, label %.loopexit18, label %8

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %.0, i64 8
  %10 = tail call zeroext i1 @addr_equal(ptr noundef nonnull %9, ptr noundef %1) #2
  br i1 %10, label %11, label %7, !llvm.loop !9

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %.0, i64 136
  store i32 %2, ptr %12, align 8, !tbaa !11
  br label %.loopexit18

.loopexit18:                                      ; preds = %7, %11
  %13 = icmp eq i32 %2, 0
  br i1 %13, label %14, label %.loopexit

14:                                               ; preds = %.loopexit18
  %15 = getelementptr inbounds i8, ptr %4, i64 284
  store i8 1, ptr %15, align 4, !tbaa !17
  %.120 = load ptr, ptr %6, align 8, !tbaa !5
  %.not1721 = icmp eq ptr %.120, null
  br i1 %.not1721, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %14, %20
  %.122 = phi ptr [ %.1, %20 ], [ %.120, %14 ]
  %16 = getelementptr inbounds i8, ptr %.122, i64 136
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp eq i32 %17, 6
  br i1 %18, label %19, label %20

19:                                               ; preds = %.lr.ph
  store i32 4, ptr %16, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %19, %.lr.ph
  %.1 = load ptr, ptr %.122, align 8, !tbaa !5
  %.not17 = icmp eq ptr %.1, null
  br i1 %.not17, label %.loopexit, label %.lr.ph, !llvm.loop !20

.loopexit:                                        ; preds = %20, %14, %.loopexit18, %3
  ret void
}

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

declare zeroext i1 @addr_equal(ptr noundef, 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !16, i64 136}
!12 = !{!"result_t", !6, i64 0, !13, i64 8, !16, i64 136}
!13 = !{!"sockaddr_storage", !14, i64 0, !7, i64 2, !15, i64 120}
!14 = !{!"short", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !19, i64 284}
!18 = !{!"search_t", !6, i64 0, !7, i64 8, !7, i64 28, !19, i64 284, !15, i64 288, !6, i64 296, !6, i64 304}
!19 = !{!"_Bool", !7, i64 0}
!20 = distinct !{!20, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass