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

; 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_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }
%struct._EFI_SIMPLE_NETWORK_PROTOCOL = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.NIC_DEVICE = type { i64, ptr, ptr, %struct._EFI_SIMPLE_NETWORK_PROTOCOL, %struct._EFI_SIMPLE_NETWORK_PROTOCOL, %struct.EFI_SIMPLE_NETWORK_MODE, i8, ptr, i16, i8, i8, i8, i8, i64, i64, i16, ptr, ptr, [8 x i8], %struct.EFI_MAC_ADDRESS, i8, ptr, ptr, ptr, ptr, ptr, i64, 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] }

@.str = external hidden unnamed_addr constant [161 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@gBS = external global ptr, align 8

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

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 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

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @SN_StationAddress(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %11 = load ptr, ptr @gBS, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !10
  %14 = call i64 %13(i64 noundef 8)
  store i64 %14, ptr %10, align 8, !tbaa !15
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr null, %15
  br i1 %16, label %17, label %90

17:                                               ; preds = %3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %18, i32 0, i32 15
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = icmp ne ptr null, %20
  br i1 %21, label %22, label %90

22:                                               ; preds = %17
  %23 = load i8, ptr %5, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %32, label %26

26:                                               ; preds = %22
  %27 = load i8, ptr %5, align 1, !tbaa !9
  %28 = icmp ne i8 %27, 0
  br i1 %28, label %90, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = icmp ne ptr null, %30
  br i1 %31, label %32, label %90

32:                                               ; preds = %29, %22
  %33 = call zeroext i8 @DebugAssertEnabled()
  %34 = zext i8 %33 to i32
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %46

36:                                               ; preds = %32
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = ptrtoint ptr %37 to i64
  %39 = sub i64 %38, ptrtoint (ptr getelementptr inbounds (%struct.NIC_DEVICE, ptr null, i32 0, i32 3) to i64)
  %40 = inttoptr i64 %39 to ptr
  %41 = getelementptr inbounds %struct.NIC_DEVICE, ptr %40, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !18
  %43 = icmp ne i64 %42, 943216705
  br i1 %43, label %44, label %46

44:                                               ; preds = %36
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1182, ptr noundef @.str.1)
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  br label %51

46:                                               ; preds = %36, %32
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = ptrtoint ptr %47 to i64
  %49 = sub i64 %48, ptrtoint (ptr getelementptr inbounds (%struct.NIC_DEVICE, ptr null, i32 0, i32 3) to i64)
  %50 = inttoptr i64 %49 to ptr
  br label %51

51:                                               ; preds = %46, %44
  %52 = phi ptr [ %45, %44 ], [ %50, %46 ]
  store ptr %52, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %53, i32 0, i32 15
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  store ptr %55, ptr %8, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 4, !tbaa !23
  %59 = icmp eq i32 2, %58
  br i1 %59, label %60, label %81

60:                                               ; preds = %51
  %61 = load i8, ptr %5, align 1, !tbaa !9
  %62 = icmp ne i8 %61, 0
  br i1 %62, label %63, label %69

63:                                               ; preds = %60
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %64, i32 0, i32 11
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %66, i32 0, i32 13
  %68 = call ptr @CopyMem(ptr noundef %65, ptr noundef %67, i64 noundef 32)
  br label %74

69:                                               ; preds = %60
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %70, i32 0, i32 11
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call ptr @CopyMem(ptr noundef %71, ptr noundef %72, i64 noundef 32)
  br label %74

74:                                               ; preds = %69, %63
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %76, i32 0, i32 11
  %78 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds [32 x i8], ptr %78, i64 0, i64 0
  %80 = call i64 @Ax88772MacAddressSet(ptr noundef %75, ptr noundef %79)
  store i64 %80, ptr %9, align 8, !tbaa !15
  br label %89

81:                                               ; preds = %51
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 4, !tbaa !23
  %85 = icmp eq i32 1, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %81
  store i64 -9223372036854775801, ptr %9, align 8, !tbaa !15
  br label %88

87:                                               ; preds = %81
  store i64 -9223372036854775789, ptr %9, align 8, !tbaa !15
  br label %88

88:                                               ; preds = %87, %86
  br label %89

89:                                               ; preds = %88, %74
  br label %91

90:                                               ; preds = %29, %26, %17, %3
  store i64 -9223372036854775806, ptr %9, align 8, !tbaa !15
  br label %91

91:                                               ; preds = %90, %89
  %92 = load ptr, ptr @gBS, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %92, i32 0, i32 2
  %94 = load ptr, ptr %93, align 8, !tbaa !24
  %95 = load i64, ptr %10, align 8, !tbaa !15
  call void %94(i64 noundef %95)
  %96 = load i64, ptr %9, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, 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
  ret i64 %96
}

declare i64 @Ax88772MacAddressSet(ptr noundef, ptr noundef) #1

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

!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 24}
!11 = !{!"", !12, i64 0, !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, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!12 = !{!"", !13, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !6, i64 120}
!17 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !13, 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}
!18 = !{!19, !13, i64 0}
!19 = !{!"", !13, i64 0, !6, i64 8, !6, i64 16, !17, i64 24, !17, i64 152, !20, i64 280, !7, i64 936, !6, i64 944, !22, i64 952, !7, i64 954, !7, i64 955, !7, i64 956, !7, i64 957, !13, i64 960, !13, i64 968, !22, i64 976, !6, i64 984, !6, i64 992, !7, i64 1000, !21, i64 1008, !7, i64 1040, !6, i64 1048, !6, i64 1056, !6, i64 1064, !6, i64 1072, !6, i64 1080, !13, i64 1088, !6, i64 1096}
!20 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !7, i64 40, !21, i64 552, !21, i64 584, !21, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!21 = !{!"", !7, i64 0}
!22 = !{!"short", !7, i64 0}
!23 = !{!20, !14, i64 0}
!24 = !{!11, !6, i64 32}


; 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 = external hidden unnamed_addr constant [161 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @SN_StationAddress(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = load ptr, ptr @gBS, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = tail call i64 %6(i64 noundef 8) #2
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %31, label %8

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 120
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %.not22 = icmp eq ptr %10, null
  br i1 %.not22, label %31, label %11

11:                                               ; preds = %8
  %.not23 = icmp eq i8 %1, 0
  %.not24 = icmp eq ptr %2, null
  %or.cond = and i1 %.not23, %.not24
  br i1 %or.cond, label %31, label %12

12:                                               ; preds = %11
  %13 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not25 = icmp eq i8 %13, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre28 = add i64 %.pre, -24
  %.pre30 = inttoptr i64 %.pre28 to ptr
  br i1 %.not25, label %._crit_edge, label %14

14:                                               ; preds = %12
  %15 = load i64, ptr %.pre30, align 8, !tbaa !16
  %.not26 = icmp eq i64 %15, 943216705
  br i1 %.not26, label %._crit_edge, label %16

16:                                               ; preds = %14
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1182, ptr noundef nonnull @.str.1) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %12, %14, %16
  %17 = phi ptr [ %0, %16 ], [ %.pre30, %14 ], [ %.pre30, %12 ]
  %18 = load ptr, ptr %9, align 8, !tbaa !14
  %19 = load i32, ptr %18, align 4, !tbaa !21
  switch i32 %19, label %30 [
    i32 2, label %20
    i32 1, label %31
  ]

20:                                               ; preds = %._crit_edge
  %21 = getelementptr inbounds i8, ptr %18, i64 552
  br i1 %.not23, label %25, label %22

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %18, i64 616
  %24 = tail call ptr @CopyMem(ptr noundef nonnull %21, ptr noundef nonnull %23, i64 noundef 32) #2
  br label %27

25:                                               ; preds = %20
  %26 = tail call ptr @CopyMem(ptr noundef nonnull %21, ptr noundef %2, i64 noundef 32) #2
  br label %27

27:                                               ; preds = %25, %22
  %28 = getelementptr inbounds i8, ptr %18, i64 552
  %29 = tail call i64 @Ax88772MacAddressSet(ptr noundef %17, ptr noundef nonnull %28) #2
  br label %31

30:                                               ; preds = %._crit_edge
  br label %31

31:                                               ; preds = %3, %8, %11, %._crit_edge, %27, %30
  %.0 = phi i64 [ %29, %27 ], [ -9223372036854775789, %30 ], [ -9223372036854775801, %._crit_edge ], [ -9223372036854775806, %11 ], [ -9223372036854775806, %8 ], [ -9223372036854775806, %3 ]
  %32 = load ptr, ptr @gBS, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 32
  %34 = load ptr, ptr %33, align 8, !tbaa !22
  tail call void %34(i64 noundef %7) #2
  ret i64 %.0
}

declare i64 @Ax88772MacAddressSet(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 #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, !6, i64 24}
!10 = !{!"", !11, i64 0, !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, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!11 = !{!"", !12, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 120}
!15 = !{!"_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}
!16 = !{!17, !12, i64 0}
!17 = !{!"", !12, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !15, i64 152, !18, i64 280, !7, i64 936, !6, i64 944, !20, i64 952, !7, i64 954, !7, i64 955, !7, i64 956, !7, i64 957, !12, i64 960, !12, i64 968, !20, i64 976, !6, i64 984, !6, i64 992, !7, i64 1000, !19, i64 1008, !7, i64 1040, !6, i64 1048, !6, i64 1056, !6, i64 1064, !6, i64 1072, !6, i64 1080, !12, i64 1088, !6, i64 1096}
!18 = !{!"", !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, !7, i64 40, !19, i64 552, !19, i64 584, !19, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!19 = !{!"", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!18, !13, i64 0}
!22 = !{!10, !6, i64 32}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass