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

; 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_SECURITY_ARCH_PROTOCOL = type { ptr }
%struct._EFI_SECURITY2_ARCH_PROTOCOL = type { 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 }

@mSecurityArchProtocolHandle = external dso_local global ptr, align 8
@mSecurityStub = external dso_local global %struct._EFI_SECURITY_ARCH_PROTOCOL, align 8
@mSecurity2Stub = external dso_local global %struct._EFI_SECURITY2_ARCH_PROTOCOL, align 8
@gBS = external global ptr, align 8
@gEfiSecurity2ArchProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [155 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@gEfiSecurityArchProtocolGuid = external global %struct.GUID, align 4
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.4 = 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 @SecurityStubInitialize(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, 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
  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 %6) #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 @gEfiSecurity2ArchProtocolGuid, ptr noundef null, ptr noundef %6)
  %23 = icmp slt i64 %22, 0
  br i1 %23, label %25, label %24

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

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

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

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  %30 = call zeroext i8 @DebugAssertEnabled()
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %32, label %47

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

33:                                               ; preds = %32
  %34 = call zeroext i8 @DebugAssertEnabled()
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  br label %37

37:                                               ; preds = %36, %33
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr @gBS, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %40, i32 0, i32 38
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = call i64 %42(ptr noundef @gEfiSecurityArchProtocolGuid, ptr noundef null, ptr noundef %7)
  %44 = icmp slt i64 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %39
  call void @DebugAssert(ptr noundef @.str, i64 noundef 188, ptr noundef @.str.2)
  br label %46

46:                                               ; preds = %45, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %47

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

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr @gBS, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %50, i32 0, i32 39
  %52 = load ptr, ptr %51, align 8, !tbaa !14
  %53 = call i64 (ptr, ...) %52(ptr noundef @mSecurityArchProtocolHandle, ptr noundef @gEfiSecurity2ArchProtocolGuid, ptr noundef @mSecurity2Stub, ptr noundef @gEfiSecurityArchProtocolGuid, ptr noundef @mSecurityStub, ptr noundef null)
  store i64 %53, ptr %5, align 8, !tbaa !15
  br label %54

54:                                               ; preds = %49
  %55 = call zeroext i8 @DebugAssertEnabled()
  %56 = icmp ne i8 %55, 0
  br i1 %56, label %57, label %77

57:                                               ; preds = %54
  %58 = load i64, ptr %5, align 8, !tbaa !15
  %59 = icmp slt i64 %58, 0
  br i1 %59, label %60, label %76

60:                                               ; preds = %57
  br label %61

61:                                               ; preds = %60
  %62 = call zeroext i8 @DebugPrintEnabled()
  %63 = icmp ne i8 %62, 0
  br i1 %63, label %64, label %73

64:                                               ; preds = %61
  br label %65

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

68:                                               ; preds = %65
  %69 = load i64, ptr %5, align 8, !tbaa !15
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.3, i64 noundef %69)
  br label %70

70:                                               ; preds = %68, %65
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72, %61
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  call void @DebugAssert(ptr noundef @.str, i64 noundef 201, ptr noundef @.str.4)
  br label %76

76:                                               ; preds = %75, %57
  br label %77

77:                                               ; preds = %76, %54
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i64 0
}

declare zeroext i8 @DebugAssertEnabled() #2

declare void @DebugAssert(ptr noundef, i64 noundef, 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 = !{!10, !6, i64 328}
!15 = !{!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"

%struct._EFI_SECURITY_ARCH_PROTOCOL = type { ptr }
%struct._EFI_SECURITY2_ARCH_PROTOCOL = type { ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }

@mSecurityArchProtocolHandle = external dso_local global ptr, align 8
@mSecurityStub = external dso_local global %struct._EFI_SECURITY_ARCH_PROTOCOL, align 8
@mSecurity2Stub = external dso_local global %struct._EFI_SECURITY2_ARCH_PROTOCOL, align 8
@gBS = external local_unnamed_addr global ptr, align 8
@gEfiSecurity2ArchProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [155 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@gEfiSecurityArchProtocolGuid = external global %struct.GUID, align 4
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.4 = 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 noundef i64 @SecurityStubInitialize(ptr nocapture noundef readnone %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %15, label %6

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

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

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

15:                                               ; preds = %2, %14
  %16 = call zeroext i8 @DebugAssertEnabled() #3
  %.not3 = icmp eq i8 %16, 0
  br i1 %.not3, label %26, label %17

17:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %18 = call zeroext i8 @DebugAssertEnabled() #3
  %19 = load ptr, ptr @gBS, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 320
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call i64 %21(ptr noundef nonnull @gEfiSecurityArchProtocolGuid, ptr noundef null, ptr noundef nonnull %4) #3
  %23 = icmp slt i64 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %17
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 188, ptr noundef nonnull @.str.2) #3
  br label %25

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

26:                                               ; preds = %25, %15
  %27 = load ptr, ptr @gBS, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 328
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = call i64 (ptr, ...) %29(ptr noundef nonnull @mSecurityArchProtocolHandle, ptr noundef nonnull @gEfiSecurity2ArchProtocolGuid, ptr noundef nonnull @mSecurity2Stub, ptr noundef nonnull @gEfiSecurityArchProtocolGuid, ptr noundef nonnull @mSecurityStub, ptr noundef null) #3
  %31 = call zeroext i8 @DebugAssertEnabled() #3
  %32 = icmp ne i8 %31, 0
  %33 = icmp slt i64 %30, 0
  %or.cond = select i1 %32, i1 %33, i1 false
  br i1 %or.cond, label %34, label %40

34:                                               ; preds = %26
  %35 = call zeroext i8 @DebugPrintEnabled() #3
  %.not4 = icmp eq i8 %35, 0
  br i1 %.not4, label %39, label %36

36:                                               ; preds = %34
  %37 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not5 = icmp eq i8 %37, 0
  br i1 %.not5, label %39, label %38

38:                                               ; preds = %36
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.3, i64 noundef %30) #3
  br label %39

39:                                               ; preds = %36, %38, %34
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 201, ptr noundef nonnull @.str.4) #3
  br label %40

40:                                               ; preds = %39, %26
  ret i64 0
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

declare void @DebugAssert(ptr noundef, i64 noundef, 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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass