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

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

%"class.basisu::color_rgba" = type { %union.anon }
%union.anon = type { [4 x i8] }

@.str.3 = external hidden unnamed_addr constant [110 x i8], align 1
@_ZN6basisu19g_etc1_inten_tablesE = external dso_local constant [8 x [4 x i32]], align 16
@.str.8 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu9etc_block24get_diff_subblock_colorsEPNS_10color_rgbaEttj = external hidden unnamed_addr constant [100 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
declare dso_local noundef zeroext i1 @_ZN6basisu9etc_block13unpack_color5ERjS1_S1_ttbj(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), i16 noundef zeroext, i16 noundef zeroext, i1 noundef zeroext, i32 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4), i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3 align 2

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

23:                                               ; preds = %4
  br label %26

24:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.3, i32 noundef 542, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu9etc_block24get_diff_subblock_colorsEPNS_10color_rgbaEttj) #4
  unreachable

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25, %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %27 = load i32, ptr %8, align 4, !tbaa !11
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds [8 x [4 x i32]], ptr @_ZN6basisu19g_etc1_inten_tablesE, i64 0, i64 %28
  %30 = getelementptr inbounds [4 x i32], ptr %29, i64 0, i64 0
  store ptr %30, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #5
  %31 = load i16, ptr %6, align 2, !tbaa !9
  %32 = load i16, ptr %7, align 2, !tbaa !9
  %33 = call noundef zeroext i1 @_ZN6basisu9etc_block13unpack_color5ERjS1_S1_ttbj(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12, i16 noundef zeroext %31, i16 noundef zeroext %32, i1 noundef zeroext true, i32 noundef 255)
  %34 = zext i1 %33 to i8
  store i8 %34, ptr %13, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %35 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %35, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %36 = load i32, ptr %11, align 4, !tbaa !11
  store i32 %36, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %37 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %37, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds i32, ptr %38, i64 0
  %40 = load i32, ptr %39, align 4, !tbaa !11
  store i32 %40, ptr %17, align 4, !tbaa !11
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.basisu::color_rgba", ptr %41, i64 0
  %43 = load i32, ptr %14, align 4, !tbaa !11
  %44 = load i32, ptr %17, align 4, !tbaa !11
  %45 = add nsw i32 %43, %44
  %46 = load i32, ptr %15, align 4, !tbaa !11
  %47 = load i32, ptr %17, align 4, !tbaa !11
  %48 = add nsw i32 %46, %47
  %49 = load i32, ptr %16, align 4, !tbaa !11
  %50 = load i32, ptr %17, align 4, !tbaa !11
  %51 = add nsw i32 %49, %50
  %52 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %42, i32 noundef %45, i32 noundef %48, i32 noundef %51, i32 noundef 255)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds i32, ptr %53, i64 1
  %55 = load i32, ptr %54, align 4, !tbaa !11
  store i32 %55, ptr %18, align 4, !tbaa !11
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.basisu::color_rgba", ptr %56, i64 1
  %58 = load i32, ptr %14, align 4, !tbaa !11
  %59 = load i32, ptr %18, align 4, !tbaa !11
  %60 = add nsw i32 %58, %59
  %61 = load i32, ptr %15, align 4, !tbaa !11
  %62 = load i32, ptr %18, align 4, !tbaa !11
  %63 = add nsw i32 %61, %62
  %64 = load i32, ptr %16, align 4, !tbaa !11
  %65 = load i32, ptr %18, align 4, !tbaa !11
  %66 = add nsw i32 %64, %65
  %67 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %57, i32 noundef %60, i32 noundef %63, i32 noundef %66, i32 noundef 255)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds i32, ptr %68, i64 2
  %70 = load i32, ptr %69, align 4, !tbaa !11
  store i32 %70, ptr %19, align 4, !tbaa !11
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %"class.basisu::color_rgba", ptr %71, i64 2
  %73 = load i32, ptr %14, align 4, !tbaa !11
  %74 = load i32, ptr %19, align 4, !tbaa !11
  %75 = add nsw i32 %73, %74
  %76 = load i32, ptr %15, align 4, !tbaa !11
  %77 = load i32, ptr %19, align 4, !tbaa !11
  %78 = add nsw i32 %76, %77
  %79 = load i32, ptr %16, align 4, !tbaa !11
  %80 = load i32, ptr %19, align 4, !tbaa !11
  %81 = add nsw i32 %79, %80
  %82 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %72, i32 noundef %75, i32 noundef %78, i32 noundef %81, i32 noundef 255)
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = getelementptr inbounds i32, ptr %83, i64 3
  %85 = load i32, ptr %84, align 4, !tbaa !11
  store i32 %85, ptr %20, align 4, !tbaa !11
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %"class.basisu::color_rgba", ptr %86, i64 3
  %88 = load i32, ptr %14, align 4, !tbaa !11
  %89 = load i32, ptr %20, align 4, !tbaa !11
  %90 = add nsw i32 %88, %89
  %91 = load i32, ptr %15, align 4, !tbaa !11
  %92 = load i32, ptr %20, align 4, !tbaa !11
  %93 = add nsw i32 %91, %92
  %94 = load i32, ptr %16, align 4, !tbaa !11
  %95 = load i32, ptr %20, align 4, !tbaa !11
  %96 = add nsw i32 %94, %95
  %97 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %87, i32 noundef %90, i32 noundef %93, i32 noundef %96, i32 noundef 255)
  %98 = load i8, ptr %13, align 1, !tbaa !13, !range !15, !noundef !16
  %99 = trunc i8 %98 to i1
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #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 8, ptr %9) #5
  ret i1 %99
}

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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
@_ZN6basisu19g_etc1_inten_tablesE = external dso_local local_unnamed_addr constant [8 x [4 x i32]], align 16
@.str.8 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu9etc_block24get_diff_subblock_colorsEPNS_10color_rgbaEttj = external hidden unnamed_addr constant [100 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
declare dso_local noundef zeroext i1 @_ZN6basisu9etc_block13unpack_color5ERjS1_S1_ttbj(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), i16 noundef zeroext, i16 noundef zeroext, i1 noundef zeroext, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4), i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6basisu9etc_block24get_diff_subblock_colorsEPNS_10color_rgbaEttj(ptr noundef %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i32 noundef %3) local_unnamed_addr #2 align 2 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = icmp ult i32 %3, 8
  br i1 %8, label %10, label %9

9:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.3, i32 noundef 542, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu9etc_block24get_diff_subblock_colorsEPNS_10color_rgbaEttj) #4
  unreachable

10:                                               ; preds = %4
  %11 = zext nneg i32 %3 to i64
  %12 = getelementptr inbounds [8 x [4 x i32]], ptr @_ZN6basisu19g_etc1_inten_tablesE, i64 0, i64 %11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %13 = call noundef zeroext i1 @_ZN6basisu9etc_block13unpack_color5ERjS1_S1_ttbj(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7, i16 noundef zeroext %1, i16 noundef zeroext %2, i1 noundef zeroext true, i32 noundef 255)
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %12, align 16, !tbaa !5
  %18 = add nsw i32 %17, %14
  %19 = add nsw i32 %17, %15
  %20 = add nsw i32 %17, %16
  %21 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %0, i32 noundef %18, i32 noundef %19, i32 noundef %20, i32 noundef 255)
  %22 = getelementptr inbounds i8, ptr %12, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 4
  %25 = add nsw i32 %23, %14
  %26 = add nsw i32 %23, %15
  %27 = add nsw i32 %23, %16
  %28 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %24, i32 noundef %25, i32 noundef %26, i32 noundef %27, i32 noundef 255)
  %29 = getelementptr inbounds i8, ptr %12, i64 8
  %30 = load i32, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %0, i64 8
  %32 = add nsw i32 %30, %14
  %33 = add nsw i32 %30, %15
  %34 = add nsw i32 %30, %16
  %35 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %31, i32 noundef %32, i32 noundef %33, i32 noundef %34, i32 noundef 255)
  %36 = getelementptr inbounds i8, ptr %12, i64 12
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %0, i64 12
  %39 = add nsw i32 %37, %14
  %40 = add nsw i32 %37, %15
  %41 = add nsw i32 %37, %16
  %42 = call noundef nonnull align 1 dereferenceable(4) ptr @_ZN6basisu10color_rgba3setEiiii(ptr noundef nonnull align 1 dereferenceable(4) %38, i32 noundef %39, i32 noundef %40, i32 noundef %41, i32 noundef 255)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret i1 %13
}

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 = { 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"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass