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

; 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_SIMPLE_NETWORK_MODE = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x %struct.EFI_MAC_ADDRESS], %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i8, i8, i8, i8, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }
%struct._IP4_INTERFACE = type { i32, %struct._LIST_ENTRY, i64, i32, i32, i32, i32, i8, ptr, ptr, ptr, ptr, ptr, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i32, %struct._LIST_ENTRY, i8 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._EFI_MANAGED_NETWORK_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @AllocatePool(i64 noundef) #1

declare ptr @InitializeListHead(ptr noundef) #1

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

declare void @FreePool(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @Ip4CreateInterface(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.EFI_SIMPLE_NETWORK_MODE, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 656, ptr %9) #3
  %11 = call ptr @AllocatePool(i64 noundef 232)
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %17, label %14

14:                                               ; preds = %3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14, %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %80

18:                                               ; preds = %14
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %19, i32 0, i32 0
  store i32 1179209801, ptr %20, align 8, !tbaa !9
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %21, i32 0, i32 1
  %23 = call ptr @InitializeListHead(ptr noundef %22)
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %24, i32 0, i32 2
  store i64 1, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %26, i32 0, i32 3
  store i32 0, ptr %27, align 8, !tbaa !16
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %28, i32 0, i32 4
  store i32 0, ptr %29, align 4, !tbaa !17
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %30, i32 0, i32 7
  store i8 0, ptr %31, align 8, !tbaa !18
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %33, i32 0, i32 8
  store ptr %32, ptr %34, align 8, !tbaa !19
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %36, i32 0, i32 9
  store ptr %35, ptr %37, align 8, !tbaa !20
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %39, i32 0, i32 10
  store ptr %38, ptr %40, align 8, !tbaa !21
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %41, i32 0, i32 11
  store ptr null, ptr %42, align 8, !tbaa !22
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %43, i32 0, i32 12
  store ptr null, ptr %44, align 8, !tbaa !23
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %45, i32 0, i32 13
  %47 = call ptr @InitializeListHead(ptr noundef %46)
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %48, i32 0, i32 14
  %50 = call ptr @InitializeListHead(ptr noundef %49)
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %51, i32 0, i32 15
  store ptr null, ptr %52, align 8, !tbaa !24
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._EFI_MANAGED_NETWORK_PROTOCOL, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !25
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call i64 %55(ptr noundef %56, ptr noundef null, ptr noundef %9)
  %58 = icmp slt i64 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %18
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %60)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %80

61:                                               ; preds = %18
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %62, i32 0, i32 16
  %64 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %9, i32 0, i32 11
  %65 = call ptr @CopyMem(ptr noundef %63, ptr noundef %64, i64 noundef 32)
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %66, i32 0, i32 17
  %68 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %9, i32 0, i32 12
  %69 = call ptr @CopyMem(ptr noundef %67, ptr noundef %68, i64 noundef 32)
  %70 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %9, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !27
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %72, i32 0, i32 18
  store i32 %71, ptr %73, align 8, !tbaa !29
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %74, i32 0, i32 19
  %76 = call ptr @InitializeListHead(ptr noundef %75)
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %77, i32 0, i32 20
  store i8 0, ptr %78, align 8, !tbaa !30
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %79, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %80

80:                                               ; preds = %61, %59, %17
  call void @llvm.lifetime.end.p0(i64 656, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %81 = load ptr, ptr %4, align 8
  ret ptr %81
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 0}
!10 = !{!"_IP4_INTERFACE", !11, i64 0, !12, i64 8, !13, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !7, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !12, i64 96, !12, i64 112, !6, i64 128, !14, i64 136, !14, i64 168, !11, i64 200, !12, i64 208, !7, i64 224}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"", !7, i64 0}
!15 = !{!10, !13, i64 24}
!16 = !{!10, !11, i64 32}
!17 = !{!10, !11, i64 36}
!18 = !{!10, !7, i64 48}
!19 = !{!10, !6, i64 56}
!20 = !{!10, !6, i64 64}
!21 = !{!10, !6, i64 72}
!22 = !{!10, !6, i64 80}
!23 = !{!10, !6, i64 88}
!24 = !{!10, !6, i64 128}
!25 = !{!26, !6, i64 0}
!26 = !{!"_EFI_MANAGED_NETWORK_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}
!27 = !{!28, !11, i64 4}
!28 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !14, i64 552, !14, i64 584, !14, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!29 = !{!10, !11, i64 200}
!30 = !{!10, !7, i64 224}


; 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_SIMPLE_NETWORK_MODE = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x %struct.EFI_MAC_ADDRESS], %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i8, i8, i8, i8, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @AllocatePool(i64 noundef) local_unnamed_addr #1

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #1

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

declare void @FreePool(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @Ip4CreateInterface(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.EFI_SIMPLE_NETWORK_MODE, align 4
  call void @llvm.lifetime.start.p0(i64 656, ptr nonnull %4) #4
  %5 = tail call ptr @AllocatePool(i64 noundef 232) #4
  %6 = icmp eq ptr %5, null
  %7 = icmp eq ptr %0, null
  %or.cond = or i1 %7, %6
  br i1 %or.cond, label %41, label %8

8:                                                ; preds = %3
  store i32 1179209801, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  %10 = tail call ptr @InitializeListHead(ptr noundef nonnull %9) #4
  %11 = getelementptr inbounds i8, ptr %5, i64 24
  store i64 1, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %5, i64 32
  store i32 0, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %5, i64 36
  store i32 0, ptr %13, align 4, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %5, i64 48
  store i8 0, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr %1, ptr %15, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %5, i64 64
  store ptr %2, ptr %16, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %5, i64 72
  store ptr %0, ptr %17, align 8, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %5, i64 80
  %19 = getelementptr inbounds i8, ptr %5, i64 96
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %18, i8 0, i64 16, i1 false)
  %20 = tail call ptr @InitializeListHead(ptr noundef nonnull %19) #4
  %21 = getelementptr inbounds i8, ptr %5, i64 112
  %22 = tail call ptr @InitializeListHead(ptr noundef nonnull %21) #4
  %23 = getelementptr inbounds i8, ptr %5, i64 128
  store ptr null, ptr %23, align 8, !tbaa !21
  %24 = load ptr, ptr %0, align 8, !tbaa !22
  %25 = call i64 %24(ptr noundef nonnull %0, ptr noundef null, ptr noundef nonnull %4) #4
  %26 = icmp slt i64 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %8
  call void @FreePool(ptr noundef nonnull %5) #4
  br label %41

28:                                               ; preds = %8
  %29 = getelementptr inbounds i8, ptr %5, i64 136
  %30 = getelementptr inbounds i8, ptr %4, i64 552
  %31 = call ptr @CopyMem(ptr noundef nonnull %29, ptr noundef nonnull %30, i64 noundef 32) #4
  %32 = getelementptr inbounds i8, ptr %5, i64 168
  %33 = getelementptr inbounds i8, ptr %4, i64 584
  %34 = call ptr @CopyMem(ptr noundef nonnull %32, ptr noundef nonnull %33, i64 noundef 32) #4
  %35 = getelementptr inbounds i8, ptr %4, i64 4
  %36 = load i32, ptr %35, align 4, !tbaa !24
  %37 = getelementptr inbounds i8, ptr %5, i64 200
  store i32 %36, ptr %37, align 8, !tbaa !26
  %38 = getelementptr inbounds i8, ptr %5, i64 208
  %39 = call ptr @InitializeListHead(ptr noundef nonnull %38) #4
  %40 = getelementptr inbounds i8, ptr %5, i64 224
  store i8 0, ptr %40, align 8, !tbaa !27
  br label %41

41:                                               ; preds = %3, %28, %27
  %.0 = phi ptr [ null, %27 ], [ %5, %28 ], [ null, %3 ]
  call void @llvm.lifetime.end.p0(i64 656, ptr nonnull %4) #4
  ret ptr %.0
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"_IP4_INTERFACE", !7, i64 0, !10, i64 8, !12, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !8, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !10, i64 96, !10, i64 112, !11, i64 128, !13, i64 136, !13, i64 168, !7, i64 200, !10, i64 208, !8, i64 224}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"", !8, i64 0}
!14 = !{!6, !12, i64 24}
!15 = !{!6, !7, i64 32}
!16 = !{!6, !7, i64 36}
!17 = !{!6, !8, i64 48}
!18 = !{!6, !11, i64 56}
!19 = !{!6, !11, i64 64}
!20 = !{!6, !11, i64 72}
!21 = !{!6, !11, i64 128}
!22 = !{!23, !11, i64 0}
!23 = !{!"_EFI_MANAGED_NETWORK_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}
!24 = !{!25, !7, i64 4}
!25 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !13, i64 552, !13, i64 584, !13, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!26 = !{!6, !7, i64 200}
!27 = !{!6, !8, i64 224}


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