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

; 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 [81 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [115 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu17pvrtc4_swizzle_uvEjjjj = external hidden unnamed_addr constant [75 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6basisu17pvrtc4_swizzle_uvEjjjj(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = icmp ult i32 %15, %16
  br i1 %17, label %18, label %28

18:                                               ; preds = %4
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = icmp ult i32 %19, %20
  br i1 %21, label %22, label %28

22:                                               ; preds = %18
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = call noundef zeroext i1 @_ZN6basisu7is_pow2Ej(i32 noundef %23)
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = call noundef zeroext i1 @_ZN6basisu7is_pow2Ej(i32 noundef %26)
  br label %28

28:                                               ; preds = %25, %22, %18, %4
  %29 = phi i1 [ false, %22 ], [ false, %18 ], [ false, %4 ], [ %27, %25 ]
  br i1 %29, label %30, label %31

30:                                               ; preds = %28
  br label %33

31:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.3, i32 noundef 133, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu17pvrtc4_swizzle_uvEjjjj) #4
  unreachable

32:                                               ; No predecessors!
  br label %33

33:                                               ; preds = %32, %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %34 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %34, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %35 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %35, ptr %10, align 4, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = icmp ult i32 %36, %37
  br i1 %38, label %39, label %42

39:                                               ; preds = %33
  %40 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %40, ptr %9, align 4, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %41, ptr %10, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %39, %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 1, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 1, ptr %14, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %68, %42
  %44 = load i32, ptr %13, align 4, !tbaa !5
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = icmp ult i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %75

48:                                               ; preds = %43
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = load i32, ptr %13, align 4, !tbaa !5
  %51 = and i32 %49, %50
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %57

53:                                               ; preds = %48
  %54 = load i32, ptr %14, align 4, !tbaa !5
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = or i32 %55, %54
  store i32 %56, ptr %12, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %53, %48
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = load i32, ptr %13, align 4, !tbaa !5
  %60 = and i32 %58, %59
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %67

62:                                               ; preds = %57
  %63 = load i32, ptr %14, align 4, !tbaa !5
  %64 = mul i32 2, %63
  %65 = load i32, ptr %12, align 4, !tbaa !5
  %66 = or i32 %65, %64
  store i32 %66, ptr %12, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %62, %57
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %13, align 4, !tbaa !5
  %70 = shl i32 %69, 1
  store i32 %70, ptr %13, align 4, !tbaa !5
  %71 = load i32, ptr %14, align 4, !tbaa !5
  %72 = shl i32 %71, 2
  store i32 %72, ptr %14, align 4, !tbaa !5
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = add i32 %73, 1
  store i32 %74, ptr %11, align 4, !tbaa !5
  br label %43, !llvm.loop !9

75:                                               ; preds = %47
  %76 = load i32, ptr %11, align 4, !tbaa !5
  %77 = load i32, ptr %10, align 4, !tbaa !5
  %78 = lshr i32 %77, %76
  store i32 %78, ptr %10, align 4, !tbaa !5
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = mul i32 2, %80
  %82 = shl i32 %79, %81
  %83 = load i32, ptr %12, align 4, !tbaa !5
  %84 = or i32 %83, %82
  store i32 %84, ptr %12, align 4, !tbaa !5
  %85 = load i32, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret i32 %85
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu7is_pow2Ej(i32 noundef) #1

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

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

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

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" }
attributes #1 = { inlinehint 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 "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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"}
!9 = distinct !{!9, !10}
!10 = !{!"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 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [115 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu17pvrtc4_swizzle_uvEjjjj = external hidden unnamed_addr constant [75 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN6basisu17pvrtc4_swizzle_uvEjjjj(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp ult i32 %2, %0
  %6 = icmp ult i32 %3, %1
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %7, label %.critedge

7:                                                ; preds = %4
  %8 = tail call noundef zeroext i1 @_ZN6basisu7is_pow2Ej(i32 noundef %1)
  br i1 %8, label %9, label %.critedge

9:                                                ; preds = %7
  %10 = tail call noundef zeroext i1 @_ZN6basisu7is_pow2Ej(i32 noundef %0)
  br i1 %10, label %11, label %.critedge

.critedge:                                        ; preds = %7, %4, %9
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, i32 noundef 133, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu17pvrtc4_swizzle_uvEjjjj) #4
  unreachable

11:                                               ; preds = %9
  %spec.select = tail call i32 @llvm.umin.i32(i32 %1, i32 %0)
  %12 = icmp ugt i32 %spec.select, 1
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %11
  %.033.lcssa = phi i32 [ 0, %11 ], [ %26, %.lr.ph ]
  %.032.lcssa = phi i32 [ 0, %11 ], [ %.2, %.lr.ph ]
  %13 = icmp ult i32 %1, %0
  %spec.select41 = select i1 %13, i32 %2, i32 %3
  %14 = lshr i32 %spec.select41, %.033.lcssa
  %15 = shl i32 %.033.lcssa, 1
  %16 = shl i32 %14, %15
  %17 = or i32 %16, %.032.lcssa
  ret i32 %17

.lr.ph:                                           ; preds = %11, %.lr.ph
  %.046 = phi i32 [ %25, %.lr.ph ], [ 1, %11 ]
  %.03145 = phi i32 [ %24, %.lr.ph ], [ 1, %11 ]
  %.03244 = phi i32 [ %.2, %.lr.ph ], [ 0, %11 ]
  %.03343 = phi i32 [ %26, %.lr.ph ], [ 0, %11 ]
  %18 = and i32 %.03145, %3
  %.not = icmp eq i32 %18, 0
  %19 = select i1 %.not, i32 0, i32 %.046
  %20 = and i32 %.03145, %2
  %.not40 = icmp eq i32 %20, 0
  %21 = shl i32 %.046, 1
  %22 = select i1 %.not40, i32 0, i32 %21
  %23 = or i32 %22, %.03244
  %.2 = or i32 %23, %19
  %24 = shl i32 %.03145, 1
  %25 = shl i32 %.046, 2
  %26 = add i32 %.03343, 1
  %27 = icmp ult i32 %24, %spec.select
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu7is_pow2Ej(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #3

attributes #0 = { 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 #1 = { inlinehint 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 "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass