; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (PxeReset)

; 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.SNP_DRIVER = type <{ i32, [4 x i8], %struct.EFI_LOCK, %struct._EFI_SIMPLE_NETWORK_PROTOCOL, %struct.EFI_SIMPLE_NETWORK_MODE, ptr, ptr, ptr, i8, i8, i16, i32, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, %struct.s_pxe_cdb, [6 x i8], ptr, ptr, ptr, %struct.s_pxe_db_get_init_info, i8, ptr, [100 x %struct.MAP_LIST], ptr, i8, [7 x i8] }>
%struct.EFI_LOCK = type { i64, i64, i32 }
%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] }
%struct.s_pxe_cdb = type { i16, i16, i16, i16, i64, i64, i16, i16, i16, i16 }
%struct.s_pxe_db_get_init_info = type <{ i32, i32, [4 x i32], i32, i16, i16, i16, i16, i16, i16, i16, i16, i8, i8, i8 }>
%struct.MAP_LIST = type { i64, ptr }

@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @PxeReset(ptr noundef %0) #0 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.SNP_DRIVER, ptr %4, i32 0, i32 20
  %6 = getelementptr inbounds %struct.s_pxe_cdb, ptr %5, i32 0, i32 0
  store i16 6, ptr %6, align 2, !tbaa !9
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.SNP_DRIVER, ptr %7, i32 0, i32 20
  %9 = getelementptr inbounds %struct.s_pxe_cdb, ptr %8, i32 0, i32 1
  store i16 0, ptr %9, align 2, !tbaa !20
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.SNP_DRIVER, ptr %10, i32 0, i32 20
  %12 = getelementptr inbounds %struct.s_pxe_cdb, ptr %11, i32 0, i32 2
  store i16 0, ptr %12, align 2, !tbaa !21
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.SNP_DRIVER, ptr %13, i32 0, i32 20
  %15 = getelementptr inbounds %struct.s_pxe_cdb, ptr %14, i32 0, i32 3
  store i16 0, ptr %15, align 2, !tbaa !22
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.SNP_DRIVER, ptr %16, i32 0, i32 20
  %18 = getelementptr inbounds %struct.s_pxe_cdb, ptr %17, i32 0, i32 4
  store i64 0, ptr %18, align 2, !tbaa !23
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.SNP_DRIVER, ptr %19, i32 0, i32 20
  %21 = getelementptr inbounds %struct.s_pxe_cdb, ptr %20, i32 0, i32 5
  store i64 0, ptr %21, align 2, !tbaa !24
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.SNP_DRIVER, ptr %22, i32 0, i32 20
  %24 = getelementptr inbounds %struct.s_pxe_cdb, ptr %23, i32 0, i32 6
  store i16 0, ptr %24, align 2, !tbaa !25
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.SNP_DRIVER, ptr %25, i32 0, i32 20
  %27 = getelementptr inbounds %struct.s_pxe_cdb, ptr %26, i32 0, i32 7
  store i16 0, ptr %27, align 2, !tbaa !26
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.SNP_DRIVER, ptr %28, i32 0, i32 10
  %30 = load i16, ptr %29, align 2, !tbaa !27
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.SNP_DRIVER, ptr %31, i32 0, i32 20
  %33 = getelementptr inbounds %struct.s_pxe_cdb, ptr %32, i32 0, i32 8
  store i16 %30, ptr %33, align 2, !tbaa !28
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.SNP_DRIVER, ptr %34, i32 0, i32 20
  %36 = getelementptr inbounds %struct.s_pxe_cdb, ptr %35, i32 0, i32 9
  store i16 0, ptr %36, align 2, !tbaa !29
  br label %37

37:                                               ; preds = %1
  %38 = call zeroext i8 @DebugPrintEnabled()
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %47

40:                                               ; preds = %37
  br label %41

41:                                               ; preds = %40
  %42 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 16384)
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %41
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 16384, ptr noundef @.str)
  br label %45

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

46:                                               ; preds = %45
  br label %47

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

48:                                               ; preds = %47
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.SNP_DRIVER, ptr %49, i32 0, i32 7
  %51 = load ptr, ptr %50, align 8, !tbaa !30
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.SNP_DRIVER, ptr %52, i32 0, i32 20
  %54 = ptrtoint ptr %53 to i64
  %55 = call i64 %51(i64 noundef %54)
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.SNP_DRIVER, ptr %56, i32 0, i32 20
  %58 = getelementptr inbounds %struct.s_pxe_cdb, ptr %57, i32 0, i32 6
  %59 = load i16, ptr %58, align 2, !tbaa !25
  %60 = zext i16 %59 to i32
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %85

62:                                               ; preds = %48
  br label %63

63:                                               ; preds = %62
  %64 = call zeroext i8 @DebugPrintEnabled()
  %65 = icmp ne i8 %64, 0
  br i1 %65, label %66, label %83

66:                                               ; preds = %63
  br label %67

67:                                               ; preds = %66
  %68 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2)
  %69 = icmp ne i8 %68, 0
  br i1 %69, label %70, label %81

70:                                               ; preds = %67
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.SNP_DRIVER, ptr %71, i32 0, i32 20
  %73 = getelementptr inbounds %struct.s_pxe_cdb, ptr %72, i32 0, i32 7
  %74 = load i16, ptr %73, align 2, !tbaa !26
  %75 = zext i16 %74 to i32
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.SNP_DRIVER, ptr %76, i32 0, i32 20
  %78 = getelementptr inbounds %struct.s_pxe_cdb, ptr %77, i32 0, i32 6
  %79 = load i16, ptr %78, align 2, !tbaa !25
  %80 = zext i16 %79 to i32
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2, ptr noundef @.str.1, i32 noundef %75, i32 noundef %80)
  br label %81

81:                                               ; preds = %70, %67
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82, %63
  br label %84

84:                                               ; preds = %83
  store i64 -9223372036854775801, ptr %2, align 8
  br label %86

85:                                               ; preds = %48
  store i64 0, ptr %2, align 8
  br label %86

86:                                               ; preds = %85, %84
  %87 = load i64, ptr %2, align 8
  ret i64 %87
}

declare zeroext i8 @DebugPrintEnabled() #1

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #1

declare void @DebugPrint(i64 noundef, ptr noundef, ...) #1

attributes #0 = { 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 #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" }

!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, !17, i64 898}
!10 = !{!"", !11, i64 0, !12, i64 8, !14, i64 32, !15, i64 160, !6, i64 816, !6, i64 824, !6, i64 832, !7, i64 840, !17, i64 842, !11, i64 844, !6, i64 848, !6, i64 856, !6, i64 864, !6, i64 872, !6, i64 880, !6, i64 888, !7, i64 896, !7, i64 897, !18, i64 898, !6, i64 936, !6, i64 944, !6, i64 952, !19, i64 960, !6, i64 1008, !7, i64 1016, !6, i64 2616, !7, i64 2624}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 8, !11, i64 16}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"_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}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, 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}
!16 = !{!"", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!"s_pxe_cdb", !17, i64 0, !17, i64 2, !17, i64 4, !17, i64 6, !13, i64 8, !13, i64 16, !17, i64 24, !17, i64 26, !17, i64 28, !17, i64 30}
!19 = !{!"s_pxe_db_get_init_info", !11, i64 0, !11, i64 4, !7, i64 8, !11, i64 24, !17, i64 28, !17, i64 30, !17, i64 32, !17, i64 34, !17, i64 36, !17, i64 38, !17, i64 40, !17, i64 42, !7, i64 44, !7, i64 45, !7, i64 46}
!20 = !{!10, !17, i64 900}
!21 = !{!10, !17, i64 902}
!22 = !{!10, !17, i64 904}
!23 = !{!10, !13, i64 906}
!24 = !{!10, !13, i64 914}
!25 = !{!10, !17, i64 922}
!26 = !{!10, !17, i64 924}
!27 = !{!10, !17, i64 842}
!28 = !{!10, !17, i64 926}
!29 = !{!10, !17, i64 928}
!30 = !{!10, !6, i64 832}


; 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 [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775801, 1) i64 @PxeReset(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 898
  store i16 6, ptr %2, align 2, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 900
  %4 = getelementptr inbounds i8, ptr %0, i64 922
  %5 = getelementptr inbounds i8, ptr %0, i64 924
  %6 = getelementptr inbounds i8, ptr %0, i64 842
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(26) %3, i8 0, i64 26, i1 false)
  %7 = load i16, ptr %6, align 2, !tbaa !19
  %8 = getelementptr inbounds i8, ptr %0, i64 926
  store i16 %7, ptr %8, align 2, !tbaa !20
  %9 = getelementptr inbounds i8, ptr %0, i64 928
  store i16 0, ptr %9, align 2, !tbaa !21
  %10 = tail call zeroext i8 @DebugPrintEnabled() #3
  %.not = icmp eq i8 %10, 0
  br i1 %.not, label %14, label %11

11:                                               ; preds = %1
  %12 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 16384) #3
  %.not16 = icmp eq i8 %12, 0
  br i1 %.not16, label %14, label %13

13:                                               ; preds = %11
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 16384, ptr noundef nonnull @.str) #3
  br label %14

14:                                               ; preds = %1, %11, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 832
  %16 = load ptr, ptr %15, align 8, !tbaa !22
  %17 = ptrtoint ptr %2 to i64
  %18 = tail call i64 %16(i64 noundef %17) #3
  %19 = load i16, ptr %4, align 2, !tbaa !23
  %.not17 = icmp eq i16 %19, 0
  br i1 %.not17, label %29, label %20

20:                                               ; preds = %14
  %21 = tail call zeroext i8 @DebugPrintEnabled() #3
  %.not18 = icmp eq i8 %21, 0
  br i1 %.not18, label %29, label %22

22:                                               ; preds = %20
  %23 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2) #3
  %.not19 = icmp eq i8 %23, 0
  br i1 %.not19, label %29, label %24

24:                                               ; preds = %22
  %25 = load i16, ptr %5, align 2, !tbaa !24
  %26 = zext i16 %25 to i32
  %27 = load i16, ptr %4, align 2, !tbaa !23
  %28 = zext i16 %27 to i32
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2, ptr noundef nonnull @.str.1, i32 noundef %26, i32 noundef %28) #3
  br label %29

29:                                               ; preds = %14, %24, %22, %20
  %.0 = phi i64 [ -9223372036854775801, %20 ], [ -9223372036854775801, %22 ], [ -9223372036854775801, %24 ], [ 0, %14 ]
  ret i64 %.0
}

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #1

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) local_unnamed_addr #1

declare void @DebugPrint(i64 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !16, i64 898}
!6 = !{!"", !7, i64 0, !10, i64 8, !12, i64 32, !14, i64 160, !13, i64 816, !13, i64 824, !13, i64 832, !8, i64 840, !16, i64 842, !7, i64 844, !13, i64 848, !13, i64 856, !13, i64 864, !13, i64 872, !13, i64 880, !13, i64 888, !8, i64 896, !8, i64 897, !17, i64 898, !13, i64 936, !13, i64 944, !13, i64 952, !18, i64 960, !13, i64 1008, !8, i64 1016, !13, i64 2616, !8, i64 2624}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 8, !7, i64 16}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !11, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !15, i64 552, !15, i64 584, !15, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!15 = !{!"", !8, i64 0}
!16 = !{!"short", !8, i64 0}
!17 = !{!"s_pxe_cdb", !16, i64 0, !16, i64 2, !16, i64 4, !16, i64 6, !11, i64 8, !11, i64 16, !16, i64 24, !16, i64 26, !16, i64 28, !16, i64 30}
!18 = !{!"s_pxe_db_get_init_info", !7, i64 0, !7, i64 4, !8, i64 8, !7, i64 24, !16, i64 28, !16, i64 30, !16, i64 32, !16, i64 34, !16, i64 36, !16, i64 38, !16, i64 40, !16, i64 42, !8, i64 44, !8, i64 45, !8, i64 46}
!19 = !{!6, !16, i64 842}
!20 = !{!6, !16, i64 926}
!21 = !{!6, !16, i64 928}
!22 = !{!6, !13, i64 832}
!23 = !{!6, !16, i64 922}
!24 = !{!6, !16, i64 924}


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