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

; 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.4 = external hidden unnamed_addr constant [110 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder12end_zero_runERNS_6vectorItEERj = external hidden unnamed_addr constant [74 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 2 dereferenceable(2)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu13bitwise_coder12end_zero_runERNS_6vectorItEERj(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca i16, align 2
  %7 = alloca i16, align 2
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %59

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = icmp ult i32 %13, 3
  br i1 %14, label %15, label %24

15:                                               ; preds = %11
  br label %16

16:                                               ; preds = %21, %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = add i32 %18, -1
  store i32 %19, ptr %17, align 4, !tbaa !9
  %20 = icmp ne i32 %18, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %16
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #4
  store i16 0, ptr %5, align 2, !tbaa !11
  call void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 2 dereferenceable(2) %5)
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #4
  br label %16, !llvm.loop !13

23:                                               ; preds = %16
  br label %58

24:                                               ; preds = %11
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = icmp ule i32 %26, 10
  br i1 %27, label %28, label %36

28:                                               ; preds = %24
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #4
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = sub i32 %31, 3
  %33 = shl i32 %32, 6
  %34 = or i32 17, %33
  %35 = trunc i32 %34 to i16
  store i16 %35, ptr %6, align 2, !tbaa !11
  call void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 2 dereferenceable(2) %6)
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #4
  br label %57

36:                                               ; preds = %24
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = icmp uge i32 %38, 11
  br i1 %39, label %40, label %44

40:                                               ; preds = %36
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = icmp ule i32 %42, 138
  br label %44

44:                                               ; preds = %40, %36
  %45 = phi i1 [ false, %36 ], [ %43, %40 ]
  br i1 %45, label %46, label %47

46:                                               ; preds = %44
  br label %49

47:                                               ; preds = %44
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.4, i32 noundef 1063, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder12end_zero_runERNS_6vectorItEERj) #5
  unreachable

48:                                               ; No predecessors!
  br label %49

49:                                               ; preds = %48, %46
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #4
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = sub i32 %52, 11
  %54 = shl i32 %53, 6
  %55 = or i32 18, %54
  %56 = trunc i32 %55 to i16
  store i16 %56, ptr %7, align 2, !tbaa !11
  call void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16) %50, ptr noundef nonnull align 2 dereferenceable(2) %7)
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #4
  br label %57

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

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

59:                                               ; preds = %58, %2
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %60, align 4, !tbaa !9
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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.4 = external hidden unnamed_addr constant [110 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [83 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder12end_zero_runERNS_6vectorItEERj = external hidden unnamed_addr constant [74 x i8], align 1

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 2 dereferenceable(2)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu13bitwise_coder12end_zero_runERNS_6vectorItEERj(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr nocapture noundef nonnull align 4 dereferenceable(4) %1) local_unnamed_addr #3 align 2 {
  %3 = alloca i16, align 2
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.loopexit, label %7

7:                                                ; preds = %2
  %8 = icmp ult i32 %6, 3
  br i1 %8, label %.preheader, label %12

.preheader:                                       ; preds = %7
  %9 = add nsw i32 %6, -1
  store i32 %9, ptr %1, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %.preheader, %10
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #4
  store i16 0, ptr %3, align 2, !tbaa !9
  call void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 2 dereferenceable(2) %3)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #4
  %.pr = load i32, ptr %1, align 4, !tbaa !5
  %11 = add i32 %.pr, -1
  store i32 %11, ptr %1, align 4, !tbaa !5
  %.not13 = icmp eq i32 %.pr, 0
  br i1 %.not13, label %.loopexit, label %10, !llvm.loop !11

12:                                               ; preds = %7
  %13 = icmp ult i32 %6, 11
  br i1 %13, label %14, label %17

14:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #4
  %.tr12 = trunc nuw i32 %6 to i16
  %15 = shl nuw nsw i16 %.tr12, 6
  %16 = add nsw i16 %15, -175
  store i16 %16, ptr %4, align 2, !tbaa !9
  call void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 2 dereferenceable(2) %4)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #4
  br label %.loopexit

17:                                               ; preds = %12
  %18 = icmp ult i32 %6, 139
  br i1 %18, label %19, label %.critedge

.critedge:                                        ; preds = %17
  tail call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.4, i32 noundef 1063, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder12end_zero_runERNS_6vectorItEERj) #5
  unreachable

19:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5) #4
  %.tr = trunc nuw i32 %6 to i16
  %20 = shl nuw nsw i16 %.tr, 6
  %21 = add nsw i16 %20, -686
  store i16 %21, ptr %5, align 2, !tbaa !9
  call void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 2 dereferenceable(2) %5)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #4
  br label %.loopexit

.loopexit:                                        ; preds = %10, %19, %14, %2
  store i32 0, ptr %1, align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass