; 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.host = type { i64, [1 x ptr], ptr, %struct.anon.3 }
%struct.anon.3 = 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
@__PRETTY_FUNCTION__.host_create = external hidden unnamed_addr constant [48 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.128 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.130 = external hidden unnamed_addr constant [26 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 uwtable
declare dso_local ptr @nid_type_desc(ptr noundef) #2

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

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

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

14:                                               ; preds = %2
  br label %16

15:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 1608, ptr noundef @__PRETTY_FUNCTION__.host_create) #4
  unreachable

16:                                               ; preds = %14
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.network, ptr %17, i32 0, i32 1
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call ptr @nid_lookup(ptr noundef %18, ptr noundef %19, i32 noundef -1, i32 noundef -1)
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %29

23:                                               ; preds = %16
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call ptr @nid_type_desc(ptr noundef %25)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @network_err(ptr noundef %24, ptr noundef @.str.127, ptr noundef %26, ptr noundef %27)
  store i32 %28, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

29:                                               ; preds = %16
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call ptr @nid_create(ptr noundef %30, i32 noundef -1)
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %38

34:                                               ; preds = %29
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @network_err(ptr noundef %35, ptr noundef @.str.128, ptr noundef %36)
  store i32 %37, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

38:                                               ; preds = %29
  %39 = call ptr @host_alloc()
  store ptr %39, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %46

42:                                               ; preds = %38
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @network_err(ptr noundef %43, ptr noundef @.str.129, ptr noundef %44)
  store i32 %45, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

46:                                               ; preds = %38
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.host, ptr %48, i32 0, i32 2
  store ptr %47, ptr %49, align 8, !tbaa !16
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  call void @nid_obj_set(ptr noundef %50, ptr noundef %51)
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  call void @nid_type_set(ptr noundef %52, i32 noundef 1)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call ptr @iface_create(ptr noundef %53, ptr noundef %54, i32 noundef 0)
  store ptr %55, ptr %8, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = icmp eq ptr %56, null
  br i1 %57, label %58, label %61

58:                                               ; preds = %46
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = call i32 (ptr, ptr, ...) @network_err(ptr noundef %59, ptr noundef @.str.130)
  store i32 %60, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

61:                                               ; preds = %46
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %66

65:                                               ; preds = %62
  br label %67

66:                                               ; preds = %62
  call void @__assert_fail(ptr noundef @.str.115, ptr noundef @.str.2, i32 noundef 1628, ptr noundef @__PRETTY_FUNCTION__.host_create) #4
  unreachable

67:                                               ; preds = %65
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.iface, ptr %68, i32 0, i32 0
  %70 = load i64, ptr %69, align 8, !tbaa !19
  %71 = icmp eq i64 %70, 1991415775
  br i1 %71, label %72, label %73

72:                                               ; preds = %67
  br label %74

73:                                               ; preds = %67
  call void @__assert_fail(ptr noundef @.str.116, ptr noundef @.str.2, i32 noundef 1628, ptr noundef @__PRETTY_FUNCTION__.host_create) #4
  unreachable

74:                                               ; preds = %72
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  call void @iface_owner_set(ptr noundef %77, ptr noundef %78)
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.host, ptr %80, i32 0, i32 1
  %82 = getelementptr inbounds [1 x ptr], ptr %81, i64 0, i64 0
  store ptr %79, ptr %82, align 8, !tbaa !5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.network, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  call void @nid_register(ptr noundef %84, ptr noundef %85)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

86:                                               ; preds = %76, %58, %42, %34, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %87 = load i32, ptr %3, align 4
  ret i32 %87
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @host_alloc() #2

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

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

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

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

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

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

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


; 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
@__PRETTY_FUNCTION__.host_create = external hidden unnamed_addr constant [48 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.128 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.130 = external hidden unnamed_addr constant [26 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: nounwind uwtable
declare dso_local ptr @nid_type_desc(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @network_err(ptr noundef, ptr 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 #1

; Function Attrs: nounwind uwtable
define dso_local i32 @host_create(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %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 1608, ptr noundef nonnull @__PRETTY_FUNCTION__.host_create) #2
  unreachable

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

9:                                                ; preds = %6
  %10 = tail call ptr @nid_type_desc(ptr noundef nonnull %8)
  %11 = tail call i32 (ptr, ptr, ...) @network_err(ptr noundef nonnull %0, ptr noundef nonnull @.str.127, ptr noundef %10, ptr noundef %1)
  br label %34

12:                                               ; preds = %6
  %13 = tail call ptr @nid_create(ptr noundef %1, i32 noundef -1)
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %17

15:                                               ; preds = %12
  %16 = tail call i32 (ptr, ptr, ...) @network_err(ptr noundef nonnull %0, ptr noundef nonnull @.str.128, ptr noundef %1)
  br label %34

17:                                               ; preds = %12
  %18 = tail call ptr @host_alloc()
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = tail call i32 (ptr, ptr, ...) @network_err(ptr noundef nonnull %0, ptr noundef nonnull @.str.129, ptr noundef %1)
  br label %34

22:                                               ; preds = %17
  %23 = getelementptr inbounds i8, ptr %18, i64 16
  store ptr %13, ptr %23, align 8, !tbaa !15
  tail call void @nid_obj_set(ptr noundef nonnull %13, ptr noundef nonnull %18)
  tail call void @nid_type_set(ptr noundef nonnull %13, i32 noundef 1)
  %24 = tail call ptr @iface_create(ptr noundef nonnull %0, ptr noundef %1, i32 noundef 0)
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %28

26:                                               ; preds = %22
  %27 = tail call i32 (ptr, ptr, ...) @network_err(ptr noundef nonnull %0, ptr noundef nonnull @.str.130)
  br label %34

28:                                               ; preds = %22
  %29 = load i64, ptr %24, align 8, !tbaa !18
  %30 = icmp eq i64 %29, 1991415775
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  tail call void @__assert_fail(ptr noundef nonnull @.str.116, ptr noundef nonnull @.str.2, i32 noundef 1628, ptr noundef nonnull @__PRETTY_FUNCTION__.host_create) #2
  unreachable

32:                                               ; preds = %28
  tail call void @iface_owner_set(ptr noundef nonnull %24, ptr noundef nonnull %13)
  %33 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr %24, ptr %33, align 8, !tbaa !21
  tail call void @nid_register(ptr noundef nonnull %7, ptr noundef nonnull %13)
  br label %34

34:                                               ; preds = %32, %26, %20, %15, %9
  %.0 = phi i32 [ %11, %9 ], [ %16, %15 ], [ %21, %20 ], [ %27, %26 ], [ 0, %32 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @host_alloc() local_unnamed_addr #1

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

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

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

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

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

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

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 = { 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 #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 = !{!"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, !11, i64 16}
!16 = !{!"host", !7, i64 0, !8, i64 8, !11, i64 16, !17, i64 24}
!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 = !{!11, !11, i64 0}


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