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

; 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._DHCP_SERVICE = type { i32, %struct._EFI_SERVICE_BINDING_PROTOCOL, i64, ptr, ptr, %struct._LIST_ENTRY, i64, i64, i64, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i64, ptr, ptr, ptr, %struct.EFI_MAC_ADDRESS, i8, i8, [16 x i8], ptr, %struct.EFI_DHCP4_CONFIG_DATA, i32, ptr, i32, i32, i64, i64, i32 }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }
%struct.EFI_DHCP4_CONFIG_DATA = type { i32, ptr, i32, ptr, %struct.EFI_IPv4_ADDRESS, ptr, ptr, i32, ptr }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }

declare i64 @UdpIoFreeIo(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @DhcpCleanLease(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._DHCP_SERVICE, ptr %3, i32 0, i32 7
  store i64 1, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %5, i32 0, i32 9
  %7 = load i32, ptr %6, align 8, !tbaa !17
  %8 = add i32 %7, 1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %9, i32 0, i32 9
  store i32 %8, ptr %10, align 8, !tbaa !17
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %11, i32 0, i32 10
  store i32 0, ptr %12, align 4, !tbaa !18
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %13, i32 0, i32 11
  store i32 0, ptr %14, align 8, !tbaa !19
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %15, i32 0, i32 12
  store i32 0, ptr %16, align 4, !tbaa !20
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %17, i32 0, i32 13
  %19 = load ptr, ptr %18, align 8, !tbaa !21
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %27

21:                                               ; preds = %1
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %22, i32 0, i32 13
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  call void @FreePool(ptr noundef %24)
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %25, i32 0, i32 13
  store ptr null, ptr %26, align 8, !tbaa !21
  br label %27

27:                                               ; preds = %21, %1
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %28, i32 0, i32 14
  %30 = load ptr, ptr %29, align 8, !tbaa !22
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %38

32:                                               ; preds = %27
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %33, i32 0, i32 14
  %35 = load ptr, ptr %34, align 8, !tbaa !22
  call void @FreePool(ptr noundef %35)
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %36, i32 0, i32 14
  store ptr null, ptr %37, align 8, !tbaa !22
  br label %38

38:                                               ; preds = %32, %27
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %39, i32 0, i32 15
  %41 = load ptr, ptr %40, align 8, !tbaa !23
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %49

43:                                               ; preds = %38
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %44, i32 0, i32 15
  %46 = load ptr, ptr %45, align 8, !tbaa !23
  call void @FreePool(ptr noundef %46)
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %47, i32 0, i32 15
  store ptr null, ptr %48, align 8, !tbaa !23
  br label %49

49:                                               ; preds = %43, %38
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %50, i32 0, i32 16
  store i32 0, ptr %51, align 8, !tbaa !24
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %52, i32 0, i32 17
  store i32 0, ptr %53, align 4, !tbaa !25
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %54, i32 0, i32 18
  store i32 0, ptr %55, align 8, !tbaa !26
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %56, i32 0, i32 19
  store i64 0, ptr %57, align 8, !tbaa !27
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %58, i32 0, i32 21
  %60 = load ptr, ptr %59, align 8, !tbaa !28
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %69

62:                                               ; preds = %49
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %63, i32 0, i32 21
  %65 = load ptr, ptr %64, align 8, !tbaa !28
  %66 = call i64 @UdpIoFreeIo(ptr noundef %65)
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %67, i32 0, i32 21
  store ptr null, ptr %68, align 8, !tbaa !28
  br label %69

69:                                               ; preds = %62, %49
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %70, i32 0, i32 22
  %72 = load ptr, ptr %71, align 8, !tbaa !29
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %80

74:                                               ; preds = %69
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %75, i32 0, i32 22
  %77 = load ptr, ptr %76, align 8, !tbaa !29
  call void @FreePool(ptr noundef %77)
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %78, i32 0, i32 22
  store ptr null, ptr %79, align 8, !tbaa !29
  br label %80

80:                                               ; preds = %74, %69
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %81, i32 0, i32 31
  store i32 0, ptr %82, align 8, !tbaa !30
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %83, i32 0, i32 32
  store i32 0, ptr %84, align 4, !tbaa !31
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %85, i32 0, i32 33
  store i64 0, ptr %86, align 8, !tbaa !32
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %87, i32 0, i32 34
  store i64 0, ptr %88, align 8, !tbaa !33
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %89, i32 0, i32 35
  store i32 0, ptr %90, align 8, !tbaa !34
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %91, i32 0, i32 28
  call void @DhcpCleanConfigure(ptr noundef %92)
  ret void
}

declare void @FreePool(ptr noundef) #0

declare void @DhcpCleanConfigure(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, !13, i64 72}
!10 = !{!"_DHCP_SERVICE", !11, i64 0, !12, i64 8, !13, i64 24, !6, i64 32, !6, i64 40, !14, i64 48, !13, i64 64, !13, i64 72, !13, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !6, i64 104, !6, i64 112, !6, i64 120, !11, i64 128, !11, i64 132, !11, i64 136, !13, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !15, i64 176, !7, i64 208, !7, i64 209, !7, i64 210, !6, i64 232, !16, i64 240, !11, i64 312, !6, i64 320, !11, i64 328, !11, i64 332, !13, i64 336, !13, i64 344, !11, i64 352}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"", !7, i64 0}
!16 = !{!"", !11, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !15, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64}
!17 = !{!10, !11, i64 88}
!18 = !{!10, !11, i64 92}
!19 = !{!10, !11, i64 96}
!20 = !{!10, !11, i64 100}
!21 = !{!10, !6, i64 104}
!22 = !{!10, !6, i64 112}
!23 = !{!10, !6, i64 120}
!24 = !{!10, !11, i64 128}
!25 = !{!10, !11, i64 132}
!26 = !{!10, !11, i64 136}
!27 = !{!10, !13, i64 144}
!28 = !{!10, !6, i64 160}
!29 = !{!10, !6, i64 168}
!30 = !{!10, !11, i64 328}
!31 = !{!10, !11, i64 332}
!32 = !{!10, !13, i64 336}
!33 = !{!10, !13, i64 344}
!34 = !{!10, !11, i64 352}


; 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 i64 @UdpIoFreeIo(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @DhcpCleanLease(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  store i64 1, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  %4 = load i32, ptr %3, align 8, !tbaa !16
  %5 = add i32 %4, 1
  store i32 %5, ptr %3, align 8, !tbaa !16
  %6 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 0, ptr %6, align 4, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 0, ptr %7, align 8, !tbaa !18
  %8 = getelementptr inbounds i8, ptr %0, i64 100
  store i32 0, ptr %8, align 4, !tbaa !19
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  %10 = load ptr, ptr %9, align 8, !tbaa !20
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %12, label %11

11:                                               ; preds = %1
  tail call void @FreePool(ptr noundef nonnull %10) #3
  store ptr null, ptr %9, align 8, !tbaa !20
  br label %12

12:                                               ; preds = %11, %1
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  %14 = load ptr, ptr %13, align 8, !tbaa !21
  %.not35 = icmp eq ptr %14, null
  br i1 %.not35, label %16, label %15

15:                                               ; preds = %12
  tail call void @FreePool(ptr noundef nonnull %14) #3
  store ptr null, ptr %13, align 8, !tbaa !21
  br label %16

16:                                               ; preds = %15, %12
  %17 = getelementptr inbounds i8, ptr %0, i64 120
  %18 = load ptr, ptr %17, align 8, !tbaa !22
  %.not36 = icmp eq ptr %18, null
  br i1 %.not36, label %20, label %19

19:                                               ; preds = %16
  tail call void @FreePool(ptr noundef nonnull %18) #3
  store ptr null, ptr %17, align 8, !tbaa !22
  br label %20

20:                                               ; preds = %19, %16
  %21 = getelementptr inbounds i8, ptr %0, i64 128
  store i32 0, ptr %21, align 8, !tbaa !23
  %22 = getelementptr inbounds i8, ptr %0, i64 132
  store i32 0, ptr %22, align 4, !tbaa !24
  %23 = getelementptr inbounds i8, ptr %0, i64 136
  store i32 0, ptr %23, align 8, !tbaa !25
  %24 = getelementptr inbounds i8, ptr %0, i64 144
  store i64 0, ptr %24, align 8, !tbaa !26
  %25 = getelementptr inbounds i8, ptr %0, i64 160
  %26 = load ptr, ptr %25, align 8, !tbaa !27
  %.not37 = icmp eq ptr %26, null
  br i1 %.not37, label %29, label %27

27:                                               ; preds = %20
  %28 = tail call i64 @UdpIoFreeIo(ptr noundef nonnull %26) #3
  store ptr null, ptr %25, align 8, !tbaa !27
  br label %29

29:                                               ; preds = %27, %20
  %30 = getelementptr inbounds i8, ptr %0, i64 168
  %31 = load ptr, ptr %30, align 8, !tbaa !28
  %.not38 = icmp eq ptr %31, null
  br i1 %.not38, label %33, label %32

32:                                               ; preds = %29
  tail call void @FreePool(ptr noundef nonnull %31) #3
  store ptr null, ptr %30, align 8, !tbaa !28
  br label %33

33:                                               ; preds = %32, %29
  %34 = getelementptr inbounds i8, ptr %0, i64 328
  %35 = getelementptr inbounds i8, ptr %0, i64 240
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %34, i8 0, i64 28, i1 false)
  tail call void @DhcpCleanConfigure(ptr noundef nonnull %35) #3
  ret void
}

declare void @FreePool(ptr noundef) local_unnamed_addr #0

declare void @DhcpCleanConfigure(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, !12, i64 72}
!6 = !{!"_DHCP_SERVICE", !7, i64 0, !10, i64 8, !12, i64 24, !11, i64 32, !11, i64 40, !13, i64 48, !12, i64 64, !12, i64 72, !12, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !11, i64 104, !11, i64 112, !11, i64 120, !7, i64 128, !7, i64 132, !7, i64 136, !12, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !14, i64 176, !8, i64 208, !8, i64 209, !8, i64 210, !11, i64 232, !15, i64 240, !7, i64 312, !11, i64 320, !7, i64 328, !7, i64 332, !12, i64 336, !12, i64 344, !7, i64 352}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!14 = !{!"", !8, i64 0}
!15 = !{!"", !7, i64 0, !11, i64 8, !7, i64 16, !11, i64 24, !14, i64 32, !11, i64 40, !11, i64 48, !7, i64 56, !11, i64 64}
!16 = !{!6, !7, i64 88}
!17 = !{!6, !7, i64 92}
!18 = !{!6, !7, i64 96}
!19 = !{!6, !7, i64 100}
!20 = !{!6, !11, i64 104}
!21 = !{!6, !11, i64 112}
!22 = !{!6, !11, i64 120}
!23 = !{!6, !7, i64 128}
!24 = !{!6, !7, i64 132}
!25 = !{!6, !7, i64 136}
!26 = !{!6, !12, i64 144}
!27 = !{!6, !11, i64 160}
!28 = !{!6, !11, i64 168}


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