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

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

; Function Attrs: nounwind uwtable
define dso_local void @UNDI_Receive(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.s_data_instance, ptr %5, i32 0, i32 53
  %7 = load i8, ptr %6, align 2, !tbaa !9
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %14, label %9

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.s_pxe_cdb, ptr %10, i32 0, i32 7
  store i16 -32768, ptr %11, align 1, !tbaa !15
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.s_pxe_cdb, ptr %12, i32 0, i32 6
  store i16 9, ptr %13, align 1, !tbaa !17
  br label %35

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.s_pxe_cdb, ptr %16, i32 0, i32 4
  %18 = load i64, ptr %17, align 1, !tbaa !18
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.s_pxe_cdb, ptr %19, i32 0, i32 5
  %21 = load i64, ptr %20, align 1, !tbaa !19
  %22 = call i64 @E100bReceive(ptr noundef %15, i64 noundef %18, i64 noundef %21)
  %23 = trunc i64 %22 to i16
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.s_pxe_cdb, ptr %24, i32 0, i32 6
  store i16 %23, ptr %25, align 1, !tbaa !17
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.s_pxe_cdb, ptr %26, i32 0, i32 6
  %28 = load i16, ptr %27, align 1, !tbaa !17
  %29 = zext i16 %28 to i32
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %14
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.s_pxe_cdb, ptr %32, i32 0, i32 7
  store i16 -32768, ptr %33, align 1, !tbaa !15
  br label %34

34:                                               ; preds = %31, %14
  br label %35

35:                                               ; preds = %34, %9
  ret void
}

declare i64 @E100bReceive(ptr noundef, i64 noundef, i64 noundef) #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" }

!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 = !{!16, !11, i64 26}
!16 = !{!"s_pxe_cdb", !11, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !13, i64 8, !13, i64 16, !11, i64 24, !11, i64 26, !11, i64 28, !11, i64 30}
!17 = !{!16, !11, i64 24}
!18 = !{!16, !13, i64 8}
!19 = !{!16, !13, 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"

; Function Attrs: nounwind uwtable
define dso_local void @UNDI_Receive(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 1538
  %4 = load i8, ptr %3, align 2, !tbaa !5
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %5, label %7

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 26
  store i16 -32768, ptr %6, align 1, !tbaa !14
  br label %.sink.split

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i64, ptr %8, align 1, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load i64, ptr %10, align 1, !tbaa !17
  %12 = tail call i64 @E100bReceive(ptr noundef nonnull %1, i64 noundef %9, i64 noundef %11) #2
  %13 = trunc i64 %12 to i16
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  store i16 %13, ptr %14, align 1, !tbaa !18
  %15 = and i64 %12, 65535
  %.not9 = icmp eq i64 %15, 0
  br i1 %.not9, label %17, label %.sink.split

.sink.split:                                      ; preds = %7, %5
  %.sink11 = phi i64 [ 24, %5 ], [ 26, %7 ]
  %.sink = phi i16 [ 9, %5 ], [ -32768, %7 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 %.sink11
  store i16 %.sink, ptr %16, align 1, !tbaa !19
  br label %17

17:                                               ; preds = %.sink.split, %7
  ret void
}

declare i64 @E100bReceive(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, !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 = !{!15, !7, i64 26}
!15 = !{!"s_pxe_cdb", !7, i64 0, !7, i64 2, !7, i64 4, !7, i64 6, !12, i64 8, !12, i64 16, !7, i64 24, !7, i64 26, !7, i64 28, !7, i64 30}
!16 = !{!15, !12, i64 8}
!17 = !{!15, !12, i64 16}
!18 = !{!15, !7, i64 24}
!19 = !{!7, !7, i64 0}


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