; 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
@current_time = external dso_local global %struct.bpf_map_def, section "maps", align 4
@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_tcp_data_queue.ch = external hidden unnamed_addr constant [30 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_tcp_data_queue(ptr noundef %0) #2 section "kprobe/tcp_data_queue" {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [30 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
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.pt_regs, ptr %14, i32 0, i32 13
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = inttoptr i64 %16 to ptr
  store ptr %17, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 4, ptr %6, align 4, !tbaa !12
  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 8, ptr %9) #3
  %18 = load ptr, ptr @bpf_get_current_pid_tgid, align 8, !tbaa !5
  %19 = call i64 %18()
  store i64 %19, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %20 = load i64, ptr %7, align 8, !tbaa !14
  %21 = lshr i64 %20, 32
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !12
  %23 = load ptr, ptr @bpf_map_lookup_elem, align 8, !tbaa !5
  %24 = call ptr %23(ptr noundef @pidfor_user, ptr noundef %11)
  store ptr %24, ptr %9, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %89

28:                                               ; preds = %1
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 4, !tbaa !12
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %39

32:                                               ; preds = %28
  %33 = load i32, ptr %10, align 4, !tbaa !12
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i32, ptr %34, align 4, !tbaa !12
  %36 = icmp ne i32 %33, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  store i32 0, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %89

38:                                               ; preds = %32
  br label %39

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

44:                                               ; preds = %39
  store i32 0, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %89

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

89:                                               ; preds = %45, %44, %37, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, 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 4, 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
  %90 = load i32, ptr %2, align 4
  ret i32 %90
}

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 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long long", !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
@current_time = external dso_local global %struct.bpf_map_def, section "maps", align 4
@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_tcp_data_queue.ch = external hidden unnamed_addr constant [30 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_tcp_data_queue(ptr nocapture noundef readonly %0) local_unnamed_addr #2 section "kprobe/tcp_data_queue" {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [30 x i8], align 16
  %5 = getelementptr inbounds i8, ptr %0, i64 104
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = inttoptr i64 %6 to ptr
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  store i32 4, ptr %2, align 4, !tbaa !10
  %8 = load ptr, ptr @bpf_get_current_pid_tgid, align 8, !tbaa !12
  %9 = tail call i64 %8() #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 0, ptr %3, align 4, !tbaa !10
  %10 = load ptr, ptr @bpf_map_lookup_elem, align 8, !tbaa !12
  %11 = call ptr %10(ptr noundef nonnull @pidfor_user, ptr noundef nonnull %3) #3
  %12 = icmp eq ptr %11, null
  br i1 %12, label %47, label %13

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

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

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

47:                                               ; preds = %17, %13, %1, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  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 = !{!"int", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}


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