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

; 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.pollfd = type { i32, i16, i16 }
%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] }

@g_count = external hidden global i32, align 4
@g_cbs = external hidden global [16 x ptr], align 16
@g_fds = external hidden global [16 x %struct.pollfd], align 16
@g_entry_removed = external hidden global i8, align 1
@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 uwtable
define dso_local void @net_loop() #1 {
  %1 = alloca i8, align 1
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #4
  store i8 0, ptr %1, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %8 = call i64 @time(ptr noundef null) #4
  store i64 %8, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %23, %0
  %10 = load i64, ptr %3, align 8, !tbaa !9
  %11 = load i32, ptr @g_count, align 4, !tbaa !11
  %12 = sext i32 %11 to i64
  %13 = icmp ult i64 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %26

15:                                               ; preds = %9
  %16 = load i64, ptr %3, align 8, !tbaa !9
  %17 = getelementptr inbounds [16 x ptr], ptr @g_cbs, i64 0, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i64, ptr %3, align 8, !tbaa !9
  %20 = getelementptr inbounds [16 x %struct.pollfd], ptr @g_fds, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.pollfd, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !15
  call void %18(i32 noundef -1, i32 noundef %22)
  br label %23

23:                                               ; preds = %15
  %24 = load i64, ptr %3, align 8, !tbaa !9
  %25 = add i64 %24, 1
  store i64 %25, ptr %3, align 8, !tbaa !9
  br label %9, !llvm.loop !18

26:                                               ; preds = %14
  br label %27

27:                                               ; preds = %92, %26
  %28 = load ptr, ptr @gconf, align 8, !tbaa !13
  %29 = getelementptr inbounds %struct.gconf_t, ptr %28, i32 0, i32 8
  %30 = load i8, ptr %29, align 1, !tbaa !20, !range !22, !noundef !23
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %93

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %33 = load i32, ptr @g_count, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = call i32 @poll(ptr noundef @g_fds, i64 noundef %34, i32 noundef 1000)
  store i32 %35, ptr %4, align 4, !tbaa !11
  %36 = load i32, ptr %4, align 4, !tbaa !11
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %32
  store i32 6, ptr %5, align 4
  br label %90

39:                                               ; preds = %32
  %40 = call i64 @time(ptr noundef null) #4
  %41 = load ptr, ptr @gconf, align 8, !tbaa !13
  %42 = getelementptr inbounds %struct.gconf_t, ptr %41, i32 0, i32 0
  store i64 %40, ptr %42, align 8, !tbaa !24
  %43 = load ptr, ptr @gconf, align 8, !tbaa !13
  %44 = getelementptr inbounds %struct.gconf_t, ptr %43, i32 0, i32 0
  %45 = load i64, ptr %44, align 8, !tbaa !24
  %46 = load i64, ptr %2, align 8, !tbaa !9
  %47 = sub nsw i64 %45, %46
  %48 = icmp sge i64 %47, 1
  br i1 %48, label %49, label %53

49:                                               ; preds = %39
  store i8 1, ptr %1, align 1, !tbaa !5
  %50 = load ptr, ptr @gconf, align 8, !tbaa !13
  %51 = getelementptr inbounds %struct.gconf_t, ptr %50, i32 0, i32 0
  %52 = load i64, ptr %51, align 8, !tbaa !24
  store i64 %52, ptr %2, align 8, !tbaa !9
  br label %54

53:                                               ; preds = %39
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %54

54:                                               ; preds = %53, %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %55

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

60:                                               ; preds = %55
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %85

61:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = getelementptr inbounds [16 x %struct.pollfd], ptr @g_fds, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.pollfd, ptr %63, i32 0, i32 2
  %65 = load i16, ptr %64, align 2, !tbaa !25
  %66 = sext i16 %65 to i32
  store i32 %66, ptr %7, align 4, !tbaa !11
  %67 = load i32, ptr %7, align 4, !tbaa !11
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %72, label %69

69:                                               ; preds = %61
  %70 = load i8, ptr %1, align 1, !tbaa !5, !range !22, !noundef !23
  %71 = trunc i8 %70 to i1
  br i1 %71, label %72, label %81

72:                                               ; preds = %69, %61
  %73 = load i64, ptr %6, align 8, !tbaa !9
  %74 = getelementptr inbounds [16 x ptr], ptr @g_cbs, i64 0, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !13
  %76 = load i32, ptr %7, align 4, !tbaa !11
  %77 = load i64, ptr %6, align 8, !tbaa !9
  %78 = getelementptr inbounds [16 x %struct.pollfd], ptr @g_fds, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.pollfd, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !15
  call void %75(i32 noundef %76, i32 noundef %80)
  br label %81

81:                                               ; preds = %72, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %82

82:                                               ; preds = %81
  %83 = load i64, ptr %6, align 8, !tbaa !9
  %84 = add i64 %83, 1
  store i64 %84, ptr %6, align 8, !tbaa !9
  br label %55, !llvm.loop !26

85:                                               ; preds = %60
  %86 = load i8, ptr @g_entry_removed, align 1, !tbaa !5, !range !22, !noundef !23
  %87 = trunc i8 %86 to i1
  br i1 %87, label %88, label %89

88:                                               ; preds = %85
  call void @compress_entries()
  store i8 0, ptr @g_entry_removed, align 1, !tbaa !5
  br label %89

89:                                               ; preds = %88, %85
  store i32 0, ptr %5, align 4
  br label %90

90:                                               ; preds = %89, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %91 = load i32, ptr %5, align 4
  switch i32 %91, label %94 [
    i32 0, label %92
    i32 6, label %93
  ]

92:                                               ; preds = %90
  br label %27, !llvm.loop !27

93:                                               ; preds = %90, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #4
  ret void

94:                                               ; preds = %90
  unreachable
}

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #2

declare i32 @poll(ptr noundef, i64 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @compress_entries() #1

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 = { 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 #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 }

!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 = !{!"_Bool", !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 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !12, i64 0}
!16 = !{!"pollfd", !12, i64 0, !17, i64 4, !17, i64 6}
!17 = !{!"short", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !6, i64 57}
!21 = !{!"gconf_t", !10, i64 0, !10, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !6, i64 56, !6, i64 57, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !14, i64 80, !7, i64 88, !7, i64 89, !10, i64 104, !10, i64 112, !10, i64 120, !7, i64 128, !7, i64 160}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!21, !10, i64 0}
!25 = !{!16, !17, i64 6}
!26 = distinct !{!26, !19}
!27 = distinct !{!27, !19}


; 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.pollfd = type { i32, i16, i16 }

@g_count = external hidden local_unnamed_addr global i32, align 4
@g_cbs = external hidden local_unnamed_addr global [16 x ptr], align 16
@g_fds = external hidden global [16 x %struct.pollfd], align 16
@g_entry_removed = external hidden local_unnamed_addr global i8, align 1
@gconf = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @net_loop() local_unnamed_addr #0 {
  %1 = tail call i64 @time(ptr noundef null) #4
  %2 = load i32, ptr @g_count, align 4, !tbaa !5
  %.not28 = icmp eq i32 %2, 0
  br i1 %.not28, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %0
  %.pre31 = phi i32 [ 0, %0 ], [ %12, %.lr.ph ]
  %3 = load ptr, ptr @gconf, align 8, !tbaa !9
  %4 = getelementptr inbounds i8, ptr %3, i64 57
  %5 = load i8, ptr %4, align 1, !tbaa !11, !range !15, !noundef !16
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %.lr.ph26, label %.thread

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01822 = phi i64 [ %11, %.lr.ph ], [ 0, %0 ]
  %7 = getelementptr inbounds [16 x ptr], ptr @g_cbs, i64 0, i64 %.01822
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds [16 x %struct.pollfd], ptr @g_fds, i64 0, i64 %.01822
  %10 = load i32, ptr %9, align 8, !tbaa !17
  tail call void %8(i32 noundef -1, i32 noundef %10) #4
  %11 = add nuw i64 %.01822, 1
  %12 = load i32, ptr @g_count, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = icmp ult i64 %11, %13
  br i1 %14, label %.lr.ph, label %.preheader, !llvm.loop !20

.lr.ph26:                                         ; preds = %.preheader, %53
  %15 = phi i32 [ %54, %53 ], [ %.pre31, %.preheader ]
  %.01725 = phi i64 [ %..017, %53 ], [ %1, %.preheader ]
  %16 = sext i32 %15 to i64
  %17 = tail call i32 @poll(ptr noundef nonnull @g_fds, i64 noundef %16, i32 noundef 1000) #4
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %.thread, label %19

19:                                               ; preds = %.lr.ph26
  %20 = tail call i64 @time(ptr noundef null) #4
  %21 = load ptr, ptr @gconf, align 8, !tbaa !9
  store i64 %20, ptr %21, align 8, !tbaa !22
  %..017 = tail call i64 @llvm.smax.i64(i64 %20, i64 %.01725)
  %22 = load i32, ptr @g_count, align 4, !tbaa !5
  %.not29 = icmp eq i32 %22, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph24

.lr.ph24:                                         ; preds = %19
  %23 = icmp sgt i64 %20, %.01725
  %.fr = freeze i1 %23
  br i1 %.fr, label %.lr.ph24.split.us, label %.lr.ph24.split

.lr.ph24.split.us:                                ; preds = %.lr.ph24, %.lr.ph24.split.us
  %.01523.us = phi i64 [ %31, %.lr.ph24.split.us ], [ 0, %.lr.ph24 ]
  %24 = getelementptr inbounds [16 x %struct.pollfd], ptr @g_fds, i64 0, i64 %.01523.us
  %25 = getelementptr inbounds i8, ptr %24, i64 6
  %26 = load i16, ptr %25, align 2, !tbaa !23
  %27 = sext i16 %26 to i32
  %28 = getelementptr inbounds [16 x ptr], ptr @g_cbs, i64 0, i64 %.01523.us
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = load i32, ptr %24, align 8, !tbaa !17
  tail call void %29(i32 noundef %27, i32 noundef %30) #4
  %31 = add nuw i64 %.01523.us, 1
  %32 = load i32, ptr @g_count, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = icmp ult i64 %31, %33
  br i1 %34, label %.lr.ph24.split.us, label %._crit_edge, !llvm.loop !24

._crit_edge:                                      ; preds = %47, %.lr.ph24.split.us, %19
  %35 = phi i32 [ 0, %19 ], [ %32, %.lr.ph24.split.us ], [ %48, %47 ]
  %36 = load i8, ptr @g_entry_removed, align 1, !tbaa !25, !range !15, !noundef !16
  %37 = trunc nuw i8 %36 to i1
  br i1 %37, label %52, label %53

.lr.ph24.split:                                   ; preds = %.lr.ph24, %47
  %38 = phi i32 [ %48, %47 ], [ %22, %.lr.ph24 ]
  %.01523 = phi i64 [ %49, %47 ], [ 0, %.lr.ph24 ]
  %39 = getelementptr inbounds [16 x %struct.pollfd], ptr @g_fds, i64 0, i64 %.01523
  %40 = getelementptr inbounds i8, ptr %39, i64 6
  %41 = load i16, ptr %40, align 2, !tbaa !23
  %.not.not = icmp eq i16 %41, 0
  br i1 %.not.not, label %47, label %42

42:                                               ; preds = %.lr.ph24.split
  %43 = sext i16 %41 to i32
  %44 = getelementptr inbounds [16 x ptr], ptr @g_cbs, i64 0, i64 %.01523
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = load i32, ptr %39, align 8, !tbaa !17
  tail call void %45(i32 noundef %43, i32 noundef %46) #4
  %.pre32 = load i32, ptr @g_count, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %.lr.ph24.split, %42
  %48 = phi i32 [ %38, %.lr.ph24.split ], [ %.pre32, %42 ]
  %49 = add nuw i64 %.01523, 1
  %50 = sext i32 %48 to i64
  %51 = icmp ult i64 %49, %50
  br i1 %51, label %.lr.ph24.split, label %._crit_edge, !llvm.loop !24

52:                                               ; preds = %._crit_edge
  tail call void @compress_entries()
  store i8 0, ptr @g_entry_removed, align 1, !tbaa !25
  %.pre = load i32, ptr @g_count, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %._crit_edge, %52
  %54 = phi i32 [ %35, %._crit_edge ], [ %.pre, %52 ]
  %55 = load ptr, ptr @gconf, align 8, !tbaa !9
  %56 = getelementptr inbounds i8, ptr %55, i64 57
  %57 = load i8, ptr %56, align 1, !tbaa !11, !range !15, !noundef !16
  %58 = trunc nuw i8 %57 to i1
  br i1 %58, label %.lr.ph26, label %.thread

.thread:                                          ; preds = %53, %.lr.ph26, %.preheader
  ret void
}

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #1

declare i32 @poll(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @compress_entries() local_unnamed_addr #0

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

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !14, i64 57}
!12 = !{!"gconf_t", !13, i64 0, !13, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !14, i64 56, !14, i64 57, !6, i64 60, !6, i64 64, !6, i64 68, !6, i64 72, !10, 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 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !6, i64 0}
!18 = !{!"pollfd", !6, i64 0, !19, i64 4, !19, i64 6}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !13, i64 0}
!23 = !{!18, !19, i64 6}
!24 = distinct !{!24, !21}
!25 = !{!14, !14, i64 0}


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