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

; 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._IP4_CONFIG_INSTANCE = type { i32, ptr, ptr, ptr, %struct._EFI_IP4_CONFIG_PROTOCOL, %struct._EFI_HII_CONFIG_ACCESS_PROTOCOL, ptr, ptr, ptr, %struct._IP4CONFIG_CALLBACK_INFO, i64, ptr, ptr, ptr, ptr, i64, %struct.NIC_ADDR, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8 }
%struct._EFI_IP4_CONFIG_PROTOCOL = type { ptr, ptr, ptr }
%struct._EFI_HII_CONFIG_ACCESS_PROTOCOL = type { ptr, ptr, ptr }
%struct._IP4CONFIG_CALLBACK_INFO = type { i8, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.NIC_ADDR = type { i16, i8, %struct.EFI_MAC_ADDRESS }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

declare void @FreePool(ptr noundef) #0

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

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

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._IP4_CONFIG_INSTANCE, ptr %8, i32 0, i32 18
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  call void @FreePool(ptr noundef %10)
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._IP4_CONFIG_INSTANCE, ptr %11, i32 0, i32 18
  store ptr null, ptr %12, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %7, %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._IP4_CONFIG_INSTANCE, ptr %14, i32 0, i32 10
  store i64 0, ptr %15, align 8, !tbaa !19
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._IP4_CONFIG_INSTANCE, ptr %16, i32 0, i32 13
  store ptr null, ptr %17, align 8, !tbaa !20
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._IP4_CONFIG_INSTANCE, ptr %18, i32 0, i32 14
  store ptr null, ptr %19, align 8, !tbaa !21
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  call void @Ip4ConfigCleanDhcp4(ptr noundef %20)
  ret void
}

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, !6, i64 216}
!10 = !{!"_IP4_CONFIG_INSTANCE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !13, i64 56, !6, i64 80, !6, i64 88, !6, i64 96, !14, i64 104, !16, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !16, i64 160, !17, i64 168, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !7, i64 256, !7, i64 257}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_IP4_CONFIG_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!"_EFI_HII_CONFIG_ACCESS_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!"_IP4CONFIG_CALLBACK_INFO", !7, i64 0, !7, i64 1, !15, i64 2, !15, i64 6, !15, i64 10}
!15 = !{!"", !7, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"", !18, i64 0, !7, i64 2, !15, i64 3}
!18 = !{!"short", !7, i64 0}
!19 = !{!10, !16, i64 120}
!20 = !{!10, !6, i64 144}
!21 = !{!10, !6, i64 152}


; 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"

declare void @FreePool(ptr noundef) local_unnamed_addr #0

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

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

4:                                                ; preds = %1
  tail call void @FreePool(ptr noundef nonnull %3) #3
  store ptr null, ptr %2, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %4, %1
  %6 = getelementptr inbounds i8, ptr %0, i64 120
  store i64 0, ptr %6, align 8, !tbaa !18
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  tail call void @Ip4ConfigCleanDhcp4(ptr noundef nonnull %0)
  ret void
}

; 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, !10, i64 216}
!6 = !{!"_IP4_CONFIG_INSTANCE", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !12, i64 56, !10, i64 80, !10, i64 88, !10, i64 96, !13, i64 104, !15, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !15, i64 160, !16, i64 168, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !8, i64 256, !8, i64 257}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_EFI_IP4_CONFIG_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16}
!12 = !{!"_EFI_HII_CONFIG_ACCESS_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!"_IP4CONFIG_CALLBACK_INFO", !8, i64 0, !8, i64 1, !14, i64 2, !14, i64 6, !14, i64 10}
!14 = !{!"", !8, i64 0}
!15 = !{!"long long", !8, i64 0}
!16 = !{!"", !17, i64 0, !8, i64 2, !14, i64 3}
!17 = !{!"short", !8, i64 0}
!18 = !{!6, !15, i64 120}


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