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

; 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_IPv6_ADDRESS = type { [16 x i8] }

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

; 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 @NetIp6IsUnspecifiedAddr(ptr noundef %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  store i8 0, ptr %4, align 1, !tbaa !9
  br label %6

6:                                                ; preds = %21, %1
  %7 = load i8, ptr %4, align 1, !tbaa !9
  %8 = zext i8 %7 to i32
  %9 = icmp slt i32 %8, 16
  br i1 %9, label %10, label %24

10:                                               ; preds = %6
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %11, i32 0, i32 0
  %13 = load i8, ptr %4, align 1, !tbaa !9
  %14 = zext i8 %13 to i64
  %15 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %17 = zext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %10
  store i8 0, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %25

20:                                               ; preds = %10
  br label %21

21:                                               ; preds = %20
  %22 = load i8, ptr %4, align 1, !tbaa !9
  %23 = add i8 %22, 1
  store i8 %23, ptr %4, align 1, !tbaa !9
  br label %6, !llvm.loop !10

24:                                               ; preds = %6
  store i8 1, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %25

25:                                               ; preds = %24, %19
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  %26 = load i8, ptr %2, align 1
  ret i8 %26
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local zeroext range(i8 0, 2) i8 @NetIp6IsUnspecifiedAddr(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %.not = icmp eq i8 %2, 0
  br i1 %.not, label %3, label %48

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5
  %.not.1 = icmp eq i8 %5, 0
  br i1 %.not.1, label %6, label %48

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 2
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %.not.2 = icmp eq i8 %8, 0
  br i1 %.not.2, label %9, label %48

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 3
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %.not.3 = icmp eq i8 %11, 0
  br i1 %.not.3, label %12, label %48

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %.not.4 = icmp eq i8 %14, 0
  br i1 %.not.4, label %15, label %48

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 5
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %.not.5 = icmp eq i8 %17, 0
  br i1 %.not.5, label %18, label %48

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %0, i64 6
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %.not.6 = icmp eq i8 %20, 0
  br i1 %.not.6, label %21, label %48

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %0, i64 7
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %.not.7 = icmp eq i8 %23, 0
  br i1 %.not.7, label %24, label %48

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %.not.8 = icmp eq i8 %26, 0
  br i1 %.not.8, label %27, label %48

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %0, i64 9
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %.not.9 = icmp eq i8 %29, 0
  br i1 %.not.9, label %30, label %48

30:                                               ; preds = %27
  %31 = getelementptr inbounds i8, ptr %0, i64 10
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %.not.10 = icmp eq i8 %32, 0
  br i1 %.not.10, label %33, label %48

33:                                               ; preds = %30
  %34 = getelementptr inbounds i8, ptr %0, i64 11
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %.not.11 = icmp eq i8 %35, 0
  br i1 %.not.11, label %36, label %48

36:                                               ; preds = %33
  %37 = getelementptr inbounds i8, ptr %0, i64 12
  %38 = load i8, ptr %37, align 1, !tbaa !5
  %.not.12 = icmp eq i8 %38, 0
  br i1 %.not.12, label %39, label %48

39:                                               ; preds = %36
  %40 = getelementptr inbounds i8, ptr %0, i64 13
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %.not.13 = icmp eq i8 %41, 0
  br i1 %.not.13, label %42, label %48

42:                                               ; preds = %39
  %43 = getelementptr inbounds i8, ptr %0, i64 14
  %44 = load i8, ptr %43, align 1, !tbaa !5
  %.not.14 = icmp eq i8 %44, 0
  br i1 %.not.14, label %45, label %48

45:                                               ; preds = %42
  %46 = getelementptr inbounds i8, ptr %0, i64 15
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %.not.15 = icmp eq i8 %47, 0
  %spec.select = zext i1 %.not.15 to i8
  br label %48

48:                                               ; preds = %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6, %3, %1
  %.04 = phi i8 [ 0, %1 ], [ 0, %3 ], [ 0, %6 ], [ 0, %9 ], [ 0, %12 ], [ 0, %15 ], [ 0, %18 ], [ 0, %21 ], [ 0, %24 ], [ 0, %27 ], [ 0, %30 ], [ 0, %33 ], [ 0, %36 ], [ 0, %39 ], [ 0, %42 ], [ %spec.select, %45 ]
  ret i8 %.04
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass