; LLVM IR from facebookresearch/habitat-sim :: src/deps/basis-universal/encoder/basisu_etc.ll (ZN6basisu9etc_block11pack_delta3Eiii)

; 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.3 = external hidden unnamed_addr constant [110 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [55 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii = external hidden unnamed_addr constant [62 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [55 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i16 @_ZN6basisu9etc_block11pack_delta3Eiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp sge i32 %7, -4
  br i1 %8, label %9, label %12

9:                                                ; preds = %3
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp sle i32 %10, 3
  br label %12

12:                                               ; preds = %9, %3
  %13 = phi i1 [ false, %3 ], [ %11, %9 ]
  br i1 %13, label %14, label %15

14:                                               ; preds = %12
  br label %17

15:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.3, i32 noundef 442, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii) #2
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp sge i32 %18, -4
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp sle i32 %21, 3
  br label %23

23:                                               ; preds = %20, %17
  %24 = phi i1 [ false, %17 ], [ %22, %20 ]
  br i1 %24, label %25, label %26

25:                                               ; preds = %23
  br label %28

26:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.3, i32 noundef 443, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii) #2
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27, %25
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = icmp sge i32 %29, -4
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = icmp sle i32 %32, 3
  br label %34

34:                                               ; preds = %31, %28
  %35 = phi i1 [ false, %28 ], [ %33, %31 ]
  br i1 %35, label %36, label %37

36:                                               ; preds = %34
  br label %39

37:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.3, i32 noundef 444, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii) #2
  unreachable

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %36
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %42, label %45

42:                                               ; preds = %39
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = add nsw i32 %43, 8
  store i32 %44, ptr %4, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %42, %39
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = icmp slt i32 %46, 0
  br i1 %47, label %48, label %51

48:                                               ; preds = %45
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = add nsw i32 %49, 8
  store i32 %50, ptr %5, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %48, %45
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = icmp slt i32 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %51
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = add nsw i32 %55, 8
  store i32 %56, ptr %6, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %54, %51
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = shl i32 %59, 3
  %61 = or i32 %58, %60
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = shl i32 %62, 6
  %64 = or i32 %61, %63
  %65 = trunc i32 %64 to i16
  ret i16 %65
}

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


; 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.3 = external hidden unnamed_addr constant [110 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [55 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii = external hidden unnamed_addr constant [62 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [55 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext range(i16 0, 512) i16 @_ZN6basisu9etc_block11pack_delta3Eiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = add i32 %0, 4
  %5 = icmp ult i32 %4, 8
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.3, i32 noundef 442, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii) #2
  unreachable

7:                                                ; preds = %3
  %8 = add i32 %1, 4
  %9 = icmp ult i32 %8, 8
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.3, i32 noundef 443, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii) #2
  unreachable

11:                                               ; preds = %7
  %12 = add i32 %2, 4
  %13 = icmp ult i32 %12, 8
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.3, i32 noundef 444, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu9etc_block11pack_delta3Eiii) #2
  unreachable

15:                                               ; preds = %11
  %16 = lshr i32 %0, 28
  %17 = and i32 %16, 8
  %spec.select = add nsw i32 %17, %0
  %18 = lshr i32 %1, 28
  %19 = and i32 %18, 8
  %.015 = add nsw i32 %19, %1
  %20 = lshr i32 %2, 28
  %21 = and i32 %20, 8
  %.0 = add nsw i32 %21, %2
  %22 = shl nuw nsw i32 %.015, 3
  %23 = shl nuw nsw i32 %spec.select, 6
  %24 = or i32 %22, %23
  %25 = or i32 %24, %.0
  %26 = trunc nuw nsw i32 %25 to i16
  ret i16 %26
}

attributes #0 = { noreturn nounwind "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 = { mustprogress 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 = { noreturn 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: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass