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

; 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._DHCP6_SERVICE = type { i32, ptr, ptr, %struct._EFI_SERVICE_BINDING_PROTOCOL, ptr, ptr, ptr, ptr, i32, %struct._LIST_ENTRY, i64 }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }
%struct._EFI_SIMPLE_NETWORK_PROTOCOL = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%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] }

@.str = external hidden unnamed_addr constant [131 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [25 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

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

9:                                                ; preds = %1
  %10 = call zeroext i8 @DebugAssertEnabled()
  %11 = icmp ne i8 %10, 0
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @DebugAssert(ptr noundef @.str, i64 noundef 2928, ptr noundef @.str.21)
  br label %16

16:                                               ; preds = %15, %12
  br label %17

17:                                               ; preds = %16, %9
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct._DHCP6_SERVICE, ptr %22, i32 0, i32 4
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  store ptr %24, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %25, i32 0, i32 16
  %27 = load i8, ptr %26, align 1, !tbaa !19
  store i8 %27, ptr %5, align 1, !tbaa !20
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %28, i32 0, i32 15
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  %31 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %30, i32 0, i32 17
  %32 = load i8, ptr %31, align 1, !tbaa !23
  %33 = icmp ne i8 %32, 0
  br i1 %33, label %35, label %34

34:                                               ; preds = %19
  store i8 0, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %62

35:                                               ; preds = %19
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %36, i32 0, i32 11
  %38 = load ptr, ptr %37, align 8, !tbaa !26
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = call i64 %38(ptr noundef %39, ptr noundef %4, ptr noundef null)
  store i64 %40, ptr %6, align 8, !tbaa !27
  %41 = load i64, ptr %6, align 8, !tbaa !27
  %42 = icmp slt i64 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %35
  store i8 0, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %62

44:                                               ; preds = %35
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._EFI_SIMPLE_NETWORK_PROTOCOL, ptr %45, i32 0, i32 15
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %48 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %47, i32 0, i32 18
  %49 = load i8, ptr %48, align 4, !tbaa !28
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %50, i32 0, i32 16
  store i8 %49, ptr %51, align 1, !tbaa !19
  %52 = load i8, ptr %5, align 1, !tbaa !20
  %53 = icmp ne i8 %52, 0
  br i1 %53, label %61, label %54

54:                                               ; preds = %44
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._DHCP6_INSTANCE, ptr %55, i32 0, i32 16
  %57 = load i8, ptr %56, align 1, !tbaa !19
  %58 = zext i8 %57 to i32
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %54
  store i8 1, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %62

61:                                               ; preds = %54, %44
  store i8 0, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %62

62:                                               ; preds = %61, %60, %43, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %63 = load i8, ptr %2, align 1
  ret i8 %63
}

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, !6, i64 16}
!10 = !{!"_DHCP6_INSTANCE", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !13, i64 40, !6, i64 112, !6, i64 120, !6, i64 128, !14, i64 136, !12, i64 160, !12, i64 176, !6, i64 192, !7, i64 200, !6, i64 208, !15, i64 216, !7, i64 224, !7, i64 225, !15, i64 232}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"_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}
!14 = !{!"_DHCP6_IA_CB", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!15 = !{!"long long", !7, i64 0}
!16 = !{!17, !6, i64 40}
!17 = !{!"_DHCP6_SERVICE", !11, i64 0, !6, i64 8, !6, i64 16, !18, i64 24, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !12, i64 80, !15, i64 96}
!18 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!19 = !{!10, !7, i64 225}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !6, i64 120}
!22 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !15, 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, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!23 = !{!24, !7, i64 651}
!24 = !{!"", !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, !25, i64 552, !25, i64 584, !25, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!25 = !{!"", !7, i64 0}
!26 = !{!22, !6, i64 88}
!27 = !{!15, !15, i64 0}
!28 = !{!24, !7, i64 652}


; 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.21 = external hidden unnamed_addr constant [25 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

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

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

7:                                                ; preds = %6, %1
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 40
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 225
  %13 = load i8, ptr %12, align 1, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %11, i64 120
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %15, i64 651
  %17 = load i8, ptr %16, align 1, !tbaa !21
  %.not = icmp eq i8 %17, 0
  br i1 %.not, label %27, label %18

18:                                               ; preds = %7
  %19 = getelementptr inbounds i8, ptr %11, i64 88
  %20 = load ptr, ptr %19, align 8, !tbaa !24
  %21 = call i64 %20(ptr noundef nonnull %11, ptr noundef nonnull %2, ptr noundef null) #3
  %22 = icmp slt i64 %21, 0
  br i1 %22, label %27, label %23

23:                                               ; preds = %18
  %24 = load ptr, ptr %14, align 8, !tbaa !19
  %25 = getelementptr inbounds i8, ptr %24, i64 652
  %26 = load i8, ptr %25, align 4, !tbaa !25
  store i8 %26, ptr %12, align 1, !tbaa !18
  %.not12 = icmp eq i8 %13, 0
  %.not13 = icmp ne i8 %26, 0
  %or.cond14.not = select i1 %.not12, i1 %.not13, i1 false
  %spec.select = zext i1 %or.cond14.not to i8
  br label %27

27:                                               ; preds = %23, %18, %7
  %.0 = phi i8 [ 0, %7 ], [ 0, %18 ], [ %spec.select, %23 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret i8 %.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 16}
!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 = !{!16, !10, i64 40}
!16 = !{!"_DHCP6_SERVICE", !7, i64 0, !10, i64 8, !10, i64 16, !17, i64 24, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !7, i64 72, !11, i64 80, !14, i64 96}
!17 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !10, i64 0, !10, i64 8}
!18 = !{!6, !8, i64 225}
!19 = !{!20, !10, i64 120}
!20 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !14, 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, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!21 = !{!22, !8, i64 651}
!22 = !{!"", !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, !23, i64 552, !23, i64 584, !23, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!23 = !{!"", !8, i64 0}
!24 = !{!20, !10, i64 88}
!25 = !{!22, !8, i64 652}


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