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

; 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::vec" = type { [4 x float] }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu6imagef9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu6imagef10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu3vecILj4EfEC2Effff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef, float noundef) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu3vecILj4EfE3setEffff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef, float noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN6basisu6imagef6resizeERKS0_jRKNS_3vecILj4EfEE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, ptr noundef nonnull align 4 dereferenceable(16)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNK6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu9add_imageERKNS_6imagefES2_RS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.basisu::vec", align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  call void @_ZN6basisu3vecILj4EfEC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %7, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %15 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN6basisu6imagef6resizeERKS0_jRKNS_3vecILj4EfEE(ptr noundef nonnull align 8 dereferenceable(32) %13, ptr noundef nonnull align 8 dereferenceable(32) %14, i32 noundef -1, ptr noundef nonnull align 4 dereferenceable(16) %7)
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %67, %3
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef i32 @_ZNK6basisu6imagef10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  %20 = icmp slt i32 %17, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %16
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %70

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %63, %22
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = call noundef i32 @_ZNK6basisu6imagef9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %25)
  %27 = icmp ult i32 %24, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %23
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %66

29:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNK6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32) %30, i32 noundef %31, i32 noundef %32)
  store ptr %33, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNK6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32) %34, i32 noundef %35, i32 noundef %36)
  store ptr %37, ptr %12, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32) %38, i32 noundef %39, i32 noundef %40)
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %42, i32 noundef 0)
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %44, i32 noundef 0)
  %46 = fadd float %43, %45
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %47, i32 noundef 1)
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %49, i32 noundef 1)
  %51 = fadd float %48, %50
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %52, i32 noundef 2)
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %54, i32 noundef 2)
  %56 = fadd float %53, %55
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %57, i32 noundef 3)
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %59, i32 noundef 3)
  %61 = fadd float %58, %60
  %62 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu3vecILj4EfE3setEffff(ptr noundef nonnull align 4 dereferenceable(16) %41, float noundef %46, float noundef %51, float noundef %56, float noundef %61)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %63

63:                                               ; preds = %29
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = add i32 %64, 1
  store i32 %65, ptr %10, align 4, !tbaa !9
  br label %23, !llvm.loop !11

66:                                               ; preds = %28
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %8, align 4, !tbaa !9
  br label %16, !llvm.loop !13

70:                                               ; preds = %21
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

%"class.basisu::vec" = type { [4 x float] }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu6imagef9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu6imagef10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu3vecILj4EfEC2Effff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef, float noundef) unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu3vecILj4EfE3setEffff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN6basisu6imagef6resizeERKS0_jRKNS_3vecILj4EfEE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(16) ptr @_ZNK6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu9add_imageERKNS_6imagefES2_RS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) local_unnamed_addr #3 {
  %4 = alloca %"class.basisu::vec", align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @_ZN6basisu3vecILj4EfEC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %4, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %5 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN6basisu6imagef6resizeERKS0_jRKNS_3vecILj4EfEE(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef -1, ptr noundef nonnull align 4 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  %6 = call noundef i32 @_ZNK6basisu6imagef10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader, label %._crit_edge27

.preheader:                                       ; preds = %3, %._crit_edge
  %.026 = phi i32 [ %9, %._crit_edge ], [ 0, %3 ]
  %8 = call noundef i32 @_ZNK6basisu6imagef9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge27:                                    ; preds = %._crit_edge, %3
  ret void

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %9 = add nuw nsw i32 %.026, 1
  %10 = call noundef i32 @_ZNK6basisu6imagef10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.preheader, label %._crit_edge27, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.02425 = phi i32 [ %28, %.lr.ph ], [ 0, %.preheader ]
  %12 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNK6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %.02425, i32 noundef %.026)
  %13 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZNK6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %.02425, i32 noundef %.026)
  %14 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu6imagefclEjj(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef %.02425, i32 noundef %.026)
  %15 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %12, i32 noundef 0)
  %16 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %13, i32 noundef 0)
  %17 = fadd float %15, %16
  %18 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %12, i32 noundef 1)
  %19 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %13, i32 noundef 1)
  %20 = fadd float %18, %19
  %21 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %12, i32 noundef 2)
  %22 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %13, i32 noundef 2)
  %23 = fadd float %21, %22
  %24 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %12, i32 noundef 3)
  %25 = call noundef float @_ZNK6basisu3vecILj4EfEixEj(ptr noundef nonnull align 4 dereferenceable(16) %13, i32 noundef 3)
  %26 = fadd float %24, %25
  %27 = call noundef nonnull align 4 dereferenceable(16) ptr @_ZN6basisu3vecILj4EfE3setEffff(ptr noundef nonnull align 4 dereferenceable(16) %14, float noundef %17, float noundef %20, float noundef %23, float noundef %26)
  %28 = add nuw i32 %.02425, 1
  %29 = call noundef i32 @_ZNK6basisu6imagef9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %30 = icmp ult i32 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !7
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 }

!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"}
!7 = distinct !{!7, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass