; 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.host = type { i64, [1 x ptr], ptr, %struct.anon.3 }
%struct.anon.3 = 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.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
@.str.12 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.host_rx = external hidden unnamed_addr constant [42 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [72 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
declare dso_local ptr @nid_name_get(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @host_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
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %8

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

11:                                               ; preds = %8
  br label %13

12:                                               ; preds = %8
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.2, i32 noundef 503, ptr noundef @__PRETTY_FUNCTION__.host_rx) #4
  unreachable

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

18:                                               ; preds = %13
  br label %20

19:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.2, i32 noundef 503, ptr noundef @__PRETTY_FUNCTION__.host_rx) #4
  unreachable

20:                                               ; preds = %18
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.iface, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = getelementptr inbounds %struct.nid, ptr %25, i32 0, i32 4
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  store ptr %27, ptr %5, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %22
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  br label %33

32:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.25, ptr noundef @.str.2, i32 noundef 505, ptr noundef @__PRETTY_FUNCTION__.host_rx) #4
  unreachable

33:                                               ; preds = %31
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.host, ptr %34, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !19
  %37 = icmp eq i64 %36, 2602815055
  br i1 %37, label %38, label %39

38:                                               ; preds = %33
  br label %40

39:                                               ; preds = %33
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.2, i32 noundef 505, ptr noundef @__PRETTY_FUNCTION__.host_rx) #4
  unreachable

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  br label %48

47:                                               ; preds = %43
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.2, i32 noundef 506, ptr noundef @__PRETTY_FUNCTION__.host_rx) #4
  unreachable

48:                                               ; preds = %46
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.pkt, ptr %49, i32 0, i32 0
  %51 = load i64, ptr %50, align 8, !tbaa !21
  %52 = icmp eq i64 %51, 2864434397
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  br label %55

54:                                               ; preds = %48
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.2, i32 noundef 506, ptr noundef @__PRETTY_FUNCTION__.host_rx) #4
  unreachable

55:                                               ; preds = %53
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.host, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !23
  %61 = call ptr @nid_name_get(ptr noundef %60)
  call void (ptr, ...) @msg_log(ptr noundef @.str.30, ptr noundef %61)
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.pkt, ptr %62, i32 0, i32 3
  %64 = load i32, ptr %63, align 4, !tbaa !24
  call void (ptr, ...) @msg_log(ptr noundef @.str.31, i32 noundef %64)
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.iface, ptr %65, i32 0, i32 3
  %67 = getelementptr inbounds %struct.pktq, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !25
  store ptr %68, ptr %6, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %75, %57
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %80

72:                                               ; preds = %69
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %7, align 4, !tbaa !9
  br label %75

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

80:                                               ; preds = %69
  %81 = load i32, ptr %7, align 4, !tbaa !9
  call void (ptr, ...) @msg_log(ptr noundef @.str.32, i32 noundef %81)
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.iface, ptr %82, i32 0, i32 3
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pktq_enqueue(ptr noundef %83, ptr noundef %84)
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = call i32 @host_rx_process(ptr noundef %85)
  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 i32 @host_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 = !{!"host", !13, i64 0, !7, i64 8, !6, i64 16, !15, i64 24}
!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 16}
!24 = !{!22, !10, i64 20}
!25 = !{!12, !6, i64 24}
!26 = !{!22, !6, i64 40}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; 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.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
@.str.12 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.host_rx = external hidden unnamed_addr constant [42 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [72 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
declare dso_local ptr @nid_name_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
define dso_local noundef i32 @host_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 503, ptr noundef nonnull @__PRETTY_FUNCTION__.host_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 503, ptr noundef nonnull @__PRETTY_FUNCTION__.host_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
  %.not20 = icmp eq ptr %12, null
  br i1 %.not20, label %13, label %14

13:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.2, i32 noundef 505, ptr noundef nonnull @__PRETTY_FUNCTION__.host_rx) #2
  unreachable

14:                                               ; preds = %8
  %15 = load i64, ptr %12, align 8, !tbaa !17
  %16 = icmp eq i64 %15, 2602815055
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.2, i32 noundef 505, ptr noundef nonnull @__PRETTY_FUNCTION__.host_rx) #2
  unreachable

18:                                               ; preds = %14
  %.not21 = icmp eq ptr %1, null
  br i1 %.not21, label %19, label %20

19:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.2, i32 noundef 506, ptr noundef nonnull @__PRETTY_FUNCTION__.host_rx) #2
  unreachable

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

23:                                               ; preds = %20
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2, i32 noundef 506, ptr noundef nonnull @__PRETTY_FUNCTION__.host_rx) #2
  unreachable

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %12, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !21
  %27 = tail call ptr @nid_name_get(ptr noundef %26)
  tail call void (ptr, ...) @msg_log(ptr noundef nonnull @.str.30, 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.31, i32 noundef %29)
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  %.01623 = load ptr, ptr %30, align 8, !tbaa !23
  %.not2224 = icmp eq ptr %.01623, null
  br i1 %.not2224, label %._crit_edge, label %.lr.ph

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

._crit_edge:                                      ; preds = %.lr.ph, %24
  %.0.lcssa = phi i32 [ 0, %24 ], [ %31, %.lr.ph ]
  tail call void (ptr, ...) @msg_log(ptr noundef nonnull @.str.32, i32 noundef %.0.lcssa)
  tail call void @pktq_enqueue(ptr noundef nonnull %30, ptr noundef nonnull %1)
  %33 = tail call i32 @host_rx_process(ptr noundef nonnull %12)
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @host_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 = !{!"host", !7, i64 0, !8, i64 8, !10, i64 16, !13, i64 24}
!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 16}
!22 = !{!20, !12, i64 20}
!23 = !{!10, !10, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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