; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe (Dhcp6CallbackUser)

; 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._DHCP6_INSTANCE = type { i32, ptr, ptr, %struct._LIST_ENTRY, %struct._EFI_DHCP6_PROTOCOL, ptr, ptr, ptr, %struct._DHCP6_IA_CB, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr, i8, ptr, i64, i8, i8, i64 }
%struct._EFI_DHCP6_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._DHCP6_IA_CB = type { ptr, i32, i32, i32, i32 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_DHCP6_CONFIG_DATA = type { ptr, ptr, i32, ptr, %struct.EFI_DHCP6_IA_DESCRIPTOR, ptr, i8, i8, ptr }
%struct.EFI_DHCP6_IA_DESCRIPTOR = type { i16, i32 }
%struct.EFI_DHCP6_IA = type { %struct.EFI_DHCP6_IA_DESCRIPTOR, i32, ptr, i32, [1 x %struct.EFI_DHCP6_IA_ADDRESS] }
%struct.EFI_DHCP6_IA_ADDRESS = type { %struct.EFI_IPv6_ADDRESS, i32, i32 }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }

@.str = external hidden unnamed_addr constant [131 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1

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

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #1

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

declare void @FreePool(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @Dhcp6CallbackUser(ptr noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  br label %11

11:                                               ; preds = %3
  %12 = call zeroext i8 @DebugAssertEnabled()
  %13 = icmp ne i8 %12, 0
  br i1 %13, label %14, label %19

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

17:                                               ; preds = %14
  call void @DebugAssert(ptr noundef @.str, i64 noundef 494, ptr noundef @.str.1)
  br label %18

18:                                               ; preds = %17, %14
  br label %19

19:                                               ; preds = %18, %11
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = call zeroext i8 @DebugAssertEnabled()
  %24 = icmp ne i8 %23, 0
  br i1 %24, label %25, label %32

25:                                               ; preds = %22
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %26, i32 0, i32 6
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = icmp ne ptr %28, null
  br i1 %29, label %31, label %30

30:                                               ; preds = %25
  call void @DebugAssert(ptr noundef @.str, i64 noundef 495, ptr noundef @.str.5)
  br label %31

31:                                               ; preds = %30, %25
  br label %32

32:                                               ; preds = %31, %22
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = call zeroext i8 @DebugAssertEnabled()
  %37 = icmp ne i8 %36, 0
  br i1 %37, label %38, label %46

38:                                               ; preds = %35
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %39, i32 0, i32 8
  %41 = getelementptr inbounds %struct._DHCP6_IA_CB, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = icmp ne ptr %42, null
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  call void @DebugAssert(ptr noundef @.str, i64 noundef 496, ptr noundef @.str.6)
  br label %45

45:                                               ; preds = %44, %38
  br label %46

46:                                               ; preds = %45, %35
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  store ptr null, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %7, align 8, !tbaa !18
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = getelementptr inbounds %struct.EFI_DHCP6_CONFIG_DATA, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !19
  store ptr %53, ptr %9, align 8, !tbaa !5
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %54, i32 0, i32 6
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct.EFI_DHCP6_CONFIG_DATA, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !23
  store ptr %58, ptr %10, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %96

61:                                               ; preds = %48
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %66, i32 0, i32 8
  %68 = getelementptr inbounds %struct._DHCP6_IA_CB, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !17
  %70 = getelementptr inbounds %struct.EFI_DHCP6_IA, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 8, !tbaa !24
  %72 = load i32, ptr %5, align 4, !tbaa !9
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = call i64 %62(ptr noundef %64, ptr noundef %65, i32 noundef %71, i32 noundef %72, ptr noundef %74, ptr noundef %8)
  store i64 %75, ptr %7, align 8, !tbaa !18
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = icmp ne ptr %76, null
  br i1 %77, label %78, label %95

78:                                               ; preds = %61
  br label %79

79:                                               ; preds = %78
  %80 = call zeroext i8 @DebugAssertEnabled()
  %81 = icmp ne i8 %80, 0
  br i1 %81, label %82, label %88

82:                                               ; preds = %79
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load ptr, ptr %83, align 8, !tbaa !5
  %85 = icmp ne ptr %84, null
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  call void @DebugAssert(ptr noundef @.str, i64 noundef 520, ptr noundef @.str.7)
  br label %87

87:                                               ; preds = %86, %82
  br label %88

88:                                               ; preds = %87, %79
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load ptr, ptr %91, align 8, !tbaa !5
  call void @FreePool(ptr noundef %92)
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %93, ptr %94, align 8, !tbaa !5
  br label %95

95:                                               ; preds = %90, %61
  br label %96

96:                                               ; preds = %95, %48
  %97 = load i64, ptr %7, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i64 %97
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 120}
!12 = !{!"_DHCP6_INSTANCE", !10, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 40, !6, i64 112, !6, i64 120, !6, i64 128, !15, i64 136, !13, i64 160, !13, i64 176, !6, i64 192, !7, i64 200, !6, i64 208, !16, i64 216, !7, i64 224, !7, i64 225, !16, i64 232}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"_EFI_DHCP6_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}
!15 = !{!"_DHCP6_IA_CB", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!16 = !{!"long long", !7, i64 0}
!17 = !{!12, !6, i64 136}
!18 = !{!16, !16, i64 0}
!19 = !{!20, !6, i64 0}
!20 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !21, i64 32, !6, i64 40, !7, i64 48, !7, i64 49, !6, i64 56}
!21 = !{!"", !22, i64 0, !10, i64 4}
!22 = !{!"short", !7, i64 0}
!23 = !{!20, !6, i64 8}
!24 = !{!25, !10, i64 8}
!25 = !{!"", !21, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !7, i64 28}


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

@.str = external hidden unnamed_addr constant [131 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

declare void @DebugAssert(ptr noundef, i64 noundef, 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

declare void @FreePool(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @Dhcp6CallbackUser(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = tail call zeroext i8 @DebugAssertEnabled() #3
  %6 = icmp eq i8 %5, 0
  %7 = icmp ne ptr %2, null
  %or.cond = or i1 %7, %6
  br i1 %or.cond, label %9, label %8

8:                                                ; preds = %3
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 494, ptr noundef nonnull @.str.1) #3
  br label %9

9:                                                ; preds = %3, %8
  %10 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %10, 0
  br i1 %.not, label %15, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 120
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %.not17 = icmp eq ptr %13, null
  br i1 %.not17, label %14, label %15

14:                                               ; preds = %11
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 495, ptr noundef nonnull @.str.5) #3
  br label %15

15:                                               ; preds = %9, %14, %11
  %16 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not18 = icmp eq i8 %16, 0
  br i1 %.not18, label %21, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %0, i64 136
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %.not19 = icmp eq ptr %19, null
  br i1 %.not19, label %20, label %21

20:                                               ; preds = %17
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 496, ptr noundef nonnull @.str.6) #3
  br label %21

21:                                               ; preds = %17, %20, %15
  store ptr null, ptr %4, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %0, i64 120
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %.not20 = icmp eq ptr %24, null
  br i1 %.not20, label %42, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %23, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = getelementptr inbounds i8, ptr %0, i64 136
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  %32 = load i32, ptr %31, align 8, !tbaa !22
  %33 = load ptr, ptr %2, align 8, !tbaa !16
  %34 = call i64 %24(ptr noundef nonnull %28, ptr noundef %27, i32 noundef %32, i32 noundef %1, ptr noundef %33, ptr noundef nonnull %4) #3
  %35 = load ptr, ptr %4, align 8, !tbaa !16
  %.not21 = icmp eq ptr %35, null
  br i1 %.not21, label %42, label %36

36:                                               ; preds = %25
  %37 = call zeroext i8 @DebugAssertEnabled() #3
  %.not22 = icmp ne i8 %37, 0
  %.pre24 = load ptr, ptr %2, align 8, !tbaa !16
  %.not23 = icmp eq ptr %.pre24, null
  %or.cond25 = select i1 %.not22, i1 %.not23, i1 false
  br i1 %or.cond25, label %38, label %39

38:                                               ; preds = %36
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 520, ptr noundef nonnull @.str.7) #3
  %.pre = load ptr, ptr %2, align 8, !tbaa !16
  br label %39

39:                                               ; preds = %38, %36
  %40 = phi ptr [ %.pre, %38 ], [ %.pre24, %36 ]
  call void @FreePool(ptr noundef %40) #3
  %41 = load ptr, ptr %4, align 8, !tbaa !16
  store ptr %41, ptr %2, align 8, !tbaa !16
  br label %42

42:                                               ; preds = %25, %39, %21
  %.0 = phi i64 [ %34, %39 ], [ %34, %25 ], [ 0, %21 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i64 %.0
}

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 = { 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 120}
!6 = !{!"_DHCP6_INSTANCE", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !12, i64 40, !10, i64 112, !10, i64 120, !10, i64 128, !13, i64 136, !11, i64 160, !11, i64 176, !10, i64 192, !8, i64 200, !10, i64 208, !14, i64 216, !8, i64 224, !8, i64 225, !14, i64 232}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!12 = !{!"_EFI_DHCP6_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!13 = !{!"_DHCP6_IA_CB", !10, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!14 = !{!"long long", !8, i64 0}
!15 = !{!6, !10, i64 136}
!16 = !{!10, !10, i64 0}
!17 = !{!18, !10, i64 0}
!18 = !{!"", !10, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !19, i64 32, !10, i64 40, !8, i64 48, !8, i64 49, !10, i64 56}
!19 = !{!"", !20, i64 0, !7, i64 4}
!20 = !{!"short", !8, i64 0}
!21 = !{!18, !10, i64 8}
!22 = !{!23, !7, i64 8}
!23 = !{!"", !19, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !8, i64 28}


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