; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RGBD (RGBDSurface)

; 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.RGBDSurface = type { ptr, ptr, i32, %class.RNArray, i32, i32, i32, ptr, ptr, %class.R2Box, i32, ptr, ptr, ptr }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Point = type { [2 x double] }

; 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 uwtable
declare dso_local noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK11RGBDSurface25TransformSurfaceToTextureERK7R2PointRS0_(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) unnamed_addr #3 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %12 = getelementptr inbounds %class.RGBDSurface, ptr %11, i32 0, i32 9
  %13 = call noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %12)
  store double %13, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %14 = getelementptr inbounds %class.RGBDSurface, ptr %11, i32 0, i32 9
  %15 = call noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %14)
  store double %15, ptr %9, align 8, !tbaa !9
  %16 = load double, ptr %8, align 8, !tbaa !9
  %17 = fcmp oeq double %16, 0.000000e+00
  br i1 %17, label %21, label %18

18:                                               ; preds = %3
  %19 = load double, ptr %9, align 8, !tbaa !9
  %20 = fcmp oeq double %19, 0.000000e+00
  br i1 %20, label %21, label %22

21:                                               ; preds = %18, %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %51

22:                                               ; preds = %18
  %23 = getelementptr inbounds %class.RGBDSurface, ptr %11, i32 0, i32 4
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = sitofp i32 %24 to double
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %26, i32 noundef 0)
  %28 = getelementptr inbounds %class.RGBDSurface, ptr %11, i32 0, i32 9
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK5R2BoxixEi(ptr noundef nonnull align 8 dereferenceable(40) %28, i32 noundef 0)
  %30 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %29, i32 noundef 0)
  %31 = fsub double %27, %30
  %32 = fmul double %25, %31
  %33 = load double, ptr %8, align 8, !tbaa !9
  %34 = fdiv double %32, %33
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %35, i32 noundef 0)
  store double %34, ptr %36, align 8, !tbaa !9
  %37 = getelementptr inbounds %class.RGBDSurface, ptr %11, i32 0, i32 5
  %38 = load i32, ptr %37, align 4, !tbaa !20
  %39 = sitofp i32 %38 to double
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %40, i32 noundef 1)
  %42 = getelementptr inbounds %class.RGBDSurface, ptr %11, i32 0, i32 9
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK5R2BoxixEi(ptr noundef nonnull align 8 dereferenceable(40) %42, i32 noundef 0)
  %44 = call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %43, i32 noundef 1)
  %45 = fsub double %41, %44
  %46 = fmul double %39, %45
  %47 = load double, ptr %9, align 8, !tbaa !9
  %48 = fdiv double %46, %47
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %49, i32 noundef 1)
  store double %48, ptr %50, align 8, !tbaa !9
  store i32 1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %51

51:                                               ; preds = %22, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %52 = load i32, ptr %4, align 4
  ret i32 %52
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 40}
!12 = !{!"_ZTS11RGBDSurface", !6, i64 8, !13, i64 16, !14, i64 24, !13, i64 40, !13, i64 44, !13, i64 48, !6, i64 56, !6, i64 64, !16, i64 72, !13, i64 112, !6, i64 120, !6, i64 128, !6, i64 136}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS7RNArrayIP6R2GridE", !15, i64 0}
!15 = !{!"_ZTS8RNVArray", !6, i64 0, !13, i64 8, !13, i64 12}
!16 = !{!"_ZTS5R2Box", !17, i64 0, !19, i64 8, !19, i64 24}
!17 = !{!"_ZTS7R2Solid", !18, i64 0}
!18 = !{!"_ZTS7R2Shape"}
!19 = !{!"_ZTS7R2Point", !7, i64 0}
!20 = !{!12, !13, i64 44}


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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK11RGBDSurface25TransformSurfaceToTextureERK7R2PointRS0_(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) unnamed_addr #2 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = tail call noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %4)
  %6 = tail call noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %4)
  %7 = fcmp oeq double %5, 0.000000e+00
  %8 = fcmp oeq double %6, 0.000000e+00
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %30, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = sitofp i32 %11 to double
  %13 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 0)
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK5R2BoxixEi(ptr noundef nonnull align 8 dereferenceable(40) %4, i32 noundef 0)
  %15 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %14, i32 noundef 0)
  %16 = fsub double %13, %15
  %17 = fmul double %16, %12
  %18 = fdiv double %17, %5
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef 0)
  store double %18, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %0, i64 44
  %21 = load i32, ptr %20, align 4, !tbaa !19
  %22 = sitofp i32 %21 to double
  %23 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef 1)
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK5R2BoxixEi(ptr noundef nonnull align 8 dereferenceable(40) %4, i32 noundef 0)
  %25 = tail call noundef double @_ZNK7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %24, i32 noundef 1)
  %26 = fsub double %23, %25
  %27 = fmul double %26, %22
  %28 = fdiv double %27, %6
  %29 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R2PointixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef 1)
  store double %28, ptr %29, align 8, !tbaa !17
  br label %30

30:                                               ; preds = %3, %9
  %.0 = phi i32 [ 1, %9 ], [ 0, %3 ]
  ret i32 %.0
}

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

!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, !10, i64 40}
!6 = !{!"_ZTS11RGBDSurface", !7, i64 8, !10, i64 16, !11, i64 24, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !7, i64 64, !13, i64 72, !10, i64 112, !7, i64 120, !7, i64 128, !7, i64 136}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS7RNArrayIP6R2GridE", !12, i64 0}
!12 = !{!"_ZTS8RNVArray", !7, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!"_ZTS5R2Box", !14, i64 0, !16, i64 8, !16, i64 24}
!14 = !{!"_ZTS7R2Solid", !15, i64 0}
!15 = !{!"_ZTS7R2Shape"}
!16 = !{!"_ZTS7R2Point", !8, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !8, i64 0}
!19 = !{!6, !10, i64 44}


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