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

; 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: nounwind uwtable
define dso_local i64 @Ip6SetToAllNodeMulticast(i8 noundef zeroext %0, i8 noundef zeroext %1, ptr noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  store i8 %0, ptr %5, align 1, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !8
  %8 = load ptr, ptr %7, align 8, !tbaa !8
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  store i64 -9223372036854775806, ptr %4, align 8
  br label %40

11:                                               ; preds = %3
  %12 = load i8, ptr %5, align 1, !tbaa !5
  %13 = icmp ne i8 %12, 0
  br i1 %13, label %19, label %14

14:                                               ; preds = %11
  %15 = load i8, ptr %6, align 1, !tbaa !5
  %16 = zext i8 %15 to i32
  %17 = icmp eq i32 %16, 5
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i64 -9223372036854775806, ptr %4, align 8
  br label %40

19:                                               ; preds = %14, %11
  %20 = load ptr, ptr %7, align 8, !tbaa !8
  %21 = call ptr @ZeroMem(ptr noundef %20, i64 noundef 16)
  %22 = load ptr, ptr %7, align 8, !tbaa !8
  %23 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [16 x i8], ptr %23, i64 0, i64 0
  store i8 -1, ptr %24, align 1, !tbaa !5
  %25 = load i8, ptr %6, align 1, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !8
  %27 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds [16 x i8], ptr %27, i64 0, i64 1
  store i8 %25, ptr %28, align 1, !tbaa !5
  %29 = load i8, ptr %5, align 1, !tbaa !5
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %35, label %31

31:                                               ; preds = %19
  %32 = load ptr, ptr %7, align 8, !tbaa !8
  %33 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds [16 x i8], ptr %33, i64 0, i64 15
  store i8 1, ptr %34, align 1, !tbaa !5
  br label %39

35:                                               ; preds = %19
  %36 = load ptr, ptr %7, align 8, !tbaa !8
  %37 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds [16 x i8], ptr %37, i64 0, i64 15
  store i8 2, ptr %38, align 1, !tbaa !5
  br label %39

39:                                               ; preds = %35, %31
  store i64 0, ptr %4, align 8
  br label %40

40:                                               ; preds = %39, %18, %10
  %41 = load i64, ptr %4, align 8
  ret i64 %41
}

declare ptr @ZeroMem(ptr noundef, i64 noundef) #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 = { "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"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}


; 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 range(i64 -9223372036854775806, 1) i64 @Ip6SetToAllNodeMulticast(i8 noundef zeroext %0, i8 noundef zeroext %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %2, null
  br i1 %4, label %11, label %5

5:                                                ; preds = %3
  %6 = icmp eq i8 %0, 0
  %7 = icmp eq i8 %1, 5
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %11, label %.sink.split

.sink.split:                                      ; preds = %5
  %8 = tail call ptr @ZeroMem(ptr noundef nonnull %2, i64 noundef 16) #2
  store i8 -1, ptr %2, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %2, i64 1
  store i8 %1, ptr %9, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 15
  %. = select i1 %6, i8 1, i8 2
  store i8 %., ptr %10, align 1, !tbaa !5
  br label %11

11:                                               ; preds = %.sink.split, %5, %3
  %.0 = phi i64 [ -9223372036854775806, %3 ], [ -9223372036854775806, %5 ], [ 0, %.sink.split ]
  ret i64 %.0
}

declare ptr @ZeroMem(ptr noundef, i64 noundef) local_unnamed_addr #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 = { "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,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass