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

; 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.IFR_VARSTORAGE_DATA = type { %struct._LIST_ENTRY, %struct.GUID, ptr, i16, i8, %struct._LIST_ENTRY }
%struct.GUID = type { i32, i16, i16, [8 x i8] }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._EFI_IFR_QUESTION_HEADER = type <{ %struct._EFI_IFR_STATEMENT_HEADER, i16, i16, %union.anon, i8 }>
%struct._EFI_IFR_STATEMENT_HEADER = type { i16, i16 }
%union.anon = type { i16 }
%struct.IFR_BLOCK_DATA = type { %struct._LIST_ENTRY, i16, i16, i16, i8, i8, %struct._LIST_ENTRY, ptr }
%struct._EFI_IFR_OP_HEADER = type { i8, 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

declare ptr @AllocateZeroPool(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @InsertBlockData(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @InternalGetString(ptr noundef, i16 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @BlockArrayCheck(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i8 noundef zeroext, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @IsThisOpcodeRequired(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i16 noundef zeroext %4, ptr noundef %5) #2 {
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i16, align 2
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i16, align 2
  %16 = alloca i16, align 2
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i16 %4, ptr %12, align 2, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store i16 0, ptr %16, align 2, !tbaa !9
  store i16 0, ptr %15, align 2, !tbaa !9
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 2
  store ptr %20, ptr %17, align 8, !tbaa !5
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.IFR_VARSTORAGE_DATA, ptr %21, i32 0, i32 4
  %23 = load i8, ptr %22, align 2, !tbaa !11
  %24 = zext i8 %23 to i32
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %37

26:                                               ; preds = %6
  %27 = load ptr, ptr %17, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._EFI_IFR_QUESTION_HEADER, ptr %27, i32 0, i32 3
  %29 = load i16, ptr %28, align 1, !tbaa !16
  store i16 %29, ptr %16, align 2, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i16, ptr %16, align 2, !tbaa !9
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call zeroext i8 @BlockArrayCheck(ptr noundef %30, i16 noundef zeroext %31, i16 noundef zeroext 0, i8 noundef zeroext 1, ptr noundef %32)
  %34 = icmp ne i8 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %26
  store i64 0, ptr %7, align 8
  store i32 1, ptr %18, align 4
  br label %109

36:                                               ; preds = %26
  br label %61

37:                                               ; preds = %6
  %38 = load ptr, ptr %17, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._EFI_IFR_QUESTION_HEADER, ptr %38, i32 0, i32 3
  %40 = load i16, ptr %39, align 1, !tbaa !16
  store i16 %40, ptr %15, align 2, !tbaa !9
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i16, ptr %15, align 2, !tbaa !9
  %43 = load i16, ptr %12, align 2, !tbaa !9
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = call zeroext i8 @BlockArrayCheck(ptr noundef %41, i16 noundef zeroext %42, i16 noundef zeroext %43, i8 noundef zeroext 0, ptr noundef %44)
  %46 = icmp ne i8 %45, 0
  br i1 %46, label %48, label %47

47:                                               ; preds = %37
  store i64 0, ptr %7, align 8
  store i32 1, ptr %18, align 4
  br label %109

48:                                               ; preds = %37
  %49 = load i16, ptr %15, align 2, !tbaa !9
  %50 = zext i16 %49 to i32
  %51 = load i16, ptr %12, align 2, !tbaa !9
  %52 = zext i16 %51 to i32
  %53 = add nsw i32 %50, %52
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.IFR_VARSTORAGE_DATA, ptr %54, i32 0, i32 3
  %56 = load i16, ptr %55, align 8, !tbaa !17
  %57 = zext i16 %56 to i32
  %58 = icmp sgt i32 %53, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %48
  store i64 -9223372036854775806, ptr %7, align 8
  store i32 1, ptr %18, align 4
  br label %109

60:                                               ; preds = %48
  br label %61

61:                                               ; preds = %60, %36
  %62 = call ptr @AllocateZeroPool(i64 noundef 48)
  store ptr %62, ptr %14, align 8, !tbaa !5
  %63 = load ptr, ptr %14, align 8, !tbaa !5
  %64 = icmp eq ptr %63, null
  br i1 %64, label %65, label %66

65:                                               ; preds = %61
  store i64 -9223372036854775799, ptr %7, align 8
  store i32 1, ptr %18, align 4
  br label %109

66:                                               ; preds = %61
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.IFR_VARSTORAGE_DATA, ptr %67, i32 0, i32 4
  %69 = load i8, ptr %68, align 2, !tbaa !11
  %70 = zext i8 %69 to i32
  %71 = icmp eq i32 %70, 1
  br i1 %71, label %72, label %78

72:                                               ; preds = %66
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = load i16, ptr %16, align 2, !tbaa !9
  %75 = call ptr @InternalGetString(ptr noundef %73, i16 noundef zeroext %74)
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.IFR_BLOCK_DATA, ptr %76, i32 0, i32 7
  store ptr %75, ptr %77, align 8, !tbaa !18
  br label %82

78:                                               ; preds = %66
  %79 = load i16, ptr %15, align 2, !tbaa !9
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.IFR_BLOCK_DATA, ptr %80, i32 0, i32 1
  store i16 %79, ptr %81, align 8, !tbaa !20
  br label %82

82:                                               ; preds = %78, %72
  %83 = load i16, ptr %12, align 2, !tbaa !9
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.IFR_BLOCK_DATA, ptr %84, i32 0, i32 2
  store i16 %83, ptr %85, align 2, !tbaa !21
  %86 = load ptr, ptr %17, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._EFI_IFR_QUESTION_HEADER, ptr %86, i32 0, i32 1
  %88 = load i16, ptr %87, align 1, !tbaa !22
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.IFR_BLOCK_DATA, ptr %89, i32 0, i32 3
  store i16 %88, ptr %90, align 4, !tbaa !25
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._EFI_IFR_OP_HEADER, ptr %91, i32 0, i32 0
  %93 = load i8, ptr %92, align 1, !tbaa !26
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.IFR_BLOCK_DATA, ptr %94, i32 0, i32 4
  store i8 %93, ptr %95, align 2, !tbaa !28
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct._EFI_IFR_OP_HEADER, ptr %96, i32 0, i32 1
  %98 = load i8, ptr %97, align 1
  %99 = lshr i8 %98, 7
  %100 = load ptr, ptr %14, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.IFR_BLOCK_DATA, ptr %100, i32 0, i32 5
  store i8 %99, ptr %101, align 1, !tbaa !29
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.IFR_BLOCK_DATA, ptr %102, i32 0, i32 6
  %104 = call ptr @InitializeListHead(ptr noundef %103)
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.IFR_VARSTORAGE_DATA, ptr %105, i32 0, i32 5
  call void @InsertBlockData(ptr noundef %106, ptr noundef %14)
  %107 = load ptr, ptr %14, align 8, !tbaa !5
  %108 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %107, ptr %108, align 8, !tbaa !5
  store i64 0, ptr %7, align 8
  store i32 1, ptr %18, align 4
  br label %109

109:                                              ; preds = %82, %65, %59, %47, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %110 = load i64, ptr %7, align 8
  ret i64 %110
}

declare ptr @InitializeListHead(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 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !7, i64 42}
!12 = !{!"", !13, i64 0, !14, i64 16, !6, i64 32, !10, i64 40, !7, i64 42, !13, i64 48}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"", !15, i64 0, !10, i64 4, !10, i64 6, !7, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!12, !10, i64 40}
!18 = !{!19, !6, i64 40}
!19 = !{!"", !13, i64 0, !10, i64 16, !10, i64 18, !10, i64 20, !7, i64 22, !7, i64 23, !13, i64 24, !6, i64 40}
!20 = !{!19, !10, i64 16}
!21 = !{!19, !10, i64 18}
!22 = !{!23, !10, i64 4}
!23 = !{!"_EFI_IFR_QUESTION_HEADER", !24, i64 0, !10, i64 4, !10, i64 6, !7, i64 8, !7, i64 10}
!24 = !{!"_EFI_IFR_STATEMENT_HEADER", !10, i64 0, !10, i64 2}
!25 = !{!19, !10, i64 20}
!26 = !{!27, !7, i64 0}
!27 = !{!"_EFI_IFR_OP_HEADER", !7, i64 0, !7, i64 1, !7, i64 1}
!28 = !{!19, !7, i64 22}
!29 = !{!19, !7, i64 23}


; 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 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

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @InsertBlockData(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @InternalGetString(ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @BlockArrayCheck(ptr noundef, i16 noundef zeroext, i16 noundef zeroext, i8 noundef zeroext, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775806, 1) i64 @IsThisOpcodeRequired(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3, i16 noundef zeroext %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #2 {
  %7 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %8 = getelementptr inbounds i8, ptr %2, i64 42
  %9 = load i8, ptr %8, align 2, !tbaa !5
  %10 = icmp eq i8 %9, 1
  %11 = getelementptr inbounds i8, ptr %3, i64 10
  %12 = load i16, ptr %11, align 1, !tbaa !14
  br i1 %10, label %13, label %15

13:                                               ; preds = %6
  %14 = tail call zeroext i8 @BlockArrayCheck(ptr noundef %0, i16 noundef zeroext %12, i16 noundef zeroext 0, i8 noundef zeroext 1, ptr noundef %1)
  %.not27 = icmp eq i8 %14, 0
  br i1 %.not27, label %51, label %25

15:                                               ; preds = %6
  %16 = tail call zeroext i8 @BlockArrayCheck(ptr noundef %0, i16 noundef zeroext %12, i16 noundef zeroext %4, i8 noundef zeroext 0, ptr noundef %1)
  %.not = icmp eq i8 %16, 0
  br i1 %.not, label %51, label %17

17:                                               ; preds = %15
  %18 = zext i16 %12 to i32
  %19 = zext i16 %4 to i32
  %20 = add nuw nsw i32 %18, %19
  %21 = getelementptr inbounds i8, ptr %2, i64 40
  %22 = load i16, ptr %21, align 8, !tbaa !15
  %23 = zext i16 %22 to i32
  %24 = icmp ugt i32 %20, %23
  br i1 %24, label %51, label %25

25:                                               ; preds = %17, %13
  %.025 = phi i16 [ 0, %13 ], [ %12, %17 ]
  %.024 = phi i16 [ %12, %13 ], [ 0, %17 ]
  %26 = tail call ptr @AllocateZeroPool(i64 noundef 48) #3
  store ptr %26, ptr %7, align 8, !tbaa !16
  %27 = icmp eq ptr %26, null
  br i1 %27, label %51, label %28

28:                                               ; preds = %25
  %29 = load i8, ptr %8, align 2, !tbaa !5
  %30 = icmp eq i8 %29, 1
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  %32 = tail call ptr @InternalGetString(ptr noundef %1, i16 noundef zeroext %.024)
  %33 = getelementptr inbounds i8, ptr %26, i64 40
  store ptr %32, ptr %33, align 8, !tbaa !17
  br label %36

34:                                               ; preds = %28
  %35 = getelementptr inbounds i8, ptr %26, i64 16
  store i16 %.025, ptr %35, align 8, !tbaa !19
  br label %36

36:                                               ; preds = %34, %31
  %37 = getelementptr inbounds i8, ptr %26, i64 18
  store i16 %4, ptr %37, align 2, !tbaa !20
  %38 = getelementptr inbounds i8, ptr %3, i64 6
  %39 = load i16, ptr %38, align 1, !tbaa !21
  %40 = getelementptr inbounds i8, ptr %26, i64 20
  store i16 %39, ptr %40, align 4, !tbaa !24
  %41 = load i8, ptr %3, align 1, !tbaa !25
  %42 = getelementptr inbounds i8, ptr %26, i64 22
  store i8 %41, ptr %42, align 2, !tbaa !27
  %43 = getelementptr inbounds i8, ptr %3, i64 1
  %44 = load i8, ptr %43, align 1
  %45 = lshr i8 %44, 7
  %46 = getelementptr inbounds i8, ptr %26, i64 23
  store i8 %45, ptr %46, align 1, !tbaa !28
  %47 = getelementptr inbounds i8, ptr %26, i64 24
  %48 = tail call ptr @InitializeListHead(ptr noundef nonnull %47) #3
  %49 = getelementptr inbounds i8, ptr %2, i64 48
  call void @InsertBlockData(ptr noundef nonnull %49, ptr noundef nonnull %7)
  %50 = load ptr, ptr %7, align 8, !tbaa !16
  store ptr %50, ptr %5, align 8, !tbaa !16
  br label %51

51:                                               ; preds = %25, %17, %15, %13, %36
  %.0 = phi i64 [ 0, %36 ], [ 0, %13 ], [ 0, %15 ], [ -9223372036854775806, %17 ], [ -9223372036854775799, %25 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  ret i64 %.0
}

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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, !9, i64 42}
!6 = !{!"", !7, i64 0, !11, i64 16, !8, i64 32, !13, i64 40, !9, i64 42, !7, i64 48}
!7 = !{!"_LIST_ENTRY", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"", !12, i64 0, !13, i64 4, !13, i64 6, !9, i64 8}
!12 = !{!"int", !9, i64 0}
!13 = !{!"short", !9, i64 0}
!14 = !{!9, !9, i64 0}
!15 = !{!6, !13, i64 40}
!16 = !{!8, !8, i64 0}
!17 = !{!18, !8, i64 40}
!18 = !{!"", !7, i64 0, !13, i64 16, !13, i64 18, !13, i64 20, !9, i64 22, !9, i64 23, !7, i64 24, !8, i64 40}
!19 = !{!18, !13, i64 16}
!20 = !{!18, !13, i64 18}
!21 = !{!22, !13, i64 4}
!22 = !{!"_EFI_IFR_QUESTION_HEADER", !23, i64 0, !13, i64 4, !13, i64 6, !9, i64 8, !9, i64 10}
!23 = !{!"_EFI_IFR_STATEMENT_HEADER", !13, i64 0, !13, i64 2}
!24 = !{!18, !13, i64 20}
!25 = !{!26, !9, i64 0}
!26 = !{!"_EFI_IFR_OP_HEADER", !9, i64 0, !9, i64 1, !9, i64 1}
!27 = !{!18, !9, i64 22}
!28 = !{!18, !9, i64 23}


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