; 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.network = type { i64, %struct.nids, %struct.connlist, %struct.arptable, i32, i32, i32, i32, ptr, ptr, [1024 x i8] }
%struct.nids = type { ptr, ptr }
%struct.connlist = type { ptr, ptr }
%struct.arptable = type { ptr, ptr }
%struct.nid = type { i64, [64 x i8], i32, i32, ptr, %struct.anon.0 }
%struct.anon.0 = type { ptr, ptr }
%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 }

@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.116 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.133 = external hidden unnamed_addr constant [31 x i8], align 1
@__PRETTY_FUNCTION__.iface_create = external hidden unnamed_addr constant [64 x i8], align 1
@.str.166 = external hidden unnamed_addr constant [13 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @nid_lookup(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @nid_create(ptr noundef, i32 noundef) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @nid_type_set(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @iface_create(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.network, ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = icmp eq i64 %13, 473585002
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  br label %17

16:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 2142, ptr noundef @__PRETTY_FUNCTION__.iface_create) #5
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %22

21:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.166, ptr noundef @.str.2, i32 noundef 2143, ptr noundef @__PRETTY_FUNCTION__.iface_create) #5
  unreachable

22:                                               ; preds = %20
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.network, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = call ptr @nid_lookup(ptr noundef %24, ptr noundef %25, i32 noundef %26, i32 noundef -1)
  store ptr %27, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %31

30:                                               ; preds = %22
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %93

31:                                               ; preds = %22
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = call ptr @nid_create(ptr noundef %32, i32 noundef %33)
  store ptr %34, ptr %9, align 8, !tbaa !5
  br label %35

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

38:                                               ; preds = %35
  br label %40

39:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.132, ptr noundef @.str.2, i32 noundef 2149, ptr noundef @__PRETTY_FUNCTION__.iface_create) #5
  unreachable

40:                                               ; preds = %38
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.nid, ptr %41, i32 0, i32 0
  %43 = load i64, ptr %42, align 8, !tbaa !17
  %44 = icmp eq i64 %43, 1805988336
  br i1 %44, label %45, label %46

45:                                               ; preds = %40
  br label %47

46:                                               ; preds = %40
  call void @__assert_fail(ptr noundef @.str.133, ptr noundef @.str.2, i32 noundef 2149, ptr noundef @__PRETTY_FUNCTION__.iface_create) #5
  unreachable

47:                                               ; preds = %45
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 144) #6
  store ptr %50, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = icmp eq ptr %51, null
  br i1 %52, label %53, label %54

53:                                               ; preds = %49
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %93

54:                                               ; preds = %49
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.iface, ptr %56, i32 0, i32 0
  store i64 1991415775, ptr %57, align 8, !tbaa !20
  br label %58

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.iface, ptr %61, i32 0, i32 1
  store ptr %60, ptr %62, align 8, !tbaa !23
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.iface, ptr %63, i32 0, i32 3
  call void @pktq_init(ptr noundef %64)
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.iface, ptr %65, i32 0, i32 4
  call void @pktq_init(ptr noundef %66)
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.iface, ptr %67, i32 0, i32 5
  store i32 0, ptr %68, align 8, !tbaa !24
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.iface, ptr %69, i32 0, i32 6
  store ptr null, ptr %70, align 8, !tbaa !25
  br label %71

71:                                               ; preds = %59
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %75

74:                                               ; preds = %71
  br label %76

75:                                               ; preds = %71
  call void @__assert_fail(ptr noundef @.str.115, ptr noundef @.str.2, i32 noundef 2163, ptr noundef @__PRETTY_FUNCTION__.iface_create) #5
  unreachable

76:                                               ; preds = %74
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.iface, ptr %77, i32 0, i32 0
  %79 = load i64, ptr %78, align 8, !tbaa !20
  %80 = icmp eq i64 %79, 1991415775
  br i1 %80, label %81, label %82

81:                                               ; preds = %76
  br label %83

82:                                               ; preds = %76
  call void @__assert_fail(ptr noundef @.str.116, ptr noundef @.str.2, i32 noundef 2163, ptr noundef @__PRETTY_FUNCTION__.iface_create) #5
  unreachable

83:                                               ; preds = %81
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  call void @nid_obj_set(ptr noundef %86, ptr noundef %87)
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  call void @nid_type_set(ptr noundef %88, i32 noundef 2)
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.network, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  call void @nid_register(ptr noundef %90, ptr noundef %91)
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %92, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %93

93:                                               ; preds = %85, %53, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %94 = load ptr, ptr %4, align 8
  ret ptr %94
}

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

; Function Attrs: nounwind uwtable
declare dso_local void @pktq_init(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind allocsize(0,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 #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 }
attributes #5 = { noreturn nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!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 = !{!"network", !13, i64 0, !14, i64 8, !15, i64 24, !16, i64 40, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !6, i64 72, !6, i64 80, !7, i64 88}
!13 = !{!"long", !7, i64 0}
!14 = !{!"nids", !6, i64 0, !6, i64 8}
!15 = !{!"connlist", !6, i64 0, !6, i64 8}
!16 = !{!"arptable", !6, i64 0, !6, i64 8}
!17 = !{!18, !13, i64 0}
!18 = !{!"nid", !13, i64 0, !7, i64 8, !10, i64 72, !10, i64 76, !6, i64 80, !19, i64 88}
!19 = !{!"", !6, i64 0, !6, i64 8}
!20 = !{!21, !13, i64 0}
!21 = !{!"iface", !13, i64 0, !6, i64 8, !6, i64 16, !22, i64 24, !22, i64 40, !10, i64 56, !6, i64 64, !7, i64 72, !7, i64 88, !7, i64 104, !19, i64 128}
!22 = !{!"pktq", !6, i64 0, !6, i64 8}
!23 = !{!21, !6, i64 8}
!24 = !{!21, !10, i64 56}
!25 = !{!21, !6, i64 64}


; 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.6 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.116 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.133 = external hidden unnamed_addr constant [31 x i8], align 1
@__PRETTY_FUNCTION__.iface_create = external hidden unnamed_addr constant [64 x i8], align 1
@.str.166 = external hidden unnamed_addr constant [13 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @nid_lookup(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @nid_create(ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @nid_type_set(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @iface_create(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = icmp eq i64 %4, 473585002
  br i1 %5, label %7, label %6

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

7:                                                ; preds = %3
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %8, label %9

8:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.166, ptr noundef nonnull @.str.2, i32 noundef 2143, ptr noundef nonnull @__PRETTY_FUNCTION__.iface_create) #3
  unreachable

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = tail call ptr @nid_lookup(ptr noundef nonnull %10, ptr noundef nonnull %1, i32 noundef %2, i32 noundef -1)
  %.not29 = icmp eq ptr %11, null
  br i1 %.not29, label %12, label %32

12:                                               ; preds = %9
  %13 = tail call ptr @nid_create(ptr noundef nonnull %1, i32 noundef %2)
  %.not30 = icmp eq ptr %13, null
  br i1 %.not30, label %14, label %15

14:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.132, ptr noundef nonnull @.str.2, i32 noundef 2149, ptr noundef nonnull @__PRETTY_FUNCTION__.iface_create) #3
  unreachable

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

18:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.133, ptr noundef nonnull @.str.2, i32 noundef 2149, ptr noundef nonnull @__PRETTY_FUNCTION__.iface_create) #3
  unreachable

19:                                               ; preds = %15
  %20 = tail call noalias dereferenceable_or_null(144) ptr @calloc(i64 noundef 1, i64 noundef 144) #4
  %21 = icmp eq ptr %20, null
  br i1 %21, label %32, label %22

22:                                               ; preds = %19
  store i64 1991415775, ptr %20, align 8, !tbaa !18
  %23 = getelementptr inbounds i8, ptr %20, i64 8
  store ptr %13, ptr %23, align 8, !tbaa !21
  %24 = getelementptr inbounds i8, ptr %20, i64 24
  tail call void @pktq_init(ptr noundef nonnull %24)
  %25 = getelementptr inbounds i8, ptr %20, i64 40
  tail call void @pktq_init(ptr noundef nonnull %25)
  %26 = getelementptr inbounds i8, ptr %20, i64 56
  store i32 0, ptr %26, align 8, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %20, i64 64
  store ptr null, ptr %27, align 8, !tbaa !23
  %28 = load i64, ptr %20, align 8, !tbaa !18
  %29 = icmp eq i64 %28, 1991415775
  br i1 %29, label %31, label %30

30:                                               ; preds = %22
  tail call void @__assert_fail(ptr noundef nonnull @.str.116, ptr noundef nonnull @.str.2, i32 noundef 2163, ptr noundef nonnull @__PRETTY_FUNCTION__.iface_create) #3
  unreachable

31:                                               ; preds = %22
  tail call void @nid_obj_set(ptr noundef nonnull %13, ptr noundef nonnull %20)
  tail call void @nid_type_set(ptr noundef nonnull %13, i32 noundef 2)
  tail call void @nid_register(ptr noundef nonnull %10, ptr noundef nonnull %13)
  br label %32

32:                                               ; preds = %19, %9, %31
  %.0 = phi ptr [ %20, %31 ], [ null, %9 ], [ null, %19 ]
  ret ptr %.0
}

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

; Function Attrs: nounwind uwtable
declare dso_local void @pktq_init(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { noreturn nounwind }
attributes #4 = { nounwind allocsize(0,1) }

!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 = !{!"network", !7, i64 0, !10, i64 8, !12, i64 24, !13, i64 40, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !11, i64 72, !11, i64 80, !8, i64 88}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"nids", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"connlist", !11, i64 0, !11, i64 8}
!13 = !{!"arptable", !11, i64 0, !11, i64 8}
!14 = !{!"int", !8, i64 0}
!15 = !{!16, !7, i64 0}
!16 = !{!"nid", !7, i64 0, !8, i64 8, !14, i64 72, !14, i64 76, !11, i64 80, !17, i64 88}
!17 = !{!"", !11, i64 0, !11, i64 8}
!18 = !{!19, !7, i64 0}
!19 = !{!"iface", !7, i64 0, !11, i64 8, !11, i64 16, !20, i64 24, !20, i64 40, !14, i64 56, !11, i64 64, !8, i64 72, !8, i64 88, !8, i64 104, !17, i64 128}
!20 = !{!"pktq", !11, i64 0, !11, i64 8}
!21 = !{!19, !11, i64 8}
!22 = !{!19, !14, i64 56}
!23 = !{!19, !11, i64 64}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass