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

; 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.s_data_instance = type { i16, i16, i8, i8, i16, i16, i16, i16, i16, [32 x i8], [32 x i8], [32 x i8], [64 x i32], [128 x i32], i32, i32, i16, i16, i8, i8, i8, i8, i16, i16, i16, i16, i32, i32, i16, i16, [2 x i16], i8, i8, i16, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, [64 x i64], i16, i16, i16, i16, i8, i8, i8, i8, i8, [3 x i8], %struct.mc, i64, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mc = type { [3 x i16], i16, [8 x [32 x i8]] }
%struct.s_TxCB = type { %struct.CB_Header, i32, i16, i8, i8, [64 x i8], [16 x %struct.TBD], i32, i32, ptr, ptr, i64 }
%struct.CB_Header = type { i16, i16, i32 }
%struct.TBD = type { i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @InByte(ptr noundef, i32 noundef) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @InWord(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @OutByte(ptr noundef, i8 noundef zeroext, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @OutWord(ptr noundef, i16 noundef zeroext, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @OutLong(ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @DelayIt(ptr noundef, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @IssueCB(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca i16, align 2
  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 2, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #2
  store i16 2000, ptr %6, align 2, !tbaa !9
  br label %7

7:                                                ; preds = %23, %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.s_data_instance, ptr %9, i32 0, i32 14
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = add i32 %11, 2
  %13 = call zeroext i8 @InByte(ptr noundef %8, i32 noundef %12)
  %14 = zext i8 %13 to i32
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %7
  %17 = load i16, ptr %6, align 2, !tbaa !9
  %18 = add i16 %17, -1
  store i16 %18, ptr %6, align 2, !tbaa !9
  %19 = sext i16 %18 to i32
  %20 = icmp sge i32 %19, 0
  br label %21

21:                                               ; preds = %16, %7
  %22 = phi i1 [ false, %7 ], [ %20, %16 ]
  br i1 %22, label %23, label %25

23:                                               ; preds = %21
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  call void @DelayIt(ptr noundef %24, i16 noundef zeroext 10)
  br label %7, !llvm.loop !16

25:                                               ; preds = %21
  %26 = load i16, ptr %6, align 2, !tbaa !9
  %27 = sext i16 %26 to i32
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  call void @DelayIt(ptr noundef %30, i16 noundef zeroext 50)
  br label %31

31:                                               ; preds = %29, %25
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #2
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.s_data_instance, ptr %33, i32 0, i32 14
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = add i32 %35, 0
  %37 = call zeroext i16 @InWord(ptr noundef %32, i32 noundef %36)
  store i16 %37, ptr %5, align 2, !tbaa !9
  %38 = load i16, ptr %5, align 2, !tbaa !9
  %39 = zext i16 %38 to i32
  %40 = and i32 %39, 8192
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %48

42:                                               ; preds = %31
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.s_data_instance, ptr %44, i32 0, i32 14
  %46 = load i32, ptr %45, align 8, !tbaa !11
  %47 = add i32 %46, 0
  call void @OutWord(ptr noundef %43, i16 noundef zeroext 8192, i32 noundef %47)
  br label %48

48:                                               ; preds = %42, %31
  %49 = load i16, ptr %5, align 2, !tbaa !9
  %50 = zext i16 %49 to i32
  %51 = and i32 %50, 192
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %67

53:                                               ; preds = %48
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.s_TxCB, ptr %55, i32 0, i32 8
  %57 = load i32, ptr %56, align 1, !tbaa !18
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.s_data_instance, ptr %58, i32 0, i32 14
  %60 = load i32, ptr %59, align 8, !tbaa !11
  %61 = add i32 %60, 4
  call void @OutLong(ptr noundef %54, i32 noundef %57, i32 noundef %61)
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.s_data_instance, ptr %63, i32 0, i32 14
  %65 = load i32, ptr %64, align 8, !tbaa !11
  %66 = add i32 %65, 2
  call void @OutByte(ptr noundef %62, i8 noundef zeroext 16, i32 noundef %66)
  br label %82

67:                                               ; preds = %48
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.s_TxCB, ptr %68, i32 0, i32 10
  %70 = load ptr, ptr %69, align 1, !tbaa !21
  %71 = getelementptr inbounds %struct.s_TxCB, ptr %70, i32 0, i32 0
  %72 = getelementptr inbounds %struct.CB_Header, ptr %71, i32 0, i32 1
  %73 = load i16, ptr %72, align 1, !tbaa !22
  %74 = zext i16 %73 to i32
  %75 = and i32 %74, -24577
  %76 = trunc i32 %75 to i16
  store i16 %76, ptr %72, align 1, !tbaa !22
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.s_data_instance, ptr %78, i32 0, i32 14
  %80 = load i32, ptr %79, align 8, !tbaa !11
  %81 = add i32 %80, 2
  call void @OutByte(ptr noundef %77, i8 noundef zeroext 32, i32 noundef %81)
  br label %82

82:                                               ; preds = %67, %53
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #2
  ret i8 0
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !13, i64 880}
!12 = !{!"s_data_instance", !10, i64 0, !10, i64 2, !7, i64 4, !7, i64 5, !10, i64 6, !10, i64 8, !10, i64 10, !10, i64 12, !10, i64 14, !7, i64 16, !7, i64 48, !7, i64 80, !7, i64 112, !7, i64 368, !13, i64 880, !13, i64 884, !10, i64 888, !10, i64 890, !7, i64 892, !7, i64 893, !7, i64 894, !7, i64 895, !10, i64 896, !10, i64 898, !10, i64 900, !10, i64 902, !13, i64 904, !13, i64 908, !10, i64 912, !10, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !10, i64 922, !13, i64 924, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !14, i64 976, !14, i64 984, !14, i64 992, !14, i64 1000, !14, i64 1008, !7, i64 1016, !10, i64 1528, !10, i64 1530, !10, i64 1532, !10, i64 1534, !7, i64 1536, !7, i64 1537, !7, i64 1538, !7, i64 1539, !7, i64 1540, !7, i64 1541, !15, i64 1544, !14, i64 1808, !6, i64 1816, !14, i64 1824, !6, i64 1832, !6, i64 1840, !6, i64 1848, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888, !6, i64 1896, !6, i64 1904, !6, i64 1912}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"mc", !7, i64 0, !10, i64 6, !7, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !13, i64 212}
!19 = !{!"s_TxCB", !20, i64 0, !13, i64 8, !10, i64 12, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 80, !13, i64 208, !13, i64 212, !6, i64 216, !6, i64 224, !14, i64 232}
!20 = !{!"CB_Header", !10, i64 0, !10, i64 2, !13, i64 4}
!21 = !{!19, !6, i64 224}
!22 = !{!19, !10, i64 2}


; 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: nounwind uwtable
declare dso_local zeroext i8 @InByte(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @InWord(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @OutByte(ptr noundef, i8 noundef zeroext, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @OutWord(ptr noundef, i16 noundef zeroext, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @OutLong(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @DelayIt(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i8 @IssueCB(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 880
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = add i32 %4, 2
  %6 = tail call zeroext i8 @InByte(ptr noundef %0, i32 noundef %5)
  %.not23 = icmp eq i8 %6, 0
  br i1 %.not23, label %.critedge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %2, %8
  %.024 = phi i16 [ %9, %8 ], [ 2000, %2 ]
  %7 = icmp sgt i16 %.024, 0
  br i1 %7, label %8, label %.critedge.thread

8:                                                ; preds = %.lr.ph
  %9 = add nsw i16 %.024, -1
  tail call void @DelayIt(ptr noundef nonnull %0, i16 noundef zeroext 10)
  %10 = load i32, ptr %3, align 8, !tbaa !5
  %11 = add i32 %10, 2
  %12 = tail call zeroext i8 @InByte(ptr noundef nonnull %0, i32 noundef %11)
  %.not = icmp eq i8 %12, 0
  br i1 %.not, label %.critedge, label %.lr.ph, !llvm.loop !14

.critedge:                                        ; preds = %8
  %13 = icmp eq i16 %9, 0
  br i1 %13, label %14, label %.critedge.thread

14:                                               ; preds = %.critedge
  tail call void @DelayIt(ptr noundef nonnull %0, i16 noundef zeroext 50)
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %.lr.ph, %2, %14, %.critedge
  %15 = load i32, ptr %3, align 8, !tbaa !5
  %16 = tail call zeroext i16 @InWord(ptr noundef nonnull %0, i32 noundef %15)
  %17 = zext i16 %16 to i32
  %18 = and i32 %17, 8192
  %.not19 = icmp eq i32 %18, 0
  br i1 %.not19, label %21, label %19

19:                                               ; preds = %.critedge.thread
  %20 = load i32, ptr %3, align 8, !tbaa !5
  tail call void @OutWord(ptr noundef nonnull %0, i16 noundef zeroext 8192, i32 noundef %20)
  br label %21

21:                                               ; preds = %19, %.critedge.thread
  %22 = and i32 %17, 192
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %29

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %1, i64 212
  %26 = load i32, ptr %25, align 1, !tbaa !16
  %27 = load i32, ptr %3, align 8, !tbaa !5
  %28 = add i32 %27, 4
  tail call void @OutLong(ptr noundef nonnull %0, i32 noundef %26, i32 noundef %28)
  br label %35

29:                                               ; preds = %21
  %30 = getelementptr inbounds i8, ptr %1, i64 224
  %31 = load ptr, ptr %30, align 1, !tbaa !19
  %32 = getelementptr inbounds i8, ptr %31, i64 2
  %33 = load i16, ptr %32, align 1, !tbaa !20
  %34 = and i16 %33, -24577
  store i16 %34, ptr %32, align 1, !tbaa !20
  br label %35

35:                                               ; preds = %29, %24
  %.sink = phi i8 [ 32, %29 ], [ 16, %24 ]
  %36 = load i32, ptr %3, align 8, !tbaa !5
  %37 = add i32 %36, 2
  tail call void @OutByte(ptr noundef nonnull %0, i8 noundef zeroext %.sink, i32 noundef %37)
  ret i8 0
}

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" }

!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, !10, i64 880}
!6 = !{!"s_data_instance", !7, i64 0, !7, i64 2, !8, i64 4, !8, i64 5, !7, i64 6, !7, i64 8, !7, i64 10, !7, i64 12, !7, i64 14, !8, i64 16, !8, i64 48, !8, i64 80, !8, i64 112, !8, i64 368, !10, i64 880, !10, i64 884, !7, i64 888, !7, i64 890, !8, i64 892, !8, i64 893, !8, i64 894, !8, i64 895, !7, i64 896, !7, i64 898, !7, i64 900, !7, i64 902, !10, i64 904, !10, i64 908, !7, i64 912, !7, i64 914, !8, i64 916, !8, i64 920, !8, i64 921, !7, i64 922, !10, i64 924, !11, i64 928, !11, i64 936, !11, i64 944, !11, i64 952, !11, i64 960, !11, i64 968, !12, i64 976, !12, i64 984, !12, i64 992, !12, i64 1000, !12, i64 1008, !8, i64 1016, !7, i64 1528, !7, i64 1530, !7, i64 1532, !7, i64 1534, !8, i64 1536, !8, i64 1537, !8, i64 1538, !8, i64 1539, !8, i64 1540, !8, i64 1541, !13, i64 1544, !12, i64 1808, !11, i64 1816, !12, i64 1824, !11, i64 1832, !11, i64 1840, !11, i64 1848, !11, i64 1856, !11, i64 1864, !11, i64 1872, !11, i64 1880, !11, i64 1888, !11, i64 1896, !11, i64 1904, !11, i64 1912}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"mc", !8, i64 0, !7, i64 6, !8, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !10, i64 212}
!17 = !{!"s_TxCB", !18, i64 0, !10, i64 8, !7, i64 12, !8, i64 14, !8, i64 15, !8, i64 16, !8, i64 80, !10, i64 208, !10, i64 212, !11, i64 216, !11, i64 224, !12, i64 232}
!18 = !{!"CB_Header", !7, i64 0, !7, i64 2, !10, i64 4}
!19 = !{!17, !11, i64 224}
!20 = !{!17, !7, i64 2}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass