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

; 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.CIRRUS_LOGIC_5430_PRIVATE_DATA = type { i64, ptr, ptr, i64, %struct._EFI_UGA_DRAW_PROTOCOL, %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, %struct.EFI_EDID_DISCOVERED_PROTOCOL, %struct.EFI_EDID_ACTIVE_PROTOCOL, ptr, ptr, i64, i64, [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr, i8 }
%struct._EFI_UGA_DRAW_PROTOCOL = type { ptr, ptr, ptr }
%struct._EFI_GRAPHICS_OUTPUT_PROTOCOL = type { ptr, ptr, ptr, ptr }
%struct.EFI_EDID_DISCOVERED_PROTOCOL = type { i32, ptr }
%struct.EFI_EDID_ACTIVE_PROTOCOL = type { i32, ptr }
%struct.CIRRUS_LOGIC_5430_MODE_DATA = type { i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i64 @CirrusLogic5430UgaDrawGetMode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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 i64 @CirrusLogic5430UgaDrawSetMode(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i64 @CirrusLogic5430UgaDrawConstructor(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %4, i32 0, i32 4
  store ptr %5, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct._EFI_UGA_DRAW_PROTOCOL, ptr %6, i32 0, i32 0
  store ptr @CirrusLogic5430UgaDrawGetMode, ptr %7, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._EFI_UGA_DRAW_PROTOCOL, ptr %8, i32 0, i32 1
  store ptr @CirrusLogic5430UgaDrawSetMode, ptr %9, align 8, !tbaa !11
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._EFI_UGA_DRAW_PROTOCOL, ptr %10, i32 0, i32 2
  store ptr @CirrusLogic5430UgaDrawBlt, ptr %11, align 8, !tbaa !12
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %12, i32 0, i32 10
  store i64 0, ptr %13, align 8, !tbaa !13
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %14, i32 0, i32 14
  store i8 1, ptr %15, align 8, !tbaa !19
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %16, i32 0, i32 13
  store ptr null, ptr %17, align 8, !tbaa !20
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._EFI_UGA_DRAW_PROTOCOL, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %22, i32 0, i32 12
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %24, i32 0, i32 10
  %26 = load i64, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr %23, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_MODE_DATA, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !21
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %30, i32 0, i32 12
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %32, i32 0, i32 10
  %34 = load i64, ptr %33, align 8, !tbaa !13
  %35 = getelementptr inbounds [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr %31, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_MODE_DATA, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !23
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %38, i32 0, i32 12
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %40, i32 0, i32 10
  %42 = load i64, ptr %41, align 8, !tbaa !13
  %43 = getelementptr inbounds [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr %39, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_MODE_DATA, ptr %43, i32 0, i32 3
  %45 = load i32, ptr %44, align 4, !tbaa !24
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %46, i32 0, i32 12
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %48, i32 0, i32 10
  %50 = load i64, ptr %49, align 8, !tbaa !13
  %51 = getelementptr inbounds [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr %47, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_MODE_DATA, ptr %51, i32 0, i32 4
  %53 = load i32, ptr %52, align 4, !tbaa !25
  %54 = call i64 %20(ptr noundef %21, i32 noundef %29, i32 noundef %37, i32 noundef %45, i32 noundef %53)
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %56, i32 0, i32 12
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %58, i32 0, i32 10
  %60 = load i64, ptr %59, align 8, !tbaa !13
  %61 = getelementptr inbounds [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr %57, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_MODE_DATA, ptr %61, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !21
  %64 = zext i32 %63 to i64
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %65, i32 0, i32 12
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_PRIVATE_DATA, ptr %67, i32 0, i32 10
  %69 = load i64, ptr %68, align 8, !tbaa !13
  %70 = getelementptr inbounds [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr %66, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.CIRRUS_LOGIC_5430_MODE_DATA, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 4, !tbaa !23
  %73 = zext i32 %72 to i64
  call void @DrawLogo(ptr noundef %55, i64 noundef %64, i64 noundef %73)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i64 0
}

declare void @DrawLogo(ptr noundef, i64 noundef, i64 noundef) #2

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 = { "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 0}
!10 = !{!"_EFI_UGA_DRAW_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}
!13 = !{!14, !15, i64 136}
!14 = !{!"", !15, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !10, i64 32, !16, i64 56, !17, i64 88, !17, i64 104, !6, i64 120, !6, i64 128, !15, i64 136, !15, i64 144, !7, i64 152, !6, i64 216, !7, i64 224}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"_EFI_GRAPHICS_OUTPUT_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"", !18, i64 0, !6, i64 8}
!18 = !{!"int", !7, i64 0}
!19 = !{!14, !7, i64 224}
!20 = !{!14, !6, i64 216}
!21 = !{!22, !18, i64 4}
!22 = !{!"", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16}
!23 = !{!22, !18, i64 8}
!24 = !{!22, !18, i64 12}
!25 = !{!22, !18, i64 16}


; 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.CIRRUS_LOGIC_5430_MODE_DATA = type { i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i64 @CirrusLogic5430UgaDrawGetMode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @CirrusLogic5430UgaDrawConstructor(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr @CirrusLogic5430UgaDrawGetMode, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr @CirrusLogic5430UgaDrawSetMode, ptr %3, align 8, !tbaa !10
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr @CirrusLogic5430UgaDrawBlt, ptr %4, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  store i64 0, ptr %5, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 224
  store i8 1, ptr %6, align 8, !tbaa !18
  %7 = getelementptr inbounds i8, ptr %0, i64 216
  store ptr null, ptr %7, align 8, !tbaa !19
  %8 = getelementptr inbounds i8, ptr %0, i64 152
  %9 = getelementptr inbounds i8, ptr %0, i64 156
  %10 = load i32, ptr %9, align 4, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 160
  %12 = load i32, ptr %11, align 4, !tbaa !22
  %13 = getelementptr inbounds i8, ptr %0, i64 164
  %14 = load i32, ptr %13, align 4, !tbaa !23
  %15 = getelementptr inbounds i8, ptr %0, i64 168
  %16 = load i32, ptr %15, align 4, !tbaa !24
  %17 = tail call i64 @CirrusLogic5430UgaDrawSetMode(ptr noundef nonnull %2, i32 noundef %10, i32 noundef %12, i32 noundef %14, i32 noundef %16) #2
  %18 = load i64, ptr %5, align 8, !tbaa !12
  %19 = getelementptr inbounds [3 x %struct.CIRRUS_LOGIC_5430_MODE_DATA], ptr %8, i64 0, i64 %18
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !20
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %19, i64 8
  %24 = load i32, ptr %23, align 4, !tbaa !22
  %25 = zext i32 %24 to i64
  tail call void @DrawLogo(ptr noundef %0, i64 noundef %22, i64 noundef %25) #2
  ret i64 0
}

declare void @DrawLogo(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

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 = { "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, !7, i64 0}
!6 = !{!"_EFI_UGA_DRAW_PROTOCOL", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !14, i64 136}
!13 = !{!"", !14, i64 0, !7, i64 8, !7, i64 16, !14, i64 24, !6, i64 32, !15, i64 56, !16, i64 88, !16, i64 104, !7, i64 120, !7, i64 128, !14, i64 136, !14, i64 144, !8, i64 152, !7, i64 216, !8, i64 224}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"_EFI_GRAPHICS_OUTPUT_PROTOCOL", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!16 = !{!"", !17, i64 0, !7, i64 8}
!17 = !{!"int", !8, i64 0}
!18 = !{!13, !8, i64 224}
!19 = !{!13, !7, i64 216}
!20 = !{!21, !17, i64 4}
!21 = !{!"", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16}
!22 = !{!21, !17, i64 8}
!23 = !{!21, !17, i64 12}
!24 = !{!21, !17, i64 16}


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