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

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

@searches = external hidden global ptr, align 8
@.str.89 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.96 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.97 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.98 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [21 x i8], align 1

; 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

declare ptr @str_id(ptr noundef) #2

declare ptr @str_addr(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @kad_print_searches(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %7 = load ptr, ptr @searches, align 8, !tbaa !5
  store ptr %7, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %80, %1
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %83

11:                                               ; preds = %8
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.search, ptr %13, i32 0, i32 3
  %15 = getelementptr inbounds [20 x i8], ptr %14, i64 0, i64 0
  %16 = call ptr @str_id(ptr noundef %15)
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef @.str.89, ptr noundef %16) #4
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.search, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = icmp eq i32 %21, 2
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, ptr @.str.91, ptr @.str.92
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.90, ptr noundef %24) #4
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.search, ptr %27, i32 0, i32 4
  %29 = load i16, ptr %28, align 4, !tbaa !15
  %30 = zext i16 %29 to i32
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.93, i32 noundef %30) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %70, %11
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.search, ptr %34, i32 0, i32 7
  %36 = load i32, ptr %35, align 8, !tbaa !16
  %37 = icmp slt i32 %33, %36
  br i1 %37, label %38, label %73

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.search, ptr %39, i32 0, i32 6
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [14 x %struct.search_node], ptr %40, i64 0, i64 %42
  store ptr %43, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.search_node, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds [20 x i8], ptr %46, i64 0, i64 0
  %48 = call ptr @str_id(ptr noundef %47)
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str.94, ptr noundef %48) #4
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.search_node, ptr %51, i32 0, i32 1
  %53 = call ptr @str_addr(ptr noundef %52)
  %54 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.95, ptr noundef %53) #4
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.search_node, ptr %56, i32 0, i32 5
  %58 = load i32, ptr %57, align 8, !tbaa !17
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.96, i32 noundef %58) #4
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.search_node, ptr %61, i32 0, i32 8
  %63 = load i32, ptr %62, align 8, !tbaa !20
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str.97, i32 noundef %63) #4
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.search_node, ptr %66, i32 0, i32 9
  %68 = load i32, ptr %67, align 4, !tbaa !21
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.98, i32 noundef %68) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %70

70:                                               ; preds = %38
  %71 = load i32, ptr %4, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %4, align 4, !tbaa !9
  br label %32, !llvm.loop !22

73:                                               ; preds = %32
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = load i32, ptr %4, align 4, !tbaa !9
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef @.str.99, i32 noundef %75) #4
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.search, ptr %77, i32 0, i32 8
  %79 = load ptr, ptr %78, align 8, !tbaa !24
  store ptr %79, ptr %3, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %73
  %81 = load i32, ptr %5, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %5, align 4, !tbaa !9
  br label %8, !llvm.loop !25

83:                                               ; preds = %8
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = load i32, ptr %5, align 4, !tbaa !9
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef @.str.100, i32 noundef %85) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 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 #4 = { 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, !10, i64 4}
!12 = !{!"search", !13, i64 0, !10, i64 4, !14, i64 8, !7, i64 16, !13, i64 36, !10, i64 40, !7, i64 48, !10, i64 3296, !6, i64 3304}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !13, i64 36}
!16 = !{!12, !10, i64 3296}
!17 = !{!18, !10, i64 176}
!18 = !{!"search_node", !7, i64 0, !19, i64 24, !10, i64 152, !14, i64 160, !14, i64 168, !10, i64 176, !7, i64 180, !10, i64 220, !10, i64 224, !10, i64 228}
!19 = !{!"sockaddr_storage", !13, i64 0, !7, i64 2, !14, i64 120}
!20 = !{!18, !10, i64 224}
!21 = !{!18, !10, i64 228}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!12, !6, i64 3304}
!25 = distinct !{!25, !23}


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

%struct.search_node = type { [20 x i8], %struct.sockaddr_storage, i32, i64, i64, i32, [40 x i8], i32, i32, i32 }
%struct.sockaddr_storage = type { i16, [118 x i8], i64 }

@searches = external hidden local_unnamed_addr global ptr, align 8
@.str.89 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.96 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.97 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.98 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare ptr @str_id(ptr noundef) local_unnamed_addr #1

declare ptr @str_addr(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @kad_print_searches(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %.030 = load ptr, ptr @searches, align 8, !tbaa !5
  %.not31 = icmp eq ptr %.030, null
  br i1 %.not31, label %._crit_edge36, label %.lr.ph35

.lr.ph35:                                         ; preds = %1, %._crit_edge
  %.033 = phi ptr [ %.0, %._crit_edge ], [ %.030, %1 ]
  %.02732 = phi i32 [ %40, %._crit_edge ], [ 0, %1 ]
  %2 = getelementptr inbounds i8, ptr %.033, i64 16
  %3 = tail call ptr @str_id(ptr noundef nonnull %2) #3
  %4 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.89, ptr noundef %3) #3
  %5 = getelementptr inbounds i8, ptr %.033, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = icmp eq i32 %6, 2
  %8 = select i1 %7, ptr @.str.91, ptr @.str.92
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.90, ptr noundef nonnull %8) #3
  %10 = getelementptr inbounds i8, ptr %.033, i64 36
  %11 = load i16, ptr %10, align 4, !tbaa !14
  %12 = zext i16 %11 to i32
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.93, i32 noundef %12) #3
  %14 = getelementptr inbounds i8, ptr %.033, i64 3296
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph35
  %17 = getelementptr inbounds i8, ptr %.033, i64 48
  br label %18

18:                                               ; preds = %.lr.ph, %18
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %18 ]
  %19 = getelementptr inbounds [14 x %struct.search_node], ptr %17, i64 0, i64 %indvars.iv
  %20 = tail call ptr @str_id(ptr noundef nonnull %19) #3
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.94, ptr noundef %20) #3
  %22 = getelementptr inbounds i8, ptr %19, i64 24
  %23 = tail call ptr @str_addr(ptr noundef nonnull %22) #3
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.95, ptr noundef %23) #3
  %25 = getelementptr inbounds i8, ptr %19, i64 176
  %26 = load i32, ptr %25, align 8, !tbaa !16
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.96, i32 noundef %26) #3
  %28 = getelementptr inbounds i8, ptr %19, i64 224
  %29 = load i32, ptr %28, align 8, !tbaa !19
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.97, i32 noundef %29) #3
  %31 = getelementptr inbounds i8, ptr %19, i64 228
  %32 = load i32, ptr %31, align 4, !tbaa !20
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.98, i32 noundef %32) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = load i32, ptr %14, align 8, !tbaa !15
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next, %35
  br i1 %36, label %18, label %._crit_edge.loopexit, !llvm.loop !21

._crit_edge.loopexit:                             ; preds = %18
  %37 = trunc nuw nsw i64 %indvars.iv.next to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph35
  %.028.lcssa = phi i32 [ 0, %.lr.ph35 ], [ %37, %._crit_edge.loopexit ]
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.99, i32 noundef %.028.lcssa) #3
  %39 = getelementptr inbounds i8, ptr %.033, i64 3304
  %40 = add nuw nsw i32 %.02732, 1
  %.0 = load ptr, ptr %39, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge36, label %.lr.ph35, !llvm.loop !23

._crit_edge36:                                    ; preds = %._crit_edge, %1
  %.027.lcssa = phi i32 [ 0, %1 ], [ %40, %._crit_edge ]
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.100, i32 noundef %.027.lcssa) #3
  ret void
}

attributes #0 = { nofree nounwind "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 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 = { 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, !12, i64 4}
!10 = !{!"search", !11, i64 0, !12, i64 4, !13, i64 8, !7, i64 16, !11, i64 36, !12, i64 40, !7, i64 48, !12, i64 3296, !6, i64 3304}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !11, i64 36}
!15 = !{!10, !12, i64 3296}
!16 = !{!17, !12, i64 176}
!17 = !{!"search_node", !7, i64 0, !18, i64 24, !12, i64 152, !13, i64 160, !13, i64 168, !12, i64 176, !7, i64 180, !12, i64 220, !12, i64 224, !12, i64 228}
!18 = !{!"sockaddr_storage", !11, i64 0, !7, i64 2, !13, i64 120}
!19 = !{!17, !12, i64 224}
!20 = !{!17, !12, i64 228}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


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