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

; 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] }

@.str.12 = external hidden unnamed_addr constant [144 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [20 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

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

declare zeroext i8 @DebugAssertEnabled() #1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @NetIp6IsLinkLocalAddr(ptr noundef %0) #2 {
  %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) #3
  br label %6

6:                                                ; preds = %1
  %7 = call zeroext i8 @DebugAssertEnabled()
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %9, label %14

9:                                                ; preds = %6
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @DebugAssert(ptr noundef @.str.12, i64 noundef 757, ptr noundef @.str.16)
  br label %13

13:                                               ; preds = %12, %9
  br label %14

14:                                               ; preds = %13, %6
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds [16 x i8], ptr %18, i64 0, i64 0
  %20 = load i8, ptr %19, align 1, !tbaa !9
  %21 = zext i8 %20 to i32
  %22 = icmp ne i32 %21, 254
  br i1 %22, label %23, label %24

23:                                               ; preds = %16
  store i8 0, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %52

24:                                               ; preds = %16
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds [16 x i8], ptr %26, i64 0, i64 1
  %28 = load i8, ptr %27, align 1, !tbaa !9
  %29 = zext i8 %28 to i32
  %30 = icmp ne i32 %29, 128
  br i1 %30, label %31, label %32

31:                                               ; preds = %24
  store i8 0, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %52

32:                                               ; preds = %24
  store i8 2, ptr %4, align 1, !tbaa !9
  br label %33

33:                                               ; preds = %48, %32
  %34 = load i8, ptr %4, align 1, !tbaa !9
  %35 = zext i8 %34 to i32
  %36 = icmp slt i32 %35, 8
  br i1 %36, label %37, label %51

37:                                               ; preds = %33
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %38, i32 0, i32 0
  %40 = load i8, ptr %4, align 1, !tbaa !9
  %41 = zext i8 %40 to i64
  %42 = getelementptr inbounds [16 x i8], ptr %39, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !9
  %44 = zext i8 %43 to i32
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %37
  store i8 0, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %52

47:                                               ; preds = %37
  br label %48

48:                                               ; preds = %47
  %49 = load i8, ptr %4, align 1, !tbaa !9
  %50 = add i8 %49, 1
  store i8 %50, ptr %4, align 1, !tbaa !9
  br label %33, !llvm.loop !10

51:                                               ; preds = %33
  store i8 1, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %52

52:                                               ; preds = %51, %46, %31, %23
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  %53 = load i8, ptr %2, align 1
  ret i8 %53
}

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 = !{!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"

@.str.12 = external hidden unnamed_addr constant [144 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [20 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @NetIp6IsLinkLocalAddr(ptr noundef readonly %0) local_unnamed_addr #1 {
  %2 = tail call zeroext i8 @DebugAssertEnabled() #2
  %3 = icmp eq i8 %2, 0
  %4 = icmp ne ptr %0, null
  %or.cond = or i1 %4, %3
  br i1 %or.cond, label %6, label %5

5:                                                ; preds = %1
  tail call void @DebugAssert(ptr noundef nonnull @.str.12, i64 noundef 757, ptr noundef nonnull @.str.16) #2
  br label %6

6:                                                ; preds = %5, %1
  %7 = load i8, ptr %0, align 1, !tbaa !5
  %.not = icmp eq i8 %7, -2
  br i1 %.not, label %8, label %.loopexit

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 1
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %.not9 = icmp eq i8 %10, -128
  br i1 %.not9, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 2
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %.not10 = icmp eq i8 %12, 0
  br i1 %.not10, label %.preheader.1, label %.loopexit

.preheader.1:                                     ; preds = %.preheader.preheader
  %13 = getelementptr inbounds i8, ptr %0, i64 3
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %.not10.1 = icmp eq i8 %14, 0
  br i1 %.not10.1, label %.preheader.2, label %.loopexit

.preheader.2:                                     ; preds = %.preheader.1
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %.not10.2 = icmp eq i8 %16, 0
  br i1 %.not10.2, label %.preheader.3, label %.loopexit

.preheader.3:                                     ; preds = %.preheader.2
  %17 = getelementptr inbounds i8, ptr %0, i64 5
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %.not10.3 = icmp eq i8 %18, 0
  br i1 %.not10.3, label %.preheader.4, label %.loopexit

.preheader.4:                                     ; preds = %.preheader.3
  %19 = getelementptr inbounds i8, ptr %0, i64 6
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %.not10.4 = icmp eq i8 %20, 0
  br i1 %.not10.4, label %.preheader.5, label %.loopexit

.preheader.5:                                     ; preds = %.preheader.4
  %21 = getelementptr inbounds i8, ptr %0, i64 7
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %.not10.5 = icmp eq i8 %22, 0
  %spec.select = zext i1 %.not10.5 to i8
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.5, %.preheader.preheader, %.preheader.1, %.preheader.2, %.preheader.3, %.preheader.4, %8, %6
  %.08 = phi i8 [ 0, %6 ], [ 0, %8 ], [ 0, %.preheader.preheader ], [ 0, %.preheader.1 ], [ 0, %.preheader.2 ], [ 0, %.preheader.3 ], [ 0, %.preheader.4 ], [ %spec.select, %.preheader.5 ]
  ret i8 %.08
}

attributes #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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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