; 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.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 }

@.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.11 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [37 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_destroy = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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
declare void @free(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @nid_destroy(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @iface_destroy(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  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) #5
  store ptr null, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.network, ptr %6, i32 0, i32 0
  %8 = load i64, ptr %7, align 8, !tbaa !9
  %9 = icmp eq i64 %8, 473585002
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %12

11:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 2180, ptr noundef @__PRETTY_FUNCTION__.iface_destroy) #6
  unreachable

12:                                               ; preds = %10
  br label %13

13:                                               ; preds = %12
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  br label %18

17:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.2, i32 noundef 2181, ptr noundef @__PRETTY_FUNCTION__.iface_destroy) #6
  unreachable

18:                                               ; preds = %16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.iface, ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = icmp eq i64 %21, 1991415775
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  br label %25

24:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.2, i32 noundef 2181, ptr noundef @__PRETTY_FUNCTION__.iface_destroy) #6
  unreachable

25:                                               ; preds = %23
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.iface, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !20
  store ptr %30, ptr %5, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %27
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %36

35:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.132, ptr noundef @.str.2, i32 noundef 2184, ptr noundef @__PRETTY_FUNCTION__.iface_destroy) #6
  unreachable

36:                                               ; preds = %34
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.nid, ptr %37, i32 0, i32 0
  %39 = load i64, ptr %38, align 8, !tbaa !21
  %40 = icmp eq i64 %39, 1805988336
  br i1 %40, label %41, label %42

41:                                               ; preds = %36
  br label %43

42:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.133, ptr noundef @.str.2, i32 noundef 2184, ptr noundef @__PRETTY_FUNCTION__.iface_destroy) #6
  unreachable

43:                                               ; preds = %41
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.network, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  call void @nid_unregister(ptr noundef %47, ptr noundef %48)
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = call i32 @nid_destroy(ptr noundef %49)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %51, i8 0, i64 144, i1 false)
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %52) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 0
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 "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 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 #5 = { nounwind }
attributes #6 = { 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, !11, i64 0}
!10 = !{!"network", !11, i64 0, !12, i64 8, !13, i64 24, !14, i64 40, !15, i64 56, !15, i64 60, !15, i64 64, !15, i64 68, !6, i64 72, !6, i64 80, !7, i64 88}
!11 = !{!"long", !7, i64 0}
!12 = !{!"nids", !6, i64 0, !6, i64 8}
!13 = !{!"connlist", !6, i64 0, !6, i64 8}
!14 = !{!"arptable", !6, i64 0, !6, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !11, i64 0}
!17 = !{!"iface", !11, i64 0, !6, i64 8, !6, i64 16, !18, i64 24, !18, i64 40, !15, i64 56, !6, i64 64, !7, i64 72, !7, i64 88, !7, i64 104, !19, i64 128}
!18 = !{!"pktq", !6, i64 0, !6, i64 8}
!19 = !{!"", !6, i64 0, !6, i64 8}
!20 = !{!17, !6, i64 8}
!21 = !{!22, !11, i64 0}
!22 = !{!"nid", !11, i64 0, !7, i64 8, !15, i64 72, !15, i64 76, !6, i64 80, !19, i64 88}


; 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.11 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [37 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_destroy = external hidden unnamed_addr constant [52 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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

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

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

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

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

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

8:                                                ; preds = %6
  %9 = load i64, ptr %1, align 8, !tbaa !15
  %10 = icmp eq i64 %9, 1991415775
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  %.not12 = icmp eq ptr %14, null
  br i1 %.not12, label %15, label %16

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

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

19:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.133, ptr noundef nonnull @.str.2, i32 noundef 2184, ptr noundef nonnull @__PRETTY_FUNCTION__.iface_destroy) #3
  unreachable

20:                                               ; preds = %16
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @nid_unregister(ptr noundef nonnull %21, ptr noundef nonnull %14)
  %22 = tail call i32 @nid_destroy(ptr noundef nonnull %14)
  tail call void @free(ptr noundef nonnull %1) #4
  ret i32 0
}

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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 }

!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 = !{!"iface", !7, i64 0, !11, i64 8, !11, i64 16, !17, i64 24, !17, i64 40, !14, i64 56, !11, i64 64, !8, i64 72, !8, i64 88, !8, i64 104, !18, i64 128}
!17 = !{!"pktq", !11, i64 0, !11, i64 8}
!18 = !{!"", !11, i64 0, !11, i64 8}
!19 = !{!16, !11, i64 8}
!20 = !{!21, !7, i64 0}
!21 = !{!"nid", !7, i64 0, !8, i64 8, !14, i64 72, !14, i64 76, !11, i64 80, !18, i64 88}


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