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

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

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

15:                                               ; preds = %4
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %46

16:                                               ; preds = %4
  %17 = load ptr, ptr %10, align 8, !tbaa !12
  %18 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %17, i32 0, i32 0
  %19 = call ptr @InitializeListHead(ptr noundef %18)
  %20 = load ptr, ptr %10, align 8, !tbaa !12
  %21 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %20, i32 0, i32 7
  %22 = call ptr @InitializeListHead(ptr noundef %21)
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load ptr, ptr %10, align 8, !tbaa !12
  %25 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %24, i32 0, i32 1
  store i32 %23, ptr %25, align 8, !tbaa !14
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !12
  %28 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %27, i32 0, i32 2
  store i32 %26, ptr %28, align 4, !tbaa !18
  %29 = load i16, ptr %8, align 2, !tbaa !9
  %30 = load ptr, ptr %10, align 8, !tbaa !12
  %31 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %30, i32 0, i32 3
  store i16 %29, ptr %31, align 8, !tbaa !19
  %32 = load i8, ptr %9, align 1, !tbaa !11
  %33 = load ptr, ptr %10, align 8, !tbaa !12
  %34 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %33, i32 0, i32 4
  store i8 %32, ptr %34, align 2, !tbaa !20
  %35 = load ptr, ptr %10, align 8, !tbaa !12
  %36 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %35, i32 0, i32 5
  store i64 0, ptr %36, align 8, !tbaa !21
  %37 = load ptr, ptr %10, align 8, !tbaa !12
  %38 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %37, i32 0, i32 6
  store i64 0, ptr %38, align 8, !tbaa !22
  %39 = load ptr, ptr %10, align 8, !tbaa !12
  %40 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %39, i32 0, i32 8
  store ptr null, ptr %40, align 8, !tbaa !23
  %41 = load ptr, ptr %10, align 8, !tbaa !12
  %42 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %41, i32 0, i32 9
  store ptr null, ptr %42, align 8, !tbaa !24
  %43 = load ptr, ptr %10, align 8, !tbaa !12
  %44 = getelementptr inbounds %struct.IP4_ASSEMBLE_ENTRY, ptr %43, i32 0, i32 10
  store i64 120, ptr %44, align 8, !tbaa !25
  %45 = load ptr, ptr %10, align 8, !tbaa !12
  store ptr %45, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %46

46:                                               ; preds = %16, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %47 = load ptr, ptr %5, align 8
  ret ptr %47
}

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

declare ptr @AllocatePool(i64 noundef) #2

declare ptr @InitializeListHead(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"", !16, i64 0, !6, i64 16, !6, i64 20, !10, i64 24, !7, i64 26, !17, i64 32, !17, i64 40, !16, i64 48, !13, i64 64, !13, i64 72, !17, i64 80}
!16 = !{!"_LIST_ENTRY", !13, i64 0, !13, i64 8}
!17 = !{!"long long", !7, i64 0}
!18 = !{!15, !6, i64 20}
!19 = !{!15, !10, i64 24}
!20 = !{!15, !7, i64 26}
!21 = !{!15, !17, i64 32}
!22 = !{!15, !17, i64 40}
!23 = !{!15, !13, i64 64}
!24 = !{!15, !13, i64 72}
!25 = !{!15, !17, i64 80}


; 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 ptr @Ip4CreateAssembleEntry(i32 noundef %0, i32 noundef %1, i16 noundef zeroext %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = tail call ptr @AllocatePool(i64 noundef 88) #3
  %6 = icmp eq ptr %5, null
  br i1 %6, label %18, label %7

7:                                                ; preds = %4
  %8 = tail call ptr @InitializeListHead(ptr noundef nonnull %5) #3
  %9 = getelementptr inbounds i8, ptr %5, i64 48
  %10 = tail call ptr @InitializeListHead(ptr noundef nonnull %9) #3
  %11 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 %0, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %5, i64 20
  store i32 %1, ptr %12, align 4, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %5, i64 24
  store i16 %2, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %5, i64 26
  store i8 %3, ptr %14, align 2, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %5, i64 32
  %16 = getelementptr inbounds i8, ptr %5, i64 64
  %17 = getelementptr inbounds i8, ptr %5, i64 80
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %16, i8 0, i64 16, i1 false)
  store i64 120, ptr %17, align 8, !tbaa !17
  br label %18

18:                                               ; preds = %4, %7
  ret ptr %5
}

declare ptr @AllocatePool(i64 noundef) local_unnamed_addr #1

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #1

; 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 = { 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 = { 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, !11, i64 16}
!6 = !{!"", !7, i64 0, !11, i64 16, !11, i64 20, !12, i64 24, !9, i64 26, !13, i64 32, !13, i64 40, !7, i64 48, !8, i64 64, !8, i64 72, !13, i64 80}
!7 = !{!"_LIST_ENTRY", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"short", !9, i64 0}
!13 = !{!"long long", !9, i64 0}
!14 = !{!6, !11, i64 20}
!15 = !{!6, !12, i64 24}
!16 = !{!6, !9, i64 26}
!17 = !{!6, !13, i64 80}


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