; 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.router = type { i64, ptr, [4 x ptr], i32, %struct.anon.6 }
%struct.anon.6 = 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.132 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.133 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.210 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__.router_destroy = external hidden unnamed_addr constant [55 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 void @router_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 3029, ptr noundef @__PRETTY_FUNCTION__.router_destroy) #6
  unreachable

12:                                               ; preds = %10
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.router, ptr %13, i32 0, i32 0
  %15 = load i64, ptr %14, align 8, !tbaa !16
  %16 = icmp eq i64 %15, 1606310093
  br i1 %16, label %17, label %18

17:                                               ; preds = %12
  br label %19

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

19:                                               ; preds = %17
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.router, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  store ptr %22, ptr %5, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %19
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  br label %28

27:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.132, ptr noundef @.str.2, i32 noundef 3033, ptr noundef @__PRETTY_FUNCTION__.router_destroy) #6
  unreachable

28:                                               ; preds = %26
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.nid, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !20
  %32 = icmp eq i64 %31, 1805988336
  br i1 %32, label %33, label %34

33:                                               ; preds = %28
  br label %35

34:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.133, ptr noundef @.str.2, i32 noundef 3033, ptr noundef @__PRETTY_FUNCTION__.router_destroy) #6
  unreachable

35:                                               ; preds = %33
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.network, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  call void @nid_unregister(ptr noundef %39, ptr noundef %40)
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call i32 @nid_destroy(ptr noundef %41)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %43, i8 0, i64 72, i1 false)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %44) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

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 = !{!"router", !11, i64 0, !6, i64 8, !7, i64 16, !15, i64 48, !18, i64 56}
!18 = !{!"", !6, i64 0, !6, i64 8}
!19 = !{!17, !6, i64 8}
!20 = !{!21, !11, i64 0}
!21 = !{!"nid", !11, i64 0, !7, i64 8, !15, i64 72, !15, i64 76, !6, i64 80, !18, 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.132 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.133 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.210 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__.router_destroy = external hidden unnamed_addr constant [55 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 void @router_destroy(ptr noundef %0, ptr nocapture 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 3029, ptr noundef nonnull @__PRETTY_FUNCTION__.router_destroy) #3
  unreachable

6:                                                ; preds = %2
  %7 = load i64, ptr %1, align 8, !tbaa !15
  %8 = icmp eq i64 %7, 1606310093
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !18
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %14

13:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.132, ptr noundef nonnull @.str.2, i32 noundef 3033, ptr noundef nonnull @__PRETTY_FUNCTION__.router_destroy) #3
  unreachable

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

17:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.133, ptr noundef nonnull @.str.2, i32 noundef 3033, ptr noundef nonnull @__PRETTY_FUNCTION__.router_destroy) #3
  unreachable

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

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 = !{!"router", !7, i64 0, !11, i64 8, !8, i64 16, !14, i64 48, !17, i64 56}
!17 = !{!"", !11, i64 0, !11, i64 8}
!18 = !{!16, !11, i64 8}
!19 = !{!20, !7, i64 0}
!20 = !{!"nid", !7, i64 0, !8, i64 8, !14, i64 72, !14, i64 76, !11, i64 80, !17, i64 88}


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