; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/OptionRomPkg/Bus/Usb (Statistics)

; 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._EFI_SIMPLE_NETWORK_PROTOCOL = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_SIMPLE_NETWORK_MODE = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x %struct.EFI_MAC_ADDRESS], %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i8, i8, i8, i8, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

; 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 i64 @SN_Statistics(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr null, %11
  br i1 %12, label %13, label %47

13:                                               ; preds = %4
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %14, i32 0, i32 15
  %16 = load ptr, ptr %15, align 8, !tbaa !10
  %17 = icmp ne ptr null, %16
  br i1 %17, label %18, label %47

18:                                               ; preds = %13
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %19, i32 0, i32 15
  %21 = load ptr, ptr %20, align 8, !tbaa !10
  store ptr %21, ptr %10, align 8, !tbaa !5
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = icmp eq i32 2, %24
  br i1 %25, label %26, label %38

26:                                               ; preds = %18
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load i64, ptr %27, align 8, !tbaa !17
  %29 = icmp ule i64 176, %28
  br i1 %29, label %30, label %36

30:                                               ; preds = %26
  %31 = load i8, ptr %6, align 1, !tbaa !9
  %32 = icmp ne i8 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i64 0, ptr %9, align 8, !tbaa !17
  br label %35

34:                                               ; preds = %30
  store i64 -9223372036854775805, ptr %9, align 8, !tbaa !17
  br label %35

35:                                               ; preds = %34, %33
  br label %37

36:                                               ; preds = %26
  store i64 -9223372036854775803, ptr %9, align 8, !tbaa !17
  br label %37

37:                                               ; preds = %36, %35
  br label %46

38:                                               ; preds = %18
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4, !tbaa !13
  %42 = icmp eq i32 1, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  store i64 -9223372036854775801, ptr %9, align 8, !tbaa !17
  br label %45

44:                                               ; preds = %38
  store i64 -9223372036854775789, ptr %9, align 8, !tbaa !17
  br label %45

45:                                               ; preds = %44, %43
  br label %46

46:                                               ; preds = %45, %37
  br label %48

47:                                               ; preds = %13, %4
  store i64 -9223372036854775806, ptr %9, align 8, !tbaa !17
  br label %48

48:                                               ; preds = %47, %46
  %49 = load i64, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret i64 %49
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 120}
!11 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !7, i64 40, !16, i64 552, !16, i64 584, !16, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!15 = !{!"int", !7, i64 0}
!16 = !{!"", !7, i64 0}
!17 = !{!12, !12, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local range(i64 -9223372036854775806, 1) i64 @SN_Statistics(ptr noundef readonly %0, i8 noundef zeroext %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readnone %3) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %15, label %5

5:                                                ; preds = %4
  %6 = getelementptr inbounds i8, ptr %0, i64 120
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not10 = icmp eq ptr %7, null
  br i1 %.not10, label %15, label %8

8:                                                ; preds = %5
  %9 = load i32, ptr %7, align 4, !tbaa !11
  switch i32 %9, label %14 [
    i32 2, label %10
    i32 1, label %15
  ]

10:                                               ; preds = %8
  %11 = load i64, ptr %2, align 8, !tbaa !15
  %12 = icmp ugt i64 %11, 175
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  %.not11 = icmp eq i8 %1, 0
  %. = select i1 %.not11, i64 -9223372036854775805, i64 0
  br label %15

14:                                               ; preds = %8
  br label %15

15:                                               ; preds = %4, %5, %8, %10, %13, %14
  %.0 = phi i64 [ -9223372036854775789, %14 ], [ %., %13 ], [ -9223372036854775803, %10 ], [ -9223372036854775801, %8 ], [ -9223372036854775806, %5 ], [ -9223372036854775806, %4 ]
  ret i64 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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" }

!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 120}
!6 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !8, i64 40, !14, i64 552, !14, i64 584, !14, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!13 = !{!"int", !8, i64 0}
!14 = !{!"", !8, i64 0}
!15 = !{!7, !7, i64 0}


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