; LLVM IR from wkoszek/kmnsim :: src (all)

; 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.iface = type { i64, ptr, ptr, %struct.pktq, %struct.pktq, i32, ptr, [4 x i32], [4 x i32], [6 x i32], %struct.anon }
%struct.pktq = type { ptr, ptr }
%struct.anon = type { ptr, ptr }
%struct.nid = type { i64, [64 x i8], i32, i32, ptr, %struct.anon.0 }
%struct.anon.0 = type { ptr, ptr }
%struct.hub = type { i64, ptr, [8 x ptr], i32, i32, %struct.anon.1 }
%struct.anon.1 = type { ptr, ptr }
%struct.pkt = type { i64, ptr, i32, i32, ptr, ptr, %struct.anon.2 }
%struct.anon.2 = type { ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.hub_rx = external hidden unnamed_addr constant [41 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [86 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @msg_log(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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

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

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  br label %14

13:                                               ; preds = %9
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.2, i32 noundef 259, ptr noundef @__PRETTY_FUNCTION__.hub_rx) #4
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.iface, ptr %15, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = icmp eq i64 %17, 1991415775
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  br label %21

20:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.2, i32 noundef 259, ptr noundef @__PRETTY_FUNCTION__.hub_rx) #4
  unreachable

21:                                               ; preds = %19
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.iface, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = getelementptr inbounds %struct.nid, ptr %26, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  store ptr %28, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.hub, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !19
  %32 = icmp eq i64 %31, 891901535
  br i1 %32, label %33, label %34

33:                                               ; preds = %23
  br label %35

34:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 261, ptr noundef @__PRETTY_FUNCTION__.hub_rx) #4
  unreachable

35:                                               ; preds = %33
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  br label %41

40:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.2, i32 noundef 262, ptr noundef @__PRETTY_FUNCTION__.hub_rx) #4
  unreachable

41:                                               ; preds = %39
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.pkt, ptr %42, i32 0, i32 0
  %44 = load i64, ptr %43, align 8, !tbaa !21
  %45 = icmp eq i64 %44, 2864434397
  br i1 %45, label %46, label %47

46:                                               ; preds = %41
  br label %48

47:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.2, i32 noundef 262, ptr noundef @__PRETTY_FUNCTION__.hub_rx) #4
  unreachable

48:                                               ; preds = %46
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.hub, ptr %51, i32 0, i32 1
  %53 = load ptr, ptr %52, align 8, !tbaa !23
  %54 = call ptr @nid_type_desc(ptr noundef %53)
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.hub, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !23
  %58 = call ptr @nid_name_get(ptr noundef %57)
  call void (ptr, ...) @msg_log(ptr noundef @.str.13, ptr noundef %54, ptr noundef %58)
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.pkt, ptr %59, i32 0, i32 3
  %61 = load i32, ptr %60, align 4, !tbaa !24
  call void (ptr, ...) @msg_log(ptr noundef @.str.14, i32 noundef %61)
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.iface, ptr %62, i32 0, i32 3
  %64 = getelementptr inbounds %struct.pktq, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !25
  store ptr %65, ptr %6, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %72, %50
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %77

69:                                               ; preds = %66
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %7, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %69
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.pkt, ptr %73, i32 0, i32 6
  %75 = getelementptr inbounds %struct.anon.2, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !26
  store ptr %76, ptr %6, align 8, !tbaa !5
  br label %66, !llvm.loop !27

77:                                               ; preds = %66
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.iface, ptr %79, i32 0, i32 1
  %81 = load ptr, ptr %80, align 8, !tbaa !29
  %82 = call i32 @nid_id_get(ptr noundef %81)
  call void (ptr, ...) @msg_log(ptr noundef @.str.15, i32 noundef %78, i32 noundef %82)
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.iface, ptr %83, i32 0, i32 3
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pktq_enqueue(ptr noundef %84, ptr noundef %85)
  br label %86

86:                                               ; preds = %89, %77
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = call i32 @hub_rx_process(ptr noundef %87)
  store i32 %88, ptr %8, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %86
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = icmp eq i32 %90, 0
  br i1 %91, label %86, label %92, !llvm.loop !30

92:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i32 0
}

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

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

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

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

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

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 = { noreturn 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 = { nounwind }
attributes #4 = { noreturn 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, !13, i64 0}
!12 = !{!"iface", !13, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !14, i64 40, !10, i64 56, !6, i64 64, !7, i64 72, !7, i64 88, !7, i64 104, !15, i64 128}
!13 = !{!"long", !7, i64 0}
!14 = !{!"pktq", !6, i64 0, !6, i64 8}
!15 = !{!"", !6, i64 0, !6, i64 8}
!16 = !{!12, !6, i64 16}
!17 = !{!18, !6, i64 80}
!18 = !{!"nid", !13, i64 0, !7, i64 8, !10, i64 72, !10, i64 76, !6, i64 80, !15, i64 88}
!19 = !{!20, !13, i64 0}
!20 = !{!"hub", !13, i64 0, !6, i64 8, !7, i64 16, !10, i64 80, !10, i64 84, !15, i64 88}
!21 = !{!22, !13, i64 0}
!22 = !{!"pkt", !13, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !15, i64 40}
!23 = !{!20, !6, i64 8}
!24 = !{!22, !10, i64 20}
!25 = !{!12, !6, i64 24}
!26 = !{!22, !6, i64 40}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!12, !6, i64 8}
!30 = distinct !{!30, !28}


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

@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.hub_rx = external hidden unnamed_addr constant [41 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [86 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @msg_log(ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @hub_rx(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.2, i32 noundef 259, ptr noundef nonnull @__PRETTY_FUNCTION__.hub_rx) #2
  unreachable

4:                                                ; preds = %2
  %5 = load i64, ptr %0, align 8, !tbaa !5
  %6 = icmp eq i64 %5, 1991415775
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.2, i32 noundef 259, ptr noundef nonnull @__PRETTY_FUNCTION__.hub_rx) #2
  unreachable

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %10, i64 80
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = load i64, ptr %12, align 8, !tbaa !17
  %14 = icmp eq i64 %13, 891901535
  br i1 %14, label %16, label %15

15:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 261, ptr noundef nonnull @__PRETTY_FUNCTION__.hub_rx) #2
  unreachable

16:                                               ; preds = %8
  %.not21 = icmp eq ptr %1, null
  br i1 %.not21, label %17, label %18

17:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.2, i32 noundef 262, ptr noundef nonnull @__PRETTY_FUNCTION__.hub_rx) #2
  unreachable

18:                                               ; preds = %16
  %19 = load i64, ptr %1, align 8, !tbaa !19
  %20 = icmp eq i64 %19, 2864434397
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2, i32 noundef 262, ptr noundef nonnull @__PRETTY_FUNCTION__.hub_rx) #2
  unreachable

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %12, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  %25 = tail call ptr @nid_type_desc(ptr noundef %24)
  %26 = load ptr, ptr %23, align 8, !tbaa !21
  %27 = tail call ptr @nid_name_get(ptr noundef %26)
  tail call void (ptr, ...) @msg_log(ptr noundef nonnull @.str.13, ptr noundef %25, ptr noundef %27)
  %28 = getelementptr inbounds i8, ptr %1, i64 20
  %29 = load i32, ptr %28, align 4, !tbaa !22
  tail call void (ptr, ...) @msg_log(ptr noundef nonnull @.str.14, i32 noundef %29)
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  %.01823 = load ptr, ptr %30, align 8, !tbaa !23
  %.not2224 = icmp eq ptr %.01823, null
  br i1 %.not2224, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %22, %.lr.ph
  %.01826 = phi ptr [ %.018, %.lr.ph ], [ %.01823, %22 ]
  %.025 = phi i32 [ %31, %.lr.ph ], [ 0, %22 ]
  %31 = add nuw nsw i32 %.025, 1
  %32 = getelementptr inbounds i8, ptr %.01826, i64 40
  %.018 = load ptr, ptr %32, align 8, !tbaa !23
  %.not22 = icmp eq ptr %.018, null
  br i1 %.not22, label %._crit_edge, label %.lr.ph, !llvm.loop !24

._crit_edge:                                      ; preds = %.lr.ph, %22
  %.0.lcssa = phi i32 [ 0, %22 ], [ %31, %.lr.ph ]
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  %34 = load ptr, ptr %33, align 8, !tbaa !26
  %35 = tail call i32 @nid_id_get(ptr noundef %34)
  tail call void (ptr, ...) @msg_log(ptr noundef nonnull @.str.15, i32 noundef %.0.lcssa, i32 noundef %35)
  tail call void @pktq_enqueue(ptr noundef nonnull %30, ptr noundef nonnull %1)
  br label %36

36:                                               ; preds = %36, %._crit_edge
  %37 = tail call i32 @hub_rx_process(ptr noundef nonnull %12)
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %36, label %39, !llvm.loop !27

39:                                               ; preds = %36
  ret i32 0
}

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

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

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

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

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

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 = { noreturn 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 = { noreturn 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, !7, i64 0}
!6 = !{!"iface", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !11, i64 40, !12, i64 56, !10, i64 64, !8, i64 72, !8, i64 88, !8, i64 104, !13, i64 128}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"pktq", !10, i64 0, !10, i64 8}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !10, i64 0, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!16, !10, i64 80}
!16 = !{!"nid", !7, i64 0, !8, i64 8, !12, i64 72, !12, i64 76, !10, i64 80, !13, i64 88}
!17 = !{!18, !7, i64 0}
!18 = !{!"hub", !7, i64 0, !10, i64 8, !8, i64 16, !12, i64 80, !12, i64 84, !13, i64 88}
!19 = !{!20, !7, i64 0}
!20 = !{!"pkt", !7, i64 0, !10, i64 8, !12, i64 16, !12, i64 20, !10, i64 24, !10, i64 32, !13, i64 40}
!21 = !{!18, !10, i64 8}
!22 = !{!20, !12, i64 20}
!23 = !{!10, !10, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!6, !10, i64 8}
!27 = distinct !{!27, !25}


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