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

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

; 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 void @OutByte(ptr noundef, i8 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 signext i8 @StartRU(ptr noundef %0) #0 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.s_data_instance, ptr %6, i32 0, i32 53
  %8 = load i8, ptr %7, align 2, !tbaa !9
  %9 = icmp ne i8 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store i8 -1, ptr %2, align 1
  br label %82

11:                                               ; preds = %1
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.s_data_instance, ptr %12, i32 0, i32 49
  store i16 0, ptr %13, align 4, !tbaa !15
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.s_data_instance, ptr %14, i32 0, i32 29
  store i16 0, ptr %15, align 2, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #2
  store i16 2000, ptr %4, align 2, !tbaa !17
  br label %16

16:                                               ; preds = %32, %11
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_data_instance, ptr %18, i32 0, i32 14
  %20 = load i32, ptr %19, align 8, !tbaa !18
  %21 = add i32 %20, 2
  %22 = call zeroext i8 @InByte(ptr noundef %17, i32 noundef %21)
  %23 = zext i8 %22 to i32
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %16
  %26 = load i16, ptr %4, align 2, !tbaa !17
  %27 = add i16 %26, -1
  store i16 %27, ptr %4, align 2, !tbaa !17
  %28 = sext i16 %27 to i32
  %29 = icmp sge i32 %28, 0
  br label %30

30:                                               ; preds = %25, %16
  %31 = phi i1 [ false, %16 ], [ %29, %25 ]
  br i1 %31, label %32, label %34

32:                                               ; preds = %30
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  call void @DelayIt(ptr noundef %33, i16 noundef zeroext 10)
  br label %16, !llvm.loop !19

34:                                               ; preds = %30
  %35 = load i16, ptr %4, align 2, !tbaa !17
  %36 = sext i16 %35 to i32
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  call void @DelayIt(ptr noundef %39, i16 noundef zeroext 50)
  br label %40

40:                                               ; preds = %38, %34
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #2
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.s_data_instance, ptr %42, i32 0, i32 41
  %44 = load i64, ptr %43, align 8, !tbaa !21
  %45 = trunc i64 %44 to i32
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.s_data_instance, ptr %46, i32 0, i32 14
  %48 = load i32, ptr %47, align 8, !tbaa !18
  %49 = add i32 %48, 4
  call void @OutLong(ptr noundef %41, i32 noundef %45, i32 noundef %49)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.s_data_instance, ptr %51, i32 0, i32 14
  %53 = load i32, ptr %52, align 8, !tbaa !18
  %54 = add i32 %53, 2
  call void @OutByte(ptr noundef %50, i8 noundef zeroext 1, i32 noundef %54)
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #2
  store i16 2000, ptr %5, align 2, !tbaa !17
  br label %55

55:                                               ; preds = %71, %40
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.s_data_instance, ptr %57, i32 0, i32 14
  %59 = load i32, ptr %58, align 8, !tbaa !18
  %60 = add i32 %59, 2
  %61 = call zeroext i8 @InByte(ptr noundef %56, i32 noundef %60)
  %62 = zext i8 %61 to i32
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %55
  %65 = load i16, ptr %5, align 2, !tbaa !17
  %66 = add i16 %65, -1
  store i16 %66, ptr %5, align 2, !tbaa !17
  %67 = sext i16 %66 to i32
  %68 = icmp sge i32 %67, 0
  br label %69

69:                                               ; preds = %64, %55
  %70 = phi i1 [ false, %55 ], [ %68, %64 ]
  br i1 %70, label %71, label %73

71:                                               ; preds = %69
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  call void @DelayIt(ptr noundef %72, i16 noundef zeroext 10)
  br label %55, !llvm.loop !22

73:                                               ; preds = %69
  %74 = load i16, ptr %5, align 2, !tbaa !17
  %75 = sext i16 %74 to i32
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %79

77:                                               ; preds = %73
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  call void @DelayIt(ptr noundef %78, i16 noundef zeroext 50)
  br label %79

79:                                               ; preds = %77, %73
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #2
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.s_data_instance, ptr %80, i32 0, i32 53
  store i8 1, ptr %81, align 2, !tbaa !9
  store i8 0, ptr %2, align 1
  br label %82

82:                                               ; preds = %79, %10
  %83 = load i8, ptr %2, align 1
  ret i8 %83
}

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, !7, i64 1538}
!10 = !{!"s_data_instance", !11, i64 0, !11, i64 2, !7, i64 4, !7, i64 5, !11, i64 6, !11, i64 8, !11, i64 10, !11, i64 12, !11, i64 14, !7, i64 16, !7, i64 48, !7, i64 80, !7, i64 112, !7, i64 368, !12, i64 880, !12, i64 884, !11, i64 888, !11, i64 890, !7, i64 892, !7, i64 893, !7, i64 894, !7, i64 895, !11, i64 896, !11, i64 898, !11, i64 900, !11, i64 902, !12, i64 904, !12, i64 908, !11, i64 912, !11, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !11, i64 922, !12, i64 924, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !13, i64 976, !13, i64 984, !13, i64 992, !13, i64 1000, !13, i64 1008, !7, i64 1016, !11, i64 1528, !11, i64 1530, !11, i64 1532, !11, i64 1534, !7, i64 1536, !7, i64 1537, !7, i64 1538, !7, i64 1539, !7, i64 1540, !7, i64 1541, !14, i64 1544, !13, i64 1808, !6, i64 1816, !13, 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}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"mc", !7, i64 0, !11, i64 6, !7, i64 8}
!15 = !{!10, !11, i64 1532}
!16 = !{!10, !11, i64 914}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !12, i64 880}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !13, i64 976}
!22 = distinct !{!22, !20}


; 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 void @OutByte(ptr noundef, i8 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 signext range(i8 -1, 1) i8 @StartRU(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 1538
  %3 = load i8, ptr %2, align 2, !tbaa !5
  %.not = icmp eq i8 %3, 0
  br i1 %.not, label %4, label %37

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 1532
  store i16 0, ptr %5, align 4, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %0, i64 914
  store i16 0, ptr %6, align 2, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %0, i64 880
  %8 = load i32, ptr %7, align 8, !tbaa !16
  %9 = add i32 %8, 2
  %10 = tail call zeroext i8 @InByte(ptr noundef nonnull %0, i32 noundef %9)
  %.not2633 = icmp eq i8 %10, 0
  br i1 %.not2633, label %.critedge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %4, %12
  %.02334 = phi i16 [ %13, %12 ], [ 2000, %4 ]
  %11 = icmp sgt i16 %.02334, 0
  br i1 %11, label %12, label %.critedge.thread

12:                                               ; preds = %.lr.ph
  %13 = add nsw i16 %.02334, -1
  tail call void @DelayIt(ptr noundef nonnull %0, i16 noundef zeroext 10)
  %14 = load i32, ptr %7, align 8, !tbaa !16
  %15 = add i32 %14, 2
  %16 = tail call zeroext i8 @InByte(ptr noundef nonnull %0, i32 noundef %15)
  %.not26 = icmp eq i8 %16, 0
  br i1 %.not26, label %.critedge, label %.lr.ph, !llvm.loop !17

.critedge:                                        ; preds = %12
  %17 = icmp eq i16 %13, 0
  br i1 %17, label %18, label %.critedge.thread

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

.critedge.thread:                                 ; preds = %.lr.ph, %4, %18, %.critedge
  %19 = getelementptr inbounds i8, ptr %0, i64 976
  %20 = load i64, ptr %19, align 8, !tbaa !19
  %21 = trunc i64 %20 to i32
  %22 = load i32, ptr %7, align 8, !tbaa !16
  %23 = add i32 %22, 4
  tail call void @OutLong(ptr noundef nonnull %0, i32 noundef %21, i32 noundef %23)
  %24 = load i32, ptr %7, align 8, !tbaa !16
  %25 = add i32 %24, 2
  tail call void @OutByte(ptr noundef nonnull %0, i8 noundef zeroext 1, i32 noundef %25)
  %26 = load i32, ptr %7, align 8, !tbaa !16
  %27 = add i32 %26, 2
  %28 = tail call zeroext i8 @InByte(ptr noundef nonnull %0, i32 noundef %27)
  %.not2735 = icmp eq i8 %28, 0
  br i1 %.not2735, label %.critedge2.thread, label %.lr.ph37

.lr.ph37:                                         ; preds = %.critedge.thread, %30
  %.036 = phi i16 [ %31, %30 ], [ 2000, %.critedge.thread ]
  %29 = icmp sgt i16 %.036, 0
  br i1 %29, label %30, label %.critedge2.thread

30:                                               ; preds = %.lr.ph37
  %31 = add nsw i16 %.036, -1
  tail call void @DelayIt(ptr noundef nonnull %0, i16 noundef zeroext 10)
  %32 = load i32, ptr %7, align 8, !tbaa !16
  %33 = add i32 %32, 2
  %34 = tail call zeroext i8 @InByte(ptr noundef nonnull %0, i32 noundef %33)
  %.not27 = icmp eq i8 %34, 0
  br i1 %.not27, label %.critedge2, label %.lr.ph37, !llvm.loop !20

.critedge2:                                       ; preds = %30
  %35 = icmp eq i16 %31, 0
  br i1 %35, label %36, label %.critedge2.thread

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

.critedge2.thread:                                ; preds = %.lr.ph37, %.critedge.thread, %36, %.critedge2
  store i8 1, ptr %2, align 2, !tbaa !5
  br label %37

37:                                               ; preds = %1, %.critedge2.thread
  %.025 = phi i8 [ 0, %.critedge2.thread ], [ -1, %1 ]
  ret i8 %.025
}

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, !8, i64 1538}
!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 = !{!6, !7, i64 1532}
!15 = !{!6, !7, i64 914}
!16 = !{!6, !10, i64 880}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !12, i64 976}
!20 = distinct !{!20, !18}


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