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

; 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_DPC_PROTOCOL = type { ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }
%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 }

@mDpcHandle = external dso_local global ptr, align 8
@mDpc = external dso_local global %struct._EFI_DPC_PROTOCOL, align 8
@gBS = external global ptr, align 8
@mDpcQueue = external dso_local global [32 x %struct._LIST_ENTRY], align 16
@gEfiDpcProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [145 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; 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 @DpcDriverEntryPoint(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  br label %8

8:                                                ; preds = %2
  %9 = call zeroext i8 @DebugAssertEnabled()
  %10 = icmp ne i8 %9, 0
  br i1 %10, label %11, label %26

11:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  br label %12

12:                                               ; preds = %11
  %13 = call zeroext i8 @DebugAssertEnabled()
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  br label %16

16:                                               ; preds = %15, %12
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = load ptr, ptr @gBS, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %19, i32 0, i32 38
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call i64 %21(ptr noundef @gEfiDpcProtocolGuid, ptr noundef null, ptr noundef %7)
  %23 = icmp slt i64 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  call void @DebugAssert(ptr noundef @.str, i64 noundef 326, ptr noundef @.str.1)
  br label %25

25:                                               ; preds = %24, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %26

26:                                               ; preds = %25, %8
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  store i64 0, ptr %6, align 8, !tbaa !14
  br label %29

29:                                               ; preds = %36, %28
  %30 = load i64, ptr %6, align 8, !tbaa !14
  %31 = icmp ule i64 %30, 31
  br i1 %31, label %32, label %39

32:                                               ; preds = %29
  %33 = load i64, ptr %6, align 8, !tbaa !14
  %34 = getelementptr inbounds [32 x %struct._LIST_ENTRY], ptr @mDpcQueue, i64 0, i64 %33
  %35 = call ptr @InitializeListHead(ptr noundef %34)
  br label %36

36:                                               ; preds = %32
  %37 = load i64, ptr %6, align 8, !tbaa !14
  %38 = add i64 %37, 1
  store i64 %38, ptr %6, align 8, !tbaa !14
  br label %29, !llvm.loop !15

39:                                               ; preds = %29
  %40 = load ptr, ptr @gBS, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %40, i32 0, i32 39
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = call i64 (ptr, ...) %42(ptr noundef @mDpcHandle, ptr noundef @gEfiDpcProtocolGuid, ptr noundef @mDpc, ptr noundef null)
  store i64 %43, ptr %5, align 8, !tbaa !14
  br label %44

44:                                               ; preds = %39
  %45 = call zeroext i8 @DebugAssertEnabled()
  %46 = icmp ne i8 %45, 0
  br i1 %46, label %47, label %67

47:                                               ; preds = %44
  %48 = load i64, ptr %5, align 8, !tbaa !14
  %49 = icmp slt i64 %48, 0
  br i1 %49, label %50, label %66

50:                                               ; preds = %47
  br label %51

51:                                               ; preds = %50
  %52 = call zeroext i8 @DebugPrintEnabled()
  %53 = icmp ne i8 %52, 0
  br i1 %53, label %54, label %63

54:                                               ; preds = %51
  br label %55

55:                                               ; preds = %54
  %56 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %57 = icmp ne i8 %56, 0
  br i1 %57, label %58, label %60

58:                                               ; preds = %55
  %59 = load i64, ptr %5, align 8, !tbaa !14
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.2, i64 noundef %59)
  br label %60

60:                                               ; preds = %58, %55
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62, %51
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64
  call void @DebugAssert(ptr noundef @.str, i64 noundef 344, ptr noundef @.str.3)
  br label %66

66:                                               ; preds = %65, %47
  br label %67

67:                                               ; preds = %66, %44
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  %70 = load i64, ptr %5, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i64 %70
}

declare zeroext i8 @DebugAssertEnabled() #2

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #2

declare ptr @InitializeListHead(ptr noundef) #2

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

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

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 = { "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, !6, i64 320}
!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 = !{!12, !12, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!10, !6, i64 328}


; 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._EFI_DPC_PROTOCOL = type { ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }

@mDpcHandle = external dso_local global ptr, align 8
@mDpc = external dso_local global %struct._EFI_DPC_PROTOCOL, align 8
@gBS = external local_unnamed_addr global ptr, align 8
@mDpcQueue = external dso_local global [32 x %struct._LIST_ENTRY], align 16
@gEfiDpcProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [145 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; 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 i64 @DpcDriverEntryPoint(ptr nocapture noundef readnone %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  %4 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %14, label %5

5:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %6 = tail call zeroext i8 @DebugAssertEnabled() #3
  %7 = load ptr, ptr @gBS, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 320
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = call i64 %9(ptr noundef nonnull @gEfiDpcProtocolGuid, ptr noundef null, ptr noundef nonnull %3) #3
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %5
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 326, ptr noundef nonnull @.str.1) #3
  br label %13

13:                                               ; preds = %12, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %14

14:                                               ; preds = %13, %2
  %15 = call ptr @InitializeListHead(ptr noundef nonnull @mDpcQueue) #3
  %16 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 16)) #3
  %17 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 32)) #3
  %18 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 48)) #3
  %19 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 64)) #3
  %20 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 80)) #3
  %21 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 96)) #3
  %22 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 112)) #3
  %23 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 128)) #3
  %24 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 144)) #3
  %25 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 160)) #3
  %26 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 176)) #3
  %27 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 192)) #3
  %28 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 208)) #3
  %29 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 224)) #3
  %30 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 240)) #3
  %31 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 256)) #3
  %32 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 272)) #3
  %33 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 288)) #3
  %34 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 304)) #3
  %35 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 320)) #3
  %36 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 336)) #3
  %37 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 352)) #3
  %38 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 368)) #3
  %39 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 384)) #3
  %40 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 400)) #3
  %41 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 416)) #3
  %42 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 432)) #3
  %43 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 448)) #3
  %44 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 464)) #3
  %45 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 480)) #3
  %46 = call ptr @InitializeListHead(ptr noundef nonnull getelementptr inbounds (i8, ptr @mDpcQueue, i64 496)) #3
  %47 = load ptr, ptr @gBS, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i64 328
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = call i64 (ptr, ...) %49(ptr noundef nonnull @mDpcHandle, ptr noundef nonnull @gEfiDpcProtocolGuid, ptr noundef nonnull @mDpc, ptr noundef null) #3
  %51 = call zeroext i8 @DebugAssertEnabled() #3
  %52 = icmp ne i8 %51, 0
  %53 = icmp slt i64 %50, 0
  %or.cond = select i1 %52, i1 %53, i1 false
  br i1 %or.cond, label %54, label %60

54:                                               ; preds = %14
  %55 = call zeroext i8 @DebugPrintEnabled() #3
  %.not8 = icmp eq i8 %55, 0
  br i1 %.not8, label %59, label %56

56:                                               ; preds = %54
  %57 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not9 = icmp eq i8 %57, 0
  br i1 %.not9, label %59, label %58

58:                                               ; preds = %56
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.2, i64 noundef %50) #3
  br label %59

59:                                               ; preds = %56, %58, %54
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 344, ptr noundef nonnull @.str.3) #3
  br label %60

60:                                               ; preds = %59, %14
  ret i64 %50
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #2

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #2

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

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

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 = { "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, !6, i64 320}
!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 = !{!10, !6, i64 328}


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