; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (DhcpInitProtocol)

; 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._EFI_DHCP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._DHCP_PROTOCOL = type { i32, %struct._EFI_DHCP4_PROTOCOL, %struct._LIST_ENTRY, ptr, ptr, i8, ptr, ptr, ptr, ptr, i32, i16, %struct.NET_BUF_QUEUE }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }

@mDhcp4ProtocolTemplate = external global %struct._EFI_DHCP4_PROTOCOL, align 8

declare ptr @InitializeListHead(ptr noundef) #0

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @DhcpInitProtocol(ptr noundef %0, ptr noundef %1) #1 {
  %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._DHCP_PROTOCOL, ptr %5, i32 0, i32 0
  store i32 1885562980, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %7, i32 0, i32 1
  %9 = call ptr @CopyMem(ptr noundef %8, ptr noundef @mDhcp4ProtocolTemplate, i64 noundef 72)
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %10, i32 0, i32 2
  %12 = call ptr @InitializeListHead(ptr noundef %11)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %13, i32 0, i32 3
  store ptr null, ptr %14, align 8, !tbaa !17
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %16, i32 0, i32 4
  store ptr %15, ptr %17, align 8, !tbaa !18
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %18, i32 0, i32 5
  store i8 0, ptr %19, align 8, !tbaa !19
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %20, i32 0, i32 6
  store ptr null, ptr %21, align 8, !tbaa !20
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %22, i32 0, i32 7
  store ptr null, ptr %23, align 8, !tbaa !21
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %24, i32 0, i32 8
  store ptr null, ptr %25, align 8, !tbaa !22
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %26, i32 0, i32 9
  store ptr null, ptr %27, align 8, !tbaa !23
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %28, i32 0, i32 11
  store i16 0, ptr %29, align 4, !tbaa !24
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %30, i32 0, i32 12
  call void @NetbufQueInit(ptr noundef %31)
  ret void
}

declare void @NetbufQueInit(ptr noundef) #0

attributes #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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_DHCP_PROTOCOL", !11, i64 0, !12, i64 8, !13, i64 80, !6, i64 96, !6, i64 104, !7, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !11, i64 152, !14, i64 156, !15, i64 160}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_DHCP4_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !11, i64 0, !16, i64 8, !13, i64 16, !13, i64 32, !11, i64 48, !11, i64 52}
!16 = !{!"long long", !7, i64 0}
!17 = !{!10, !6, i64 96}
!18 = !{!10, !6, i64 104}
!19 = !{!10, !7, i64 112}
!20 = !{!10, !6, i64 120}
!21 = !{!10, !6, i64 128}
!22 = !{!10, !6, i64 136}
!23 = !{!10, !6, i64 144}
!24 = !{!10, !14, i64 156}


; 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._EFI_DHCP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@mDhcp4ProtocolTemplate = external global %struct._EFI_DHCP4_PROTOCOL, align 8

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #0

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @DhcpInitProtocol(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  store i32 1885562980, ptr %1, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = tail call ptr @CopyMem(ptr noundef nonnull %3, ptr noundef nonnull @mDhcp4ProtocolTemplate, i64 noundef 72) #3
  %5 = getelementptr inbounds i8, ptr %1, i64 80
  %6 = tail call ptr @InitializeListHead(ptr noundef nonnull %5) #3
  %7 = getelementptr inbounds i8, ptr %1, i64 96
  store ptr null, ptr %7, align 8, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %1, i64 104
  store ptr %0, ptr %8, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %1, i64 112
  store i8 0, ptr %9, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %1, i64 120
  %11 = getelementptr inbounds i8, ptr %1, i64 156
  store i16 0, ptr %11, align 4, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %1, i64 160
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %10, i8 0, i64 32, i1 false)
  tail call void @NetbufQueInit(ptr noundef nonnull %12) #3
  ret void
}

declare void @NetbufQueInit(ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_DHCP_PROTOCOL", !7, i64 0, !10, i64 8, !12, i64 80, !11, i64 96, !11, i64 104, !8, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !7, i64 152, !13, i64 156, !14, i64 160}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_DHCP4_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!13 = !{!"short", !8, i64 0}
!14 = !{!"", !7, i64 0, !15, i64 8, !12, i64 16, !12, i64 32, !7, i64 48, !7, i64 52}
!15 = !{!"long long", !8, i64 0}
!16 = !{!6, !11, i64 96}
!17 = !{!6, !11, i64 104}
!18 = !{!6, !8, i64 112}
!19 = !{!6, !13, i64 156}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass