; LLVM IR from linuxkerneltravel/lmp :: eBPF_Supermarket/CPU_Subsystem/old_project/go_sar/program (tracepoint)

; 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.migrate_value = type { i64, i32, i32, i32, i32 }
%struct.migrate_info = type { i64, [16 x i8], i32, i32, i32, i32 }

@bpf_ktime_get_ns = external hidden global ptr, align 8
@bpf_map_update_elem = external hidden global ptr, align 8
@bpf_map_lookup_elem = external hidden global ptr, align 8
@queue = external dso_local global %struct.bpf_map_def, section "maps", align 4
@migrateCount = external dso_local global %struct.bpf_map_def, section "maps", align 4

; 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: nounwind uwtable
define dso_local i32 @sched_migrate_task(ptr noundef %0) #1 section "tracepoint/sched/sched_migrate_task" {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca %struct.migrate_value, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 1, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %10 = load ptr, ptr @bpf_map_lookup_elem, align 8, !tbaa !5
  %11 = call ptr %10(ptr noundef @migrateCount, ptr noundef %4)
  store ptr %11, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %17, label %14

14:                                               ; preds = %1
  %15 = load ptr, ptr @bpf_map_update_elem, align 8, !tbaa !5
  %16 = call i64 %15(ptr noundef @migrateCount, ptr noundef %4, ptr noundef %5, i64 noundef 0)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %43

17:                                               ; preds = %1
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = atomicrmw add ptr %18, i64 1 seq_cst, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %20 = load ptr, ptr @bpf_ktime_get_ns, align 8, !tbaa !5
  %21 = call i64 %20()
  store i64 %21, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #2
  %22 = load i64, ptr %8, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.migrate_value, ptr %9, i32 0, i32 0
  store i64 %22, ptr %23, align 8, !tbaa !13
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.migrate_info, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds %struct.migrate_value, ptr %9, i32 0, i32 1
  store i32 %26, ptr %27, align 8, !tbaa !17
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.migrate_info, ptr %28, i32 0, i32 3
  %30 = load i32, ptr %29, align 4, !tbaa !18
  %31 = getelementptr inbounds %struct.migrate_value, ptr %9, i32 0, i32 2
  store i32 %30, ptr %31, align 4, !tbaa !19
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.migrate_info, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 8, !tbaa !20
  %35 = getelementptr inbounds %struct.migrate_value, ptr %9, i32 0, i32 3
  store i32 %34, ptr %35, align 8, !tbaa !21
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.migrate_info, ptr %36, i32 0, i32 5
  %38 = load i32, ptr %37, align 4, !tbaa !22
  %39 = getelementptr inbounds %struct.migrate_value, ptr %9, i32 0, i32 4
  store i32 %38, ptr %39, align 4, !tbaa !23
  %40 = load ptr, ptr @bpf_map_update_elem, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call i64 %40(ptr noundef @queue, ptr noundef %41, ptr noundef %9, i64 noundef 0)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %43

43:                                               ; preds = %17, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %44 = load i32, ptr %2, align 4
  ret i32 %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"migrate_value", !12, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!15 = !{!16, !10, i64 24}
!16 = !{!"migrate_info", !12, i64 0, !7, i64 8, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36}
!17 = !{!14, !10, i64 8}
!18 = !{!16, !10, i64 28}
!19 = !{!14, !10, i64 12}
!20 = !{!16, !10, i64 32}
!21 = !{!14, !10, i64 16}
!22 = !{!16, !10, i64 36}
!23 = !{!14, !10, i64 20}


; 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 }
%struct.migrate_value = type { i64, i32, i32, i32, i32 }

@bpf_ktime_get_ns = external hidden local_unnamed_addr global ptr, align 8
@bpf_map_update_elem = external hidden local_unnamed_addr global ptr, align 8
@bpf_map_lookup_elem = external hidden local_unnamed_addr global ptr, align 8
@queue = external dso_local global %struct.bpf_map_def, section "maps", align 4
@migrateCount = external dso_local global %struct.bpf_map_def, section "maps", align 4

; 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: nounwind uwtable
define dso_local noundef i32 @sched_migrate_task(ptr nocapture noundef readonly %0) local_unnamed_addr #1 section "tracepoint/sched/sched_migrate_task" {
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca %struct.migrate_value, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #2
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  store i64 1, ptr %3, align 8, !tbaa !9
  %5 = load ptr, ptr @bpf_map_lookup_elem, align 8, !tbaa !11
  %6 = call ptr %5(ptr noundef nonnull @migrateCount, ptr noundef nonnull %2) #2
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %10

7:                                                ; preds = %1
  %8 = load ptr, ptr @bpf_map_update_elem, align 8, !tbaa !11
  %9 = call i64 %8(ptr noundef nonnull @migrateCount, ptr noundef nonnull %2, ptr noundef nonnull %3, i64 noundef 0) #2
  br label %19

10:                                               ; preds = %1
  %11 = atomicrmw add ptr %6, i64 1 seq_cst, align 8
  %12 = load ptr, ptr @bpf_ktime_get_ns, align 8, !tbaa !11
  %13 = call i64 %12() #2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #2
  store i64 %13, ptr %4, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  %16 = load <4 x i32>, ptr %14, align 8, !tbaa !5
  store <4 x i32> %16, ptr %15, align 8, !tbaa !5
  %17 = load ptr, ptr @bpf_map_update_elem, align 8, !tbaa !11
  %18 = call i64 %17(ptr noundef nonnull @queue, ptr noundef nonnull %6, ptr noundef nonnull %4, i64 noundef 0) #2
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #2
  br label %19

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"migrate_value", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}


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