; LLVM IR from linuxkerneltravel/lmp :: eBPF_Visualization/eBPF_scenario_analysis/tr_package/rt_header (rx_package)

; 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.bpf_map_def = type { i32, i32, i32, i32, i32 }
%struct.pt_regs = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.skb_message = type <{ i64, i32, i32, i16, i16, i16, [30 x i8] }>
%struct.sk_buff = type { %union.anon, %union.anon.1, %union.anon.2, [48 x i8], %union.anon.3, i64, i32, i32, i16, i16, i16, [0 x i8], i8, i8, %union.anon.5, i32, i32, ptr, ptr, i32, %struct.refcount_struct, ptr }
%union.anon = type { %struct.anon }
%struct.anon = type { ptr, ptr, %union.anon.0 }
%union.anon.0 = type { ptr }
%union.anon.1 = type { ptr }
%union.anon.2 = type { i64 }
%union.anon.3 = type { %struct.anon.4 }
%struct.anon.4 = type { i64, ptr }
%union.anon.5 = type { %struct.anon.6 }
%struct.anon.6 = type <{ [0 x i8], i16, [0 x i8], i32, i16, %union.anon.7, i32, i32, i32, %union.anon.9, %union.anon.11, i16, [2 x i8], i32, %union.anon.12, %union.anon.13, i16, i16, i16, i16, i16, i16, i16 }>
%union.anon.7 = type { i32 }
%union.anon.9 = type { i32 }
%union.anon.11 = type { i32 }
%union.anon.12 = type { i32 }
%union.anon.13 = type { i16 }
%struct.refcount_struct = type { %struct.atomic_t }
%struct.atomic_t = type { i32 }

@events = external dso_local global %struct.bpf_map_def, section "maps", align 4
@pidfor_user = external dso_local global %struct.bpf_map_def, section "maps", align 4
@bpf_ktime_get_ns = external hidden global ptr, align 8
@bpf_get_current_pid_tgid = external hidden global ptr, align 8
@bpf_map_lookup_elem = external hidden global ptr, align 8
@bpf_ringbuf_reserve = external hidden global ptr, align 8
@bpf_probe_read_kernel = external hidden global ptr, align 8
@bpf_ringbuf_submit = external hidden global ptr, align 8
@__const.kprobe_dev_queue_xmit.ch = external hidden unnamed_addr constant [19 x i8], align 16

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @kprobe_dev_queue_xmit(ptr noundef %0) #2 section "kprobe/__dev_queue_xmit" {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [19 x i8], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.pt_regs, ptr %13, i32 0, i32 13
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = inttoptr i64 %15 to ptr
  store ptr %16, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load ptr, ptr @bpf_get_current_pid_tgid, align 8, !tbaa !5
  %18 = call i64 %17()
  store i64 %18, ptr %6, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %19 = load i64, ptr %6, align 8, !tbaa !12
  %20 = lshr i64 %19, 32
  %21 = trunc i64 %20 to i32
  store i32 %21, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !14
  %22 = load ptr, ptr @bpf_map_lookup_elem, align 8, !tbaa !5
  %23 = call ptr %22(ptr noundef @pidfor_user, ptr noundef %10)
  store ptr %23, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %90

27:                                               ; preds = %1
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i32, ptr %28, align 4, !tbaa !14
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %38

31:                                               ; preds = %27
  %32 = load i32, ptr %9, align 4, !tbaa !14
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %35 = icmp ne i32 %32, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i32 0, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %90

37:                                               ; preds = %31
  br label %38

38:                                               ; preds = %37, %27
  %39 = load ptr, ptr @bpf_ringbuf_reserve, align 8, !tbaa !5
  %40 = call ptr %39(ptr noundef @events, i64 noundef 52, i64 noundef 0)
  store ptr %40, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %44, label %43

43:                                               ; preds = %38
  store i32 0, ptr %2, align 4
  store i32 1, ptr %11, align 4
  br label %90

44:                                               ; preds = %38
  %45 = load ptr, ptr @bpf_ktime_get_ns, align 8, !tbaa !5
  %46 = call i64 %45()
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.skb_message, ptr %47, i32 0, i32 0
  store i64 %46, ptr %48, align 1, !tbaa !16
  %49 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.skb_message, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.sk_buff, ptr %52, i32 0, i32 6
  %54 = call i64 %49(ptr noundef %51, i32 noundef 4, ptr noundef %53)
  %55 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !5
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.skb_message, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.sk_buff, ptr %58, i32 0, i32 7
  %60 = call i64 %55(ptr noundef %57, i32 noundef 4, ptr noundef %59)
  %61 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !5
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.skb_message, ptr %62, i32 0, i32 5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.sk_buff, ptr %64, i32 0, i32 14
  %66 = getelementptr inbounds %struct.anon.6, ptr %65, i32 0, i32 22
  %67 = call i64 %61(ptr noundef %63, i32 noundef 2, ptr noundef %66)
  %68 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !5
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.skb_message, ptr %69, i32 0, i32 4
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.sk_buff, ptr %71, i32 0, i32 14
  %73 = getelementptr inbounds %struct.anon.6, ptr %72, i32 0, i32 21
  %74 = call i64 %68(ptr noundef %70, i32 noundef 2, ptr noundef %73)
  %75 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !5
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.skb_message, ptr %76, i32 0, i32 3
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.sk_buff, ptr %78, i32 0, i32 14
  %80 = getelementptr inbounds %struct.anon.6, ptr %79, i32 0, i32 20
  %81 = call i64 %75(ptr noundef %77, i32 noundef 2, ptr noundef %80)
  call void @llvm.lifetime.start.p0(i64 19, ptr %12) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %12, ptr align 16 @__const.kprobe_dev_queue_xmit.ch, i64 19, i1 false)
  %82 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.skb_message, ptr %83, i32 0, i32 6
  %85 = getelementptr inbounds [30 x i8], ptr %84, i64 0, i64 0
  %86 = getelementptr inbounds [19 x i8], ptr %12, i64 0, i64 0
  %87 = call i64 %82(ptr noundef %85, i32 noundef 19, ptr noundef %86)
  %88 = load ptr, ptr @bpf_ringbuf_submit, align 8, !tbaa !5
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  call void %88(ptr noundef %89, i64 noundef 0)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 19, ptr %12) #3
  br label %90

90:                                               ; preds = %44, %43, %36, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %91 = load i32, ptr %2, align 4
  ret i32 %91
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 104}
!10 = !{!"pt_regs", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !13, i64 0}
!17 = !{!"skb_message", !13, i64 0, !15, i64 8, !15, i64 12, !18, i64 16, !18, i64 18, !18, i64 20, !7, i64 22}
!18 = !{!"short", !7, i64 0}


; 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"

%struct.bpf_map_def = type { i32, i32, i32, i32, i32 }

@events = external dso_local global %struct.bpf_map_def, section "maps", align 4
@pidfor_user = external dso_local global %struct.bpf_map_def, section "maps", align 4
@bpf_ktime_get_ns = external hidden local_unnamed_addr global ptr, align 8
@bpf_get_current_pid_tgid = external hidden local_unnamed_addr global ptr, align 8
@bpf_map_lookup_elem = external hidden local_unnamed_addr global ptr, align 8
@bpf_ringbuf_reserve = external hidden local_unnamed_addr global ptr, align 8
@bpf_probe_read_kernel = external hidden local_unnamed_addr global ptr, align 8
@bpf_ringbuf_submit = external hidden local_unnamed_addr global ptr, align 8
@__const.kprobe_dev_queue_xmit.ch = external hidden unnamed_addr constant [19 x i8], align 16

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @kprobe_dev_queue_xmit(ptr nocapture noundef readonly %0) local_unnamed_addr #2 section "kprobe/__dev_queue_xmit" {
  %2 = alloca i32, align 4
  %3 = alloca [19 x i8], align 16
  %4 = getelementptr inbounds i8, ptr %0, i64 104
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = inttoptr i64 %5 to ptr
  %7 = load ptr, ptr @bpf_get_current_pid_tgid, align 8, !tbaa !10
  %8 = tail call i64 %7() #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  store i32 0, ptr %2, align 4, !tbaa !12
  %9 = load ptr, ptr @bpf_map_lookup_elem, align 8, !tbaa !10
  %10 = call ptr %9(ptr noundef nonnull @pidfor_user, ptr noundef nonnull %2) #3
  %11 = icmp eq ptr %10, null
  br i1 %11, label %46, label %12

12:                                               ; preds = %1
  %13 = lshr i64 %8, 32
  %14 = trunc nuw i64 %13 to i32
  %15 = load i32, ptr %10, align 4, !tbaa !12
  %.not = icmp eq i32 %15, 0
  %.not22 = icmp eq i32 %15, %14
  %or.cond = select i1 %.not, i1 true, i1 %.not22
  br i1 %or.cond, label %16, label %46

16:                                               ; preds = %12
  %17 = load ptr, ptr @bpf_ringbuf_reserve, align 8, !tbaa !10
  %18 = call ptr %17(ptr noundef nonnull @events, i64 noundef 52, i64 noundef 0) #3
  %.not23 = icmp eq ptr %18, null
  br i1 %.not23, label %46, label %19

19:                                               ; preds = %16
  %20 = load ptr, ptr @bpf_ktime_get_ns, align 8, !tbaa !10
  %21 = call i64 %20() #3
  store i64 %21, ptr %18, align 1, !tbaa !14
  %22 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %18, i64 8
  %24 = getelementptr inbounds i8, ptr %6, i64 112
  %25 = call i64 %22(ptr noundef nonnull %23, i32 noundef 4, ptr noundef nonnull %24) #3
  %26 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !10
  %27 = getelementptr inbounds i8, ptr %18, i64 12
  %28 = getelementptr inbounds i8, ptr %6, i64 116
  %29 = call i64 %26(ptr noundef nonnull %27, i32 noundef 4, ptr noundef nonnull %28) #3
  %30 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !10
  %31 = getelementptr inbounds i8, ptr %18, i64 20
  %32 = getelementptr inbounds i8, ptr %6, i64 186
  %33 = call i64 %30(ptr noundef nonnull %31, i32 noundef 2, ptr noundef nonnull %32) #3
  %34 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !10
  %35 = getelementptr inbounds i8, ptr %18, i64 18
  %36 = getelementptr inbounds i8, ptr %6, i64 184
  %37 = call i64 %34(ptr noundef nonnull %35, i32 noundef 2, ptr noundef nonnull %36) #3
  %38 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !10
  %39 = getelementptr inbounds i8, ptr %18, i64 16
  %40 = getelementptr inbounds i8, ptr %6, i64 182
  %41 = call i64 %38(ptr noundef nonnull %39, i32 noundef 2, ptr noundef nonnull %40) #3
  call void @llvm.lifetime.start.p0(i64 19, ptr nonnull %3) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(19) %3, ptr noundef nonnull align 16 dereferenceable(19) @__const.kprobe_dev_queue_xmit.ch, i64 19, i1 false)
  %42 = load ptr, ptr @bpf_probe_read_kernel, align 8, !tbaa !10
  %43 = getelementptr inbounds i8, ptr %18, i64 22
  %44 = call i64 %42(ptr noundef nonnull %43, i32 noundef 19, ptr noundef nonnull %3) #3
  %45 = load ptr, ptr @bpf_ringbuf_submit, align 8, !tbaa !10
  call void %45(ptr noundef nonnull %18, i64 noundef 0) #3
  call void @llvm.lifetime.end.p0(i64 19, ptr nonnull %3) #3
  br label %46

46:                                               ; preds = %16, %12, %1, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 104}
!6 = !{!"pt_regs", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"skb_message", !16, i64 0, !13, i64 8, !13, i64 12, !17, i64 16, !17, i64 18, !17, i64 20, !8, i64 22}
!16 = !{!"long long", !8, i64 0}
!17 = !{!"short", !8, i64 0}


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