; 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.20 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder15end_nonzero_runERNS_6vectorItEERjj = external hidden unnamed_addr constant [87 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: mustprogress uwtable
define dso_local void @_ZN6basisu13bitwise_coder15end_nonzero_runERNS_6vectorItEERjj(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i16, align 2
  %8 = alloca i16, align 2
  %9 = alloca i16, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %63

13:                                               ; preds = %3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp ult i32 %15, 3
  br i1 %16, label %17, label %28

17:                                               ; preds = %13
  br label %18

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

23:                                               ; preds = %18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #4
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = trunc i32 %25 to i16
  store i16 %26, ptr %7, align 2, !tbaa !11
  call void @_ZN6basisu6vectorItE9push_backERKt(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 2 dereferenceable(2) %7)
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #4
  br label %18, !llvm.loop !13

27:                                               ; preds = %18
  br label %62

28:                                               ; preds = %13
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = icmp ule i32 %30, 6
  br i1 %31, label %32, label %40

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

40:                                               ; preds = %28
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = icmp uge i32 %42, 7
  br i1 %43, label %44, label %48

44:                                               ; preds = %40
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = icmp ule i32 %46, 134
  br label %48

48:                                               ; preds = %44, %40
  %49 = phi i1 [ false, %40 ], [ %47, %44 ]
  br i1 %49, label %50, label %51

50:                                               ; preds = %48
  br label %53

51:                                               ; preds = %48
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.4, i32 noundef 1040, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder15end_nonzero_runERNS_6vectorItEERjj) #5
  unreachable

52:                                               ; No predecessors!
  br label %53

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

61:                                               ; preds = %53, %32
  br label %62

62:                                               ; preds = %61, %27
  br label %63

63:                                               ; preds = %62, %3
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %64, align 4, !tbaa !9
  ret void
}

; 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)) #3 align 2

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 = { 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 = { 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 #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.20 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder15end_nonzero_runERNS_6vectorItEERjj = external hidden unnamed_addr constant [87 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: mustprogress uwtable
define dso_local void @_ZN6basisu13bitwise_coder15end_nonzero_runERNS_6vectorItEERjj(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr nocapture noundef nonnull align 4 dereferenceable(4) %1, i32 noundef %2) local_unnamed_addr #2 align 2 {
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  %6 = alloca i16, align 2
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %.loopexit, label %8

8:                                                ; preds = %3
  %9 = icmp ult i32 %7, 3
  br i1 %9, label %.preheader, label %14

.preheader:                                       ; preds = %8
  %10 = trunc i32 %2 to i16
  %11 = add nsw i32 %7, -1
  store i32 %11, ptr %1, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %.preheader, %12
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #4
  store i16 %10, 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
  %.pr = load i32, ptr %1, align 4, !tbaa !5
  %13 = add i32 %.pr, -1
  store i32 %13, ptr %1, align 4, !tbaa !5
  %.not13 = icmp eq i32 %.pr, 0
  br i1 %.not13, label %.loopexit, label %12, !llvm.loop !11

14:                                               ; preds = %8
  %15 = icmp ult i32 %7, 7
  br i1 %15, label %16, label %19

16:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5) #4
  %.tr12 = trunc nuw i32 %7 to i16
  %17 = shl nuw nsw i16 %.tr12, 6
  %18 = add nsw i16 %17, -173
  store i16 %18, 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

19:                                               ; preds = %14
  %20 = icmp ult i32 %7, 135
  br i1 %20, label %21, label %.critedge

.critedge:                                        ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.4, i32 noundef 1040, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu13bitwise_coder15end_nonzero_runERNS_6vectorItEERjj) #5
  unreachable

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

.loopexit:                                        ; preds = %12, %21, %16, %3
  store i32 0, ptr %1, align 4, !tbaa !5
  ret void
}

; 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 #3 align 2

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 = { 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 = { 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 #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,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass