; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RGBD/RGBDCamera.ll (ZN10RGBDCamera24SetUndistortedParametersEv)

; 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.RGBDCamera = type <{ i32, i32, i32, i32, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, %class.R4Matrix, ptr, ptr, ptr, ptr, i32, i32, i32, [4 x i8] }>
%class.R4Matrix = type { [4 x [4 x double]] }

@RN_EPSILON = external global double, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10RGBDCamera24SetUndistortedParametersEv(ptr noundef nonnull align 8 dereferenceable(348) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 8
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 9
  store double 0.000000e+00, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 10
  store double 0.000000e+00, ptr %8, align 8, !tbaa !15
  %9 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 11
  store double 0.000000e+00, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 12
  store double 0.000000e+00, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 13
  store double 0.000000e+00, ptr %11, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %12 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !19
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %23

15:                                               ; preds = %1
  %16 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !20
  %18 = sitofp i32 %17 to double
  %19 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !19
  %21 = sitofp i32 %20 to double
  %22 = fdiv double %18, %21
  br label %24

23:                                               ; preds = %1
  br label %24

24:                                               ; preds = %23, %15
  %25 = phi double [ %22, %15 ], [ 1.000000e+00, %23 ]
  store double %25, ptr %3, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %26 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 3
  %27 = load i32, ptr %26, align 4, !tbaa !22
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %37

29:                                               ; preds = %24
  %30 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !23
  %32 = sitofp i32 %31 to double
  %33 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 3
  %34 = load i32, ptr %33, align 4, !tbaa !22
  %35 = sitofp i32 %34 to double
  %36 = fdiv double %32, %35
  br label %38

37:                                               ; preds = %24
  br label %38

38:                                               ; preds = %37, %29
  %39 = phi double [ %36, %29 ], [ 1.000000e+00, %37 ]
  store double %39, ptr %4, align 8, !tbaa !21
  %40 = load double, ptr %3, align 8, !tbaa !21
  %41 = load double, ptr @RN_EPSILON, align 8, !tbaa !21
  %42 = call noundef i32 @_Z12RNIsNotEqualddd(double noundef %40, double noundef 1.000000e+00, double noundef %41)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %49

44:                                               ; preds = %38
  %45 = load double, ptr %3, align 8, !tbaa !21
  %46 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 14
  %47 = load double, ptr %46, align 8, !tbaa !24
  %48 = fmul double %47, %45
  store double %48, ptr %46, align 8, !tbaa !24
  br label %49

49:                                               ; preds = %44, %38
  %50 = load double, ptr %4, align 8, !tbaa !21
  %51 = load double, ptr @RN_EPSILON, align 8, !tbaa !21
  %52 = call noundef i32 @_Z12RNIsNotEqualddd(double noundef %50, double noundef 1.000000e+00, double noundef %51)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %59

54:                                               ; preds = %49
  %55 = load double, ptr %4, align 8, !tbaa !21
  %56 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 15
  %57 = load double, ptr %56, align 8, !tbaa !25
  %58 = fmul double %57, %55
  store double %58, ptr %56, align 8, !tbaa !25
  br label %59

59:                                               ; preds = %54, %49
  %60 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !20
  %62 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 2
  store i32 %61, ptr %62, align 8, !tbaa !19
  %63 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !23
  %65 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 3
  store i32 %64, ptr %65, align 4, !tbaa !22
  %66 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 6
  %67 = load double, ptr %66, align 8, !tbaa !26
  %68 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 16
  store double %67, ptr %68, align 8, !tbaa !27
  %69 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 7
  %70 = load double, ptr %69, align 8, !tbaa !28
  %71 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 17
  store double %70, ptr %71, align 8, !tbaa !29
  %72 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 8
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 18
  store double %73, ptr %74, align 8, !tbaa !30
  %75 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 9
  %76 = load double, ptr %75, align 8, !tbaa !14
  %77 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 19
  store double %76, ptr %77, align 8, !tbaa !31
  %78 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 10
  %79 = load double, ptr %78, align 8, !tbaa !15
  %80 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 20
  store double %79, ptr %80, align 8, !tbaa !32
  %81 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 11
  %82 = load double, ptr %81, align 8, !tbaa !16
  %83 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 21
  store double %82, ptr %83, align 8, !tbaa !33
  %84 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 12
  %85 = load double, ptr %84, align 8, !tbaa !17
  %86 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 22
  store double %85, ptr %86, align 8, !tbaa !34
  %87 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 13
  %88 = load double, ptr %87, align 8, !tbaa !18
  %89 = getelementptr inbounds %class.RGBDCamera, ptr %5, i32 0, i32 23
  store double %88, ptr %89, align 8, !tbaa !35
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z12RNIsNotEqualddd(double noundef, double noundef, double noundef) #2

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 48}
!10 = !{!"_ZTS10RGBDCamera", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !13, i64 176, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !11, i64 336, !11, i64 340, !11, i64 344}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTS8R4Matrix", !7, i64 0}
!14 = !{!10, !12, i64 56}
!15 = !{!10, !12, i64 64}
!16 = !{!10, !12, i64 72}
!17 = !{!10, !12, i64 80}
!18 = !{!10, !12, i64 88}
!19 = !{!10, !11, i64 8}
!20 = !{!10, !11, i64 0}
!21 = !{!12, !12, i64 0}
!22 = !{!10, !11, i64 12}
!23 = !{!10, !11, i64 4}
!24 = !{!10, !12, i64 96}
!25 = !{!10, !12, i64 104}
!26 = !{!10, !12, i64 32}
!27 = !{!10, !12, i64 112}
!28 = !{!10, !12, i64 40}
!29 = !{!10, !12, i64 120}
!30 = !{!10, !12, i64 128}
!31 = !{!10, !12, i64 136}
!32 = !{!10, !12, i64 144}
!33 = !{!10, !12, i64 152}
!34 = !{!10, !12, i64 160}
!35 = !{!10, !12, i64 168}


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

@RN_EPSILON = external local_unnamed_addr global double, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10RGBDCamera24SetUndistortedParametersEv(ptr nocapture noundef nonnull align 8 dereferenceable(348) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %2, i8 0, i64 48, i1 false)
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 0
  %6 = load i32, ptr %0, align 8
  %7 = sitofp i32 %6 to double
  %8 = fdiv double %7, 0.000000e+00
  %9 = select i1 %5, double %8, double 1.000000e+00
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = icmp eq i32 %11, 0
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  %14 = load i32, ptr %13, align 4
  %15 = sitofp i32 %14 to double
  %16 = fdiv double %15, 0.000000e+00
  %17 = select i1 %12, double %16, double 1.000000e+00
  %18 = load double, ptr @RN_EPSILON, align 8, !tbaa !14
  %19 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %9, double noundef 1.000000e+00, double noundef %18)
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %24, label %20

20:                                               ; preds = %1
  %21 = getelementptr inbounds i8, ptr %0, i64 96
  %22 = load double, ptr %21, align 8, !tbaa !15
  %23 = fmul double %9, %22
  store double %23, ptr %21, align 8, !tbaa !15
  br label %24

24:                                               ; preds = %20, %1
  %25 = load double, ptr @RN_EPSILON, align 8, !tbaa !14
  %26 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %17, double noundef 1.000000e+00, double noundef %25)
  %.not6 = icmp eq i32 %26, 0
  br i1 %.not6, label %31, label %27

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %0, i64 104
  %29 = load double, ptr %28, align 8, !tbaa !16
  %30 = fmul double %17, %29
  store double %30, ptr %28, align 8, !tbaa !16
  br label %31

31:                                               ; preds = %27, %24
  %32 = getelementptr inbounds i8, ptr %0, i64 80
  %33 = getelementptr inbounds i8, ptr %0, i64 64
  %34 = load <2 x i32>, ptr %0, align 8, !tbaa !17
  store <2 x i32> %34, ptr %3, align 8, !tbaa !17
  %35 = getelementptr inbounds i8, ptr %0, i64 32
  %36 = getelementptr inbounds i8, ptr %0, i64 112
  %37 = load <2 x double>, ptr %35, align 8, !tbaa !14
  store <2 x double> %37, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %0, i64 128
  %39 = load <2 x double>, ptr %2, align 8, !tbaa !14
  store <2 x double> %39, ptr %38, align 8, !tbaa !14
  %40 = getelementptr inbounds i8, ptr %0, i64 144
  %41 = load <2 x double>, ptr %33, align 8, !tbaa !14
  store <2 x double> %41, ptr %40, align 8, !tbaa !14
  %42 = getelementptr inbounds i8, ptr %0, i64 160
  %43 = load <2 x double>, ptr %32, align 8, !tbaa !14
  store <2 x double> %43, ptr %42, align 8, !tbaa !14
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z12RNIsNotEqualddd(double noundef, double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

!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, !7, i64 8}
!6 = !{!"_ZTS10RGBDCamera", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !11, i64 176, !12, i64 304, !12, i64 312, !12, i64 320, !12, i64 328, !7, i64 336, !7, i64 340, !7, i64 344}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTS8R4Matrix", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !7, i64 12}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !10, i64 96}
!16 = !{!6, !10, i64 104}
!17 = !{!7, !7, i64 0}


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