; LLVM IR from facebookresearch/habitat-sim :: src/deps/basis-universal/encoder (basisu_gpu_texture)

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

; 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: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode0_2EjPKvPNS_10color_rgbaE(i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu20unpack_bc7_mode1_3_7EjPKvPNS_10color_rgbaE(i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode4_5EjPKvPNS_10color_rgbaE(i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu16unpack_bc7_mode6EPKvPNS_10color_rgbaE(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6basisu10unpack_bc7EPKvPNS_10color_rgbaE(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 0
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = zext i8 %11 to i32
  store i32 %12, ptr %6, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !10
  br label %13

13:                                               ; preds = %47, %2
  %14 = load i32, ptr %7, align 4, !tbaa !10
  %15 = icmp ule i32 %14, 7
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  store i32 2, ptr %8, align 4
  br label %50

17:                                               ; preds = %13
  %18 = load i32, ptr %6, align 4, !tbaa !10
  %19 = load i32, ptr %7, align 4, !tbaa !10
  %20 = shl i32 1, %19
  %21 = and i32 %18, %20
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %46

23:                                               ; preds = %17
  %24 = load i32, ptr %7, align 4, !tbaa !10
  switch i32 %24, label %44 [
    i32 0, label %25
    i32 2, label %25
    i32 1, label %30
    i32 3, label %30
    i32 7, label %30
    i32 4, label %35
    i32 5, label %35
    i32 6, label %40
  ]

25:                                               ; preds = %23, %23
  %26 = load i32, ptr %7, align 4, !tbaa !10
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode0_2EjPKvPNS_10color_rgbaE(i32 noundef %26, ptr noundef %27, ptr noundef %28)
  store i1 %29, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %50

30:                                               ; preds = %23, %23, %23
  %31 = load i32, ptr %7, align 4, !tbaa !10
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call noundef zeroext i1 @_ZN6basisu20unpack_bc7_mode1_3_7EjPKvPNS_10color_rgbaE(i32 noundef %31, ptr noundef %32, ptr noundef %33)
  store i1 %34, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %50

35:                                               ; preds = %23, %23
  %36 = load i32, ptr %7, align 4, !tbaa !10
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = call noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode4_5EjPKvPNS_10color_rgbaE(i32 noundef %36, ptr noundef %37, ptr noundef %38)
  store i1 %39, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %50

40:                                               ; preds = %23
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = call noundef zeroext i1 @_ZN6basisu16unpack_bc7_mode6EPKvPNS_10color_rgbaE(ptr noundef %41, ptr noundef %42)
  store i1 %43, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %50

44:                                               ; preds = %23
  br label %45

45:                                               ; preds = %44
  br label %46

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

47:                                               ; preds = %46
  %48 = load i32, ptr %7, align 4, !tbaa !10
  %49 = add i32 %48, 1
  store i32 %49, ptr %7, align 4, !tbaa !10
  br label %13, !llvm.loop !12

50:                                               ; preds = %40, %35, %30, %25, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  %51 = load i32, ptr %8, align 4
  switch i32 %51, label %53 [
    i32 2, label %52
  ]

52:                                               ; preds = %50
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %53

53:                                               ; preds = %52, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %54 = load i1, ptr %3, align 1
  ret i1 %54
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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 uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode0_2EjPKvPNS_10color_rgbaE(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu20unpack_bc7_mode1_3_7EjPKvPNS_10color_rgbaE(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode4_5EjPKvPNS_10color_rgbaE(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu16unpack_bc7_mode6EPKvPNS_10color_rgbaE(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6basisu10unpack_bc7EPKvPNS_10color_rgbaE(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i8, ptr %0, align 1, !tbaa !5
  %4 = zext i8 %3 to i32
  %5 = and i32 %4, 1
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %14, label %6

6:                                                ; preds = %2, %16
  %.01822.lcssa.ph30 = phi i32 [ 2, %16 ], [ 0, %2 ]
  %7 = tail call noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode0_2EjPKvPNS_10color_rgbaE(i32 noundef %.01822.lcssa.ph30, ptr noundef nonnull %0, ptr noundef %1)
  br label %.loopexit

8:                                                ; preds = %14, %18, %26
  %.01822.lcssa.ph = phi i32 [ 7, %26 ], [ 3, %18 ], [ 1, %14 ]
  %9 = tail call noundef zeroext i1 @_ZN6basisu20unpack_bc7_mode1_3_7EjPKvPNS_10color_rgbaE(i32 noundef %.01822.lcssa.ph, ptr noundef nonnull %0, ptr noundef %1)
  br label %.loopexit

10:                                               ; preds = %20, %22
  %.01822.lcssa.ph35 = phi i32 [ 5, %22 ], [ 4, %20 ]
  %11 = tail call noundef zeroext i1 @_ZN6basisu18unpack_bc7_mode4_5EjPKvPNS_10color_rgbaE(i32 noundef %.01822.lcssa.ph35, ptr noundef nonnull %0, ptr noundef %1)
  br label %.loopexit

12:                                               ; preds = %24
  %13 = tail call noundef zeroext i1 @_ZN6basisu16unpack_bc7_mode6EPKvPNS_10color_rgbaE(ptr noundef nonnull %0, ptr noundef %1)
  br label %.loopexit

14:                                               ; preds = %2
  %15 = and i32 %4, 2
  %.not.1 = icmp eq i32 %15, 0
  br i1 %.not.1, label %16, label %8

16:                                               ; preds = %14
  %17 = and i32 %4, 4
  %.not.2 = icmp eq i32 %17, 0
  br i1 %.not.2, label %18, label %6

18:                                               ; preds = %16
  %19 = and i32 %4, 8
  %.not.3 = icmp eq i32 %19, 0
  br i1 %.not.3, label %20, label %8

20:                                               ; preds = %18
  %21 = and i32 %4, 16
  %.not.4 = icmp eq i32 %21, 0
  br i1 %.not.4, label %22, label %10

22:                                               ; preds = %20
  %23 = and i32 %4, 32
  %.not.5 = icmp eq i32 %23, 0
  br i1 %.not.5, label %24, label %10

24:                                               ; preds = %22
  %25 = and i32 %4, 64
  %.not.6 = icmp eq i32 %25, 0
  br i1 %.not.6, label %26, label %12

26:                                               ; preds = %24
  %.not.7 = icmp eq i8 %3, 0
  br i1 %.not.7, label %.loopexit, label %8

.loopexit:                                        ; preds = %26, %12, %10, %8, %6
  %27 = phi i1 [ true, %12 ], [ true, %10 ], [ true, %8 ], [ true, %6 ], [ false, %26 ]
  %.019 = phi i1 [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ undef, %26 ]
  %spec.select = and i1 %27, %.019
  ret i1 %spec.select
}

attributes #0 = { mustprogress 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++ TBAA"}


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