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

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

@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @SetMem64(ptr noundef %0, i64 noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  %8 = load i64, ptr %6, align 8, !tbaa !9
  %9 = icmp eq i64 %8, 0
  br i1 %9, label %10, label %12

10:                                               ; preds = %3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %11, ptr %4, align 8
  br label %65

12:                                               ; preds = %3
  br label %13

13:                                               ; preds = %12
  %14 = call zeroext i8 @DebugAssertEnabled()
  %15 = icmp ne i8 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @DebugAssert(ptr noundef @.str, i64 noundef 58, ptr noundef @.str.1)
  br label %20

20:                                               ; preds = %19, %16
  br label %21

21:                                               ; preds = %20, %13
  br label %22

22:                                               ; preds = %21
  br label %23

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

26:                                               ; preds = %23
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = sub i64 %27, 1
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = ptrtoint ptr %29 to i64
  %31 = sub i64 -1, %30
  %32 = icmp ule i64 %28, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %26
  call void @DebugAssert(ptr noundef @.str, i64 noundef 59, ptr noundef @.str.2)
  br label %34

34:                                               ; preds = %33, %26
  br label %35

35:                                               ; preds = %34, %23
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = call zeroext i8 @DebugAssertEnabled()
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %47

40:                                               ; preds = %37
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = ptrtoint ptr %41 to i64
  %43 = and i64 %42, 7
  %44 = icmp eq i64 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %40
  call void @DebugAssert(ptr noundef @.str, i64 noundef 60, ptr noundef @.str.3)
  br label %46

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

47:                                               ; preds = %46, %37
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = call zeroext i8 @DebugAssertEnabled()
  %51 = icmp ne i8 %50, 0
  br i1 %51, label %52, label %58

52:                                               ; preds = %49
  %53 = load i64, ptr %6, align 8, !tbaa !9
  %54 = and i64 %53, 7
  %55 = icmp eq i64 %54, 0
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  call void @DebugAssert(ptr noundef @.str, i64 noundef 61, ptr noundef @.str.4)
  br label %57

57:                                               ; preds = %56, %52
  br label %58

58:                                               ; preds = %57, %49
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load i64, ptr %6, align 8, !tbaa !9
  %62 = udiv i64 %61, 8
  %63 = load i64, ptr %7, align 8, !tbaa !9
  %64 = call ptr @InternalMemSetMem64(ptr noundef %60, i64 noundef %62, i64 noundef %63)
  store ptr %64, ptr %4, align 8
  br label %65

65:                                               ; preds = %59, %10
  %66 = load ptr, ptr %4, align 8
  ret ptr %66
}

declare zeroext i8 @DebugAssertEnabled() #1

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

declare ptr @InternalMemSetMem64(ptr noundef, i64 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, 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"

@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @SetMem64(ptr noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq i64 %1, 0
  br i1 %4, label %28, label %5

5:                                                ; preds = %3
  %6 = tail call zeroext i8 @DebugAssertEnabled() #2
  %7 = icmp eq i8 %6, 0
  %8 = icmp ne ptr %0, null
  %or.cond = or i1 %8, %7
  br i1 %or.cond, label %10, label %9

9:                                                ; preds = %5
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 58, ptr noundef nonnull @.str.1) #2
  br label %10

10:                                               ; preds = %9, %5
  %11 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp ne i8 %11, 0
  %12 = ptrtoint ptr %0 to i64
  %13 = sub i64 0, %1
  %.not12 = icmp ult i64 %13, %12
  %or.cond16 = and i1 %.not12, %.not
  br i1 %or.cond16, label %14, label %15

14:                                               ; preds = %10
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 59, ptr noundef nonnull @.str.2) #2
  br label %15

15:                                               ; preds = %14, %10
  %16 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not13 = icmp eq i8 %16, 0
  %17 = and i64 %12, 7
  %18 = icmp eq i64 %17, 0
  %or.cond19 = or i1 %18, %.not13
  br i1 %or.cond19, label %20, label %19

19:                                               ; preds = %15
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 60, ptr noundef nonnull @.str.3) #2
  br label %20

20:                                               ; preds = %19, %15
  %21 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not14 = icmp eq i8 %21, 0
  %22 = and i64 %1, 7
  %23 = icmp eq i64 %22, 0
  %or.cond21 = or i1 %23, %.not14
  br i1 %or.cond21, label %25, label %24

24:                                               ; preds = %20
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 61, ptr noundef nonnull @.str.4) #2
  br label %25

25:                                               ; preds = %20, %24
  %26 = lshr i64 %1, 3
  %27 = tail call ptr @InternalMemSetMem64(ptr noundef %0, i64 noundef %26, i64 noundef %2) #2
  br label %28

28:                                               ; preds = %3, %25
  %.0 = phi ptr [ %27, %25 ], [ %0, %3 ]
  ret ptr %.0
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare ptr @InternalMemSetMem64(ptr noundef, i64 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)"}


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