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

; 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: 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
declare dso_local void @OutWord(ptr noundef, i16 noundef zeroext, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @StopRU(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @InitializeChip(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @E100bSetInterruptState(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @E100bSetfilter(ptr noundef, i16 noundef zeroext, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @XmitWaitForCompletion(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @CheckCBList(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @E100bReset(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i16, align 2
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.s_data_instance, ptr %7, i32 0, i32 14
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = add i32 %9, 2
  call void @OutWord(ptr noundef %6, i16 noundef zeroext 256, i32 noundef %10)
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call zeroext i16 @CheckCBList(ptr noundef %11)
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  call void @XmitWaitForCompletion(ptr noundef %13)
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.s_data_instance, ptr %14, i32 0, i32 53
  %16 = load i8, ptr %15, align 2, !tbaa !16
  %17 = icmp ne i8 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %2
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  call void @StopRU(ptr noundef %19)
  br label %20

20:                                               ; preds = %18, %2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call zeroext i16 @InitializeChip(ptr noundef %21)
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = and i32 %23, 2
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %40

26:                                               ; preds = %20
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.s_data_instance, ptr %27, i32 0, i32 54
  %29 = load i8, ptr %28, align 1, !tbaa !17
  %30 = zext i8 %29 to i16
  store i16 %30, ptr %5, align 2, !tbaa !18
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.s_data_instance, ptr %31, i32 0, i32 54
  %33 = load i8, ptr %32, align 1, !tbaa !17
  %34 = zext i8 %33 to i32
  %35 = and i32 %34, -5
  %36 = trunc i32 %35 to i8
  store i8 %36, ptr %32, align 1, !tbaa !17
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = load i16, ptr %5, align 2, !tbaa !18
  %39 = call i64 @E100bSetfilter(ptr noundef %37, i16 noundef zeroext %38, i64 noundef 0, i32 noundef 0)
  br label %40

40:                                               ; preds = %26, %20
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = and i32 %41, 1
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %47

44:                                               ; preds = %40
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.s_data_instance, ptr %45, i32 0, i32 28
  store i16 0, ptr %46, align 8, !tbaa !19
  br label %47

47:                                               ; preds = %44, %40
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = call zeroext i8 @E100bSetInterruptState(ptr noundef %48)
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #2
  ret i64 0
}

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 880}
!12 = !{!"s_data_instance", !13, i64 0, !13, i64 2, !7, i64 4, !7, i64 5, !13, i64 6, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !7, i64 16, !7, i64 48, !7, i64 80, !7, i64 112, !7, i64 368, !10, i64 880, !10, i64 884, !13, i64 888, !13, i64 890, !7, i64 892, !7, i64 893, !7, i64 894, !7, i64 895, !13, i64 896, !13, i64 898, !13, i64 900, !13, i64 902, !10, i64 904, !10, i64 908, !13, i64 912, !13, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !13, i64 922, !10, 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, !13, i64 1528, !13, i64 1530, !13, i64 1532, !13, 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 = !{!"short", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"mc", !7, i64 0, !13, i64 6, !7, i64 8}
!16 = !{!12, !7, i64 1538}
!17 = !{!12, !7, i64 1539}
!18 = !{!13, !13, i64 0}
!19 = !{!12, !13, i64 912}


; 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 void @OutWord(ptr noundef, i16 noundef zeroext, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @E100bSetInterruptState(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @E100bReset(ptr noundef %0, i32 noundef %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
  tail call void @OutWord(ptr noundef %0, i16 noundef zeroext 256, i32 noundef %5)
  %6 = tail call zeroext i16 @CheckCBList(ptr noundef %0)
  tail call void @XmitWaitForCompletion(ptr noundef %0)
  %7 = getelementptr inbounds i8, ptr %0, i64 1538
  %8 = load i8, ptr %7, align 2, !tbaa !14
  %.not = icmp eq i8 %8, 0
  br i1 %.not, label %10, label %9

9:                                                ; preds = %2
  tail call void @StopRU(ptr noundef nonnull %0)
  br label %10

10:                                               ; preds = %9, %2
  %11 = tail call zeroext i16 @InitializeChip(ptr noundef nonnull %0)
  %12 = and i32 %1, 2
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 1539
  %16 = load i8, ptr %15, align 1, !tbaa !15
  %17 = zext i8 %16 to i16
  %18 = and i8 %16, -5
  store i8 %18, ptr %15, align 1, !tbaa !15
  %19 = tail call i64 @E100bSetfilter(ptr noundef nonnull %0, i16 noundef zeroext %17, i64 noundef 0, i32 noundef 0)
  br label %20

20:                                               ; preds = %14, %10
  %21 = and i32 %1, 1
  %.not14 = icmp eq i32 %21, 0
  br i1 %.not14, label %24, label %22

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %0, i64 912
  store i16 0, ptr %23, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %22, %20
  %25 = tail call zeroext i8 @E100bSetInterruptState(ptr noundef nonnull %0)
  ret i64 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 = !{!6, !8, i64 1538}
!15 = !{!6, !8, i64 1539}
!16 = !{!6, !7, i64 912}


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