; 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.conn = type { i64, ptr, ptr, %struct.anon.5 }
%struct.anon.5 = 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.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
@__PRETTY_FUNCTION__.conn_start = external hidden unnamed_addr constant [30 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 i32 @tx_perform(ptr noundef, ptr noundef) #2

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

15:                                               ; preds = %1
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.91, ptr noundef @.str.2, i32 noundef 2481, ptr noundef @__PRETTY_FUNCTION__.conn_start) #4
  unreachable

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

25:                                               ; preds = %20
  br label %27

26:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.92, ptr noundef @.str.2, i32 noundef 2481, ptr noundef @__PRETTY_FUNCTION__.conn_start) #4
  unreachable

27:                                               ; preds = %25
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  br label %30

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

33:                                               ; preds = %30
  br label %35

34:                                               ; preds = %30
  call void @__assert_fail(ptr noundef @.str.93, ptr noundef @.str.2, i32 noundef 2482, ptr noundef @__PRETTY_FUNCTION__.conn_start) #4
  unreachable

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

40:                                               ; preds = %35
  br label %42

41:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.94, ptr noundef @.str.2, i32 noundef 2482, ptr noundef @__PRETTY_FUNCTION__.conn_start) #4
  unreachable

42:                                               ; preds = %40
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = call i32 @tx_perform(ptr noundef %45, ptr noundef %46)
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = call i32 @tx_perform(ptr noundef %48, ptr noundef %49)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i32 0
}

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, !6, i64 8}
!10 = !{!"conn", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 8}
!13 = !{!14, !6, i64 80}
!14 = !{!"nid", !11, i64 0, !7, i64 8, !15, i64 72, !15, i64 76, !6, i64 80, !12, i64 88}
!15 = !{!"int", !7, i64 0}
!16 = !{!10, !6, i64 16}
!17 = !{!18, !11, i64 0}
!18 = !{!"iface", !11, i64 0, !6, i64 8, !6, i64 16, !19, i64 24, !19, i64 40, !15, i64 56, !6, i64 64, !7, i64 72, !7, i64 88, !7, i64 104, !12, i64 128}
!19 = !{!"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.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
@__PRETTY_FUNCTION__.conn_start = external hidden unnamed_addr constant [30 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 i32 @tx_perform(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @conn_start(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 80
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %7, i64 80
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %10, label %11

10:                                               ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.91, ptr noundef nonnull @.str.2, i32 noundef 2481, ptr noundef nonnull @__PRETTY_FUNCTION__.conn_start) #2
  unreachable

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

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.92, ptr noundef nonnull @.str.2, i32 noundef 2481, ptr noundef nonnull @__PRETTY_FUNCTION__.conn_start) #2
  unreachable

15:                                               ; preds = %11
  %.not11 = icmp eq ptr %9, null
  br i1 %.not11, label %16, label %17

16:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.93, ptr noundef nonnull @.str.2, i32 noundef 2482, ptr noundef nonnull @__PRETTY_FUNCTION__.conn_start) #2
  unreachable

17:                                               ; preds = %15
  %18 = load i64, ptr %9, align 8, !tbaa !16
  %19 = icmp eq i64 %18, 1991415775
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %17
  %22 = tail call i32 @tx_perform(ptr noundef nonnull %5, ptr noundef nonnull %9)
  %23 = tail call i32 @tx_perform(ptr noundef nonnull %9, ptr noundef nonnull %5)
  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 = { 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, !10, i64 8}
!6 = !{!"conn", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"", !10, i64 0, !10, i64 8}
!12 = !{!13, !10, i64 80}
!13 = !{!"nid", !7, i64 0, !8, i64 8, !14, i64 72, !14, i64 76, !10, i64 80, !11, i64 88}
!14 = !{!"int", !8, i64 0}
!15 = !{!6, !10, i64 16}
!16 = !{!17, !7, i64 0}
!17 = !{!"iface", !7, i64 0, !10, i64 8, !10, i64 16, !18, i64 24, !18, i64 40, !14, i64 56, !10, i64 64, !8, i64 72, !8, i64 88, !8, i64 104, !11, i64 128}
!18 = !{!"pktq", !10, i64 0, !10, i64 8}


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