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

; 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_pxe_cdb = type { i16, i16, i16, i16, i64, i64, i16, i16, i16, i16 }
%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_pxe_cpb_initialize = type <{ i64, i32, i32, i16, i16, i16, i16, i8, i8 }>

; Function Attrs: nounwind uwtable
define dso_local void @UNDI_Initialize(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  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 8, ptr %5) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.s_pxe_cdb, ptr %7, i32 0, i32 1
  %9 = load i16, ptr %8, align 1, !tbaa !9
  %10 = zext i16 %9 to i32
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %23

12:                                               ; preds = %2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.s_pxe_cdb, ptr %13, i32 0, i32 1
  %15 = load i16, ptr %14, align 1, !tbaa !9
  %16 = zext i16 %15 to i32
  %17 = icmp ne i32 %16, 1
  br i1 %17, label %18, label %23

18:                                               ; preds = %12
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.s_pxe_cdb, ptr %19, i32 0, i32 7
  store i16 -32768, ptr %20, align 1, !tbaa !13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.s_pxe_cdb, ptr %21, i32 0, i32 6
  store i16 1, ptr %22, align 1, !tbaa !14
  store i32 1, ptr %6, align 4
  br label %102

23:                                               ; preds = %12, %2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.s_data_instance, ptr %24, i32 0, i32 0
  %26 = load i16, ptr %25, align 8, !tbaa !15
  %27 = zext i16 %26 to i32
  %28 = icmp eq i32 %27, 2
  br i1 %28, label %29, label %34

29:                                               ; preds = %23
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.s_pxe_cdb, ptr %30, i32 0, i32 7
  store i16 -32768, ptr %31, align 1, !tbaa !13
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.s_pxe_cdb, ptr %32, i32 0, i32 6
  store i16 8, ptr %33, align 1, !tbaa !14
  store i32 1, ptr %6, align 4
  br label %102

34:                                               ; preds = %23
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.s_pxe_cdb, ptr %35, i32 0, i32 4
  %37 = load i64, ptr %36, align 1, !tbaa !19
  %38 = inttoptr i64 %37 to ptr
  store ptr %38, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.s_pxe_cpb_initialize, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 1, !tbaa !20
  %42 = icmp ult i32 %41, 57540
  br i1 %42, label %43, label %48

43:                                               ; preds = %34
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.s_pxe_cdb, ptr %44, i32 0, i32 7
  store i16 -32768, ptr %45, align 1, !tbaa !13
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.s_pxe_cdb, ptr %46, i32 0, i32 6
  store i16 2, ptr %47, align 1, !tbaa !14
  store i32 1, ptr %6, align 4
  br label %102

48:                                               ; preds = %34
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.s_pxe_cdb, ptr %49, i32 0, i32 1
  %51 = load i16, ptr %50, align 1, !tbaa !9
  %52 = zext i16 %51 to i32
  %53 = icmp eq i32 %52, 1
  %54 = zext i1 %53 to i64
  %55 = select i1 %53, i32 0, i32 1
  %56 = trunc i32 %55 to i8
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.s_data_instance, ptr %57, i32 0, i32 20
  store i8 %56, ptr %58, align 2, !tbaa !22
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.s_pxe_cpb_initialize, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 1, !tbaa !23
  %62 = trunc i32 %61 to i16
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.s_data_instance, ptr %63, i32 0, i32 17
  store i16 %62, ptr %64, align 2, !tbaa !24
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.s_pxe_cpb_initialize, ptr %65, i32 0, i32 7
  %67 = load i8, ptr %66, align 1, !tbaa !25
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.s_data_instance, ptr %68, i32 0, i32 18
  store i8 %67, ptr %69, align 4, !tbaa !26
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.s_pxe_cpb_initialize, ptr %70, i32 0, i32 8
  %72 = load i8, ptr %71, align 1, !tbaa !27
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.s_data_instance, ptr %73, i32 0, i32 21
  store i8 %72, ptr %74, align 1, !tbaa !28
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.s_pxe_cpb_initialize, ptr %75, i32 0, i32 0
  %77 = load i64, ptr %76, align 1, !tbaa !29
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.s_data_instance, ptr %78, i32 0, i32 44
  store i64 %77, ptr %79, align 8, !tbaa !30
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.s_pxe_cpb_initialize, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 1, !tbaa !20
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.s_data_instance, ptr %83, i32 0, i32 34
  store i32 %82, ptr %84, align 4, !tbaa !31
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = call i64 @E100bInit(ptr noundef %85)
  %87 = trunc i64 %86 to i16
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.s_pxe_cdb, ptr %88, i32 0, i32 6
  store i16 %87, ptr %89, align 1, !tbaa !14
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.s_pxe_cdb, ptr %90, i32 0, i32 6
  %92 = load i16, ptr %91, align 1, !tbaa !14
  %93 = zext i16 %92 to i32
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %98

95:                                               ; preds = %48
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.s_pxe_cdb, ptr %96, i32 0, i32 7
  store i16 -32768, ptr %97, align 1, !tbaa !13
  br label %101

98:                                               ; preds = %48
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.s_data_instance, ptr %99, i32 0, i32 0
  store i16 2, ptr %100, align 8, !tbaa !15
  br label %101

101:                                              ; preds = %98, %95
  store i32 1, ptr %6, align 4
  br label %102

102:                                              ; preds = %101, %43, %29, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

; 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

declare i64 @E100bInit(ptr 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, !11, i64 2}
!10 = !{!"s_pxe_cdb", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !12, i64 8, !12, i64 16, !11, i64 24, !11, i64 26, !11, i64 28, !11, i64 30}
!11 = !{!"short", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!10, !11, i64 26}
!14 = !{!10, !11, i64 24}
!15 = !{!16, !11, i64 0}
!16 = !{!"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, !17, i64 880, !17, 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, !17, i64 904, !17, i64 908, !11, i64 912, !11, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !11, i64 922, !17, i64 924, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !12, i64 976, !12, i64 984, !12, i64 992, !12, i64 1000, !12, 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, !18, i64 1544, !12, i64 1808, !6, i64 1816, !12, 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}
!17 = !{!"int", !7, i64 0}
!18 = !{!"mc", !7, i64 0, !11, i64 6, !7, i64 8}
!19 = !{!10, !12, i64 8}
!20 = !{!21, !17, i64 8}
!21 = !{!"s_pxe_cpb_initialize", !12, i64 0, !17, i64 8, !17, i64 12, !11, i64 16, !11, i64 18, !11, i64 20, !11, i64 22, !7, i64 24, !7, i64 25}
!22 = !{!16, !7, i64 894}
!23 = !{!21, !17, i64 12}
!24 = !{!16, !11, i64 890}
!25 = !{!21, !7, i64 24}
!26 = !{!16, !7, i64 892}
!27 = !{!21, !7, i64 25}
!28 = !{!16, !7, i64 895}
!29 = !{!21, !12, i64 0}
!30 = !{!16, !12, i64 1000}
!31 = !{!16, !17, i64 924}


; 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
define dso_local void @UNDI_Initialize(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 2
  %4 = load i16, ptr %3, align 1, !tbaa !5
  %switch = icmp ult i16 %4, 2
  br i1 %switch, label %8, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 26
  store i16 -32768, ptr %6, align 1, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  store i16 1, ptr %7, align 1, !tbaa !12
  br label %48

8:                                                ; preds = %2
  %9 = load i16, ptr %1, align 8, !tbaa !13
  %10 = icmp eq i16 %9, 2
  br i1 %10, label %11, label %14

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 26
  store i16 -32768, ptr %12, align 1, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  store i16 8, ptr %13, align 1, !tbaa !12
  br label %48

14:                                               ; preds = %8
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load i64, ptr %15, align 1, !tbaa !18
  %17 = inttoptr i64 %16 to ptr
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load i32, ptr %18, align 1, !tbaa !19
  %20 = icmp ult i32 %19, 57540
  br i1 %20, label %21, label %24

21:                                               ; preds = %14
  %22 = getelementptr inbounds i8, ptr %0, i64 26
  store i16 -32768, ptr %22, align 1, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  store i16 2, ptr %23, align 1, !tbaa !12
  br label %48

24:                                               ; preds = %14
  %25 = icmp ne i16 %4, 1
  %26 = zext i1 %25 to i8
  %27 = getelementptr inbounds i8, ptr %1, i64 894
  store i8 %26, ptr %27, align 2, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %17, i64 12
  %29 = load i32, ptr %28, align 1, !tbaa !22
  %30 = trunc i32 %29 to i16
  %31 = getelementptr inbounds i8, ptr %1, i64 890
  store i16 %30, ptr %31, align 2, !tbaa !23
  %32 = getelementptr inbounds i8, ptr %17, i64 24
  %33 = load i8, ptr %32, align 1, !tbaa !24
  %34 = getelementptr inbounds i8, ptr %1, i64 892
  store i8 %33, ptr %34, align 4, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %17, i64 25
  %36 = load i8, ptr %35, align 1, !tbaa !26
  %37 = getelementptr inbounds i8, ptr %1, i64 895
  store i8 %36, ptr %37, align 1, !tbaa !27
  %38 = load i64, ptr %17, align 1, !tbaa !28
  %39 = getelementptr inbounds i8, ptr %1, i64 1000
  store i64 %38, ptr %39, align 8, !tbaa !29
  %40 = getelementptr inbounds i8, ptr %1, i64 924
  store i32 %19, ptr %40, align 4, !tbaa !30
  %41 = tail call i64 @E100bInit(ptr noundef nonnull %1) #2
  %42 = trunc i64 %41 to i16
  %43 = getelementptr inbounds i8, ptr %0, i64 24
  store i16 %42, ptr %43, align 1, !tbaa !12
  %44 = and i64 %41, 65535
  %.not29 = icmp eq i64 %44, 0
  br i1 %.not29, label %47, label %45

45:                                               ; preds = %24
  %46 = getelementptr inbounds i8, ptr %0, i64 26
  store i16 -32768, ptr %46, align 1, !tbaa !11
  br label %48

47:                                               ; preds = %24
  store i16 2, ptr %1, align 8, !tbaa !13
  br label %48

48:                                               ; preds = %45, %47, %21, %11, %5
  ret void
}

declare i64 @E100bInit(ptr 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 2}
!6 = !{!"s_pxe_cdb", !7, i64 0, !7, i64 2, !7, i64 4, !7, i64 6, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 26, !7, i64 28, !7, i64 30}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!6, !7, i64 26}
!12 = !{!6, !7, i64 24}
!13 = !{!14, !7, i64 0}
!14 = !{!"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, !15, i64 880, !15, 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, !15, i64 904, !15, i64 908, !7, i64 912, !7, i64 914, !8, i64 916, !8, i64 920, !8, i64 921, !7, i64 922, !15, i64 924, !16, i64 928, !16, i64 936, !16, i64 944, !16, i64 952, !16, i64 960, !16, i64 968, !10, i64 976, !10, i64 984, !10, i64 992, !10, i64 1000, !10, 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, !17, i64 1544, !10, i64 1808, !16, i64 1816, !10, i64 1824, !16, i64 1832, !16, i64 1840, !16, i64 1848, !16, i64 1856, !16, i64 1864, !16, i64 1872, !16, i64 1880, !16, i64 1888, !16, i64 1896, !16, i64 1904, !16, i64 1912}
!15 = !{!"int", !8, i64 0}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"mc", !8, i64 0, !7, i64 6, !8, i64 8}
!18 = !{!6, !10, i64 8}
!19 = !{!20, !15, i64 8}
!20 = !{!"s_pxe_cpb_initialize", !10, i64 0, !15, i64 8, !15, i64 12, !7, i64 16, !7, i64 18, !7, i64 20, !7, i64 22, !8, i64 24, !8, i64 25}
!21 = !{!14, !8, i64 894}
!22 = !{!20, !15, i64 12}
!23 = !{!14, !7, i64 890}
!24 = !{!20, !8, i64 24}
!25 = !{!14, !8, i64 892}
!26 = !{!20, !8, i64 25}
!27 = !{!14, !8, i64 895}
!28 = !{!20, !10, i64 0}
!29 = !{!14, !10, i64 1000}
!30 = !{!14, !15, i64 924}


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