; 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.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 }
%struct.conn = type { i64, ptr, ptr, %struct.anon.5 }
%struct.anon.5 = type { ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.96 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.conn_create = external hidden unnamed_addr constant [53 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 @conn_alloc() #2

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

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

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

17:                                               ; preds = %2
  %18 = load ptr, ptr %7, 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.91, ptr noundef @.str.2, i32 noundef 1144, ptr noundef @__PRETTY_FUNCTION__.conn_create) #4
  unreachable

22:                                               ; preds = %20
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.iface, ptr %23, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !15
  %26 = icmp eq i64 %25, 1991415775
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  br label %29

28:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.92, ptr noundef @.str.2, i32 noundef 1144, ptr noundef @__PRETTY_FUNCTION__.conn_create) #4
  unreachable

29:                                               ; preds = %27
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  br label %32

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

35:                                               ; preds = %32
  br label %37

36:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.93, ptr noundef @.str.2, i32 noundef 1145, ptr noundef @__PRETTY_FUNCTION__.conn_create) #4
  unreachable

37:                                               ; preds = %35
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.iface, ptr %38, i32 0, i32 0
  %40 = load i64, ptr %39, align 8, !tbaa !15
  %41 = icmp eq i64 %40, 1991415775
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  br label %44

43:                                               ; preds = %37
  call void @__assert_fail(ptr noundef @.str.94, ptr noundef @.str.2, i32 noundef 1145, ptr noundef @__PRETTY_FUNCTION__.conn_create) #4
  unreachable

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = call i32 @iface_of_hub(ptr noundef %47)
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %55

50:                                               ; preds = %46
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call i32 @iface_of_hub(ptr noundef %51)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %50
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %102

55:                                               ; preds = %50, %46
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = call i32 @iface_is_active(ptr noundef %56)
  %58 = icmp ne i32 %57, 1
  %59 = zext i1 %58 to i32
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = add nsw i32 %60, %59
  store i32 %61, ptr %9, align 4, !tbaa !9
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = call i32 @iface_is_active(ptr noundef %62)
  %64 = icmp ne i32 %63, 1
  %65 = zext i1 %64 to i32
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = add nsw i32 %66, %65
  store i32 %67, ptr %9, align 4, !tbaa !9
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = icmp eq i32 %68, 2
  br i1 %69, label %70, label %71

70:                                               ; preds = %55
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %102

71:                                               ; preds = %55
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  call void @iface_flag_set(ptr noundef %72, i32 noundef 8)
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.iface, ptr %74, i32 0, i32 6
  store ptr %73, ptr %75, align 8, !tbaa !18
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  call void @iface_flag_set(ptr noundef %76, i32 noundef 8)
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.iface, ptr %78, i32 0, i32 6
  store ptr %77, ptr %79, align 8, !tbaa !18
  %80 = call ptr @conn_alloc()
  store ptr %80, ptr %6, align 8, !tbaa !5
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.conn, ptr %81, i32 0, i32 0
  %83 = load i64, ptr %82, align 8, !tbaa !19
  %84 = icmp eq i64 %83, 393838324
  br i1 %84, label %85, label %86

85:                                               ; preds = %71
  br label %87

86:                                               ; preds = %71
  call void @__assert_fail(ptr noundef @.str.96, ptr noundef @.str.2, i32 noundef 1165, ptr noundef @__PRETTY_FUNCTION__.conn_create) #4
  unreachable

87:                                               ; preds = %85
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.conn, ptr %89, i32 0, i32 1
  store ptr %88, ptr %90, align 8, !tbaa !21
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.conn, ptr %92, i32 0, i32 2
  store ptr %91, ptr %93, align 8, !tbaa !22
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.conn, ptr %94, i32 0, i32 0
  %96 = load i64, ptr %95, align 8, !tbaa !19
  %97 = icmp eq i64 %96, 393838324
  br i1 %97, label %98, label %99

98:                                               ; preds = %87
  br label %100

99:                                               ; preds = %87
  call void @__assert_fail(ptr noundef @.str.96, ptr noundef @.str.2, i32 noundef 1168, ptr noundef @__PRETTY_FUNCTION__.conn_create) #4
  unreachable

100:                                              ; preds = %98
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %101, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %102

102:                                              ; preds = %100, %70, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  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
  %103 = load ptr, ptr %3, align 8
  ret ptr %103
}

; Function Attrs: nounwind uwtable
declare dso_local void @iface_flag_set(ptr noundef, i32 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"nid", !13, i64 0, !7, i64 8, !10, i64 72, !10, i64 76, !6, i64 80, !14, i64 88}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8}
!15 = !{!16, !13, i64 0}
!16 = !{!"iface", !13, i64 0, !6, i64 8, !6, i64 16, !17, i64 24, !17, i64 40, !10, i64 56, !6, i64 64, !7, i64 72, !7, i64 88, !7, i64 104, !14, i64 128}
!17 = !{!"pktq", !6, i64 0, !6, i64 8}
!18 = !{!16, !6, i64 64}
!19 = !{!20, !13, i64 0}
!20 = !{!"conn", !13, i64 0, !6, i64 8, !6, i64 16, !14, i64 24}
!21 = !{!20, !6, i64 8}
!22 = !{!20, !6, i64 16}


; 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.91 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.96 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__.conn_create = external hidden unnamed_addr constant [53 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 @conn_alloc() local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @conn_create(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 80
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 80
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %7, label %8

7:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.91, ptr noundef nonnull @.str.2, i32 noundef 1144, ptr noundef nonnull @__PRETTY_FUNCTION__.conn_create) #2
  unreachable

8:                                                ; preds = %2
  %9 = load i64, ptr %4, align 8, !tbaa !13
  %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.92, ptr noundef nonnull @.str.2, i32 noundef 1144, ptr noundef nonnull @__PRETTY_FUNCTION__.conn_create) #2
  unreachable

12:                                               ; preds = %8
  %.not28 = icmp eq ptr %6, null
  br i1 %.not28, label %13, label %14

13:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.93, ptr noundef nonnull @.str.2, i32 noundef 1145, ptr noundef nonnull @__PRETTY_FUNCTION__.conn_create) #2
  unreachable

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

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

18:                                               ; preds = %14
  %19 = tail call i32 @iface_of_hub(ptr noundef nonnull %4)
  %.not29 = icmp eq i32 %19, 0
  br i1 %.not29, label %22, label %20

20:                                               ; preds = %18
  %21 = tail call i32 @iface_of_hub(ptr noundef nonnull %6)
  %.not30 = icmp eq i32 %21, 0
  br i1 %.not30, label %22, label %38

22:                                               ; preds = %20, %18
  %23 = tail call i32 @iface_is_active(ptr noundef nonnull %4)
  %24 = icmp ne i32 %23, 1
  %25 = tail call i32 @iface_is_active(ptr noundef nonnull %6)
  %26 = icmp ne i32 %25, 1
  %27 = and i1 %24, %26
  br i1 %27, label %38, label %28

28:                                               ; preds = %22
  tail call void @iface_flag_set(ptr noundef nonnull %4, i32 noundef 8)
  %29 = getelementptr inbounds i8, ptr %4, i64 64
  store ptr %6, ptr %29, align 8, !tbaa !16
  tail call void @iface_flag_set(ptr noundef nonnull %6, i32 noundef 8)
  %30 = getelementptr inbounds i8, ptr %6, i64 64
  store ptr %4, ptr %30, align 8, !tbaa !16
  %31 = tail call ptr @conn_alloc()
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = icmp eq i64 %32, 393838324
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  tail call void @__assert_fail(ptr noundef nonnull @.str.96, ptr noundef nonnull @.str.2, i32 noundef 1165, ptr noundef nonnull @__PRETTY_FUNCTION__.conn_create) #2
  unreachable

35:                                               ; preds = %28
  %36 = getelementptr inbounds i8, ptr %31, i64 8
  store ptr %0, ptr %36, align 8, !tbaa !19
  %37 = getelementptr inbounds i8, ptr %31, i64 16
  store ptr %1, ptr %37, align 8, !tbaa !20
  br label %38

38:                                               ; preds = %35, %22, %20
  %.0 = phi ptr [ null, %20 ], [ null, %22 ], [ %31, %35 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @iface_flag_set(ptr noundef, i32 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, !11, i64 80}
!6 = !{!"nid", !7, i64 0, !8, i64 8, !10, i64 72, !10, i64 76, !11, i64 80, !12, i64 88}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!14, !7, i64 0}
!14 = !{!"iface", !7, i64 0, !11, i64 8, !11, i64 16, !15, i64 24, !15, i64 40, !10, i64 56, !11, i64 64, !8, i64 72, !8, i64 88, !8, i64 104, !12, i64 128}
!15 = !{!"pktq", !11, i64 0, !11, i64 8}
!16 = !{!14, !11, i64 64}
!17 = !{!18, !7, i64 0}
!18 = !{!"conn", !7, i64 0, !11, i64 8, !11, i64 16, !12, i64 24}
!19 = !{!18, !11, i64 8}
!20 = !{!18, !11, i64 16}


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