; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Draw.ll (ZNK8R3Matrix4DrawEv)

; 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.R3Matrix = type { [3 x [3 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: mustprogress uwtable
define dso_local void @_ZNK8R3Matrix4DrawEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca [4 x [4 x double]], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 128, ptr %3) #3
  %5 = getelementptr inbounds %class.R3Matrix, ptr %4, i32 0, i32 0
  %6 = getelementptr inbounds [3 x [3 x double]], ptr %5, i64 0, i64 0
  %7 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 0
  %10 = getelementptr inbounds [4 x double], ptr %9, i64 0, i64 0
  store double %8, ptr %10, align 16, !tbaa !9
  %11 = getelementptr inbounds %class.R3Matrix, ptr %4, i32 0, i32 0
  %12 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 1
  %13 = getelementptr inbounds [3 x double], ptr %12, i64 0, i64 0
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 0
  %16 = getelementptr inbounds [4 x double], ptr %15, i64 0, i64 1
  store double %14, ptr %16, align 8, !tbaa !9
  %17 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 0
  %18 = getelementptr inbounds [4 x double], ptr %17, i64 0, i64 2
  store double 0.000000e+00, ptr %18, align 16, !tbaa !9
  %19 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 0
  %20 = getelementptr inbounds [4 x double], ptr %19, i64 0, i64 3
  store double 0.000000e+00, ptr %20, align 8, !tbaa !9
  %21 = getelementptr inbounds %class.R3Matrix, ptr %4, i32 0, i32 0
  %22 = getelementptr inbounds [3 x [3 x double]], ptr %21, i64 0, i64 0
  %23 = getelementptr inbounds [3 x double], ptr %22, i64 0, i64 1
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 1
  %26 = getelementptr inbounds [4 x double], ptr %25, i64 0, i64 0
  store double %24, ptr %26, align 16, !tbaa !9
  %27 = getelementptr inbounds %class.R3Matrix, ptr %4, i32 0, i32 0
  %28 = getelementptr inbounds [3 x [3 x double]], ptr %27, i64 0, i64 1
  %29 = getelementptr inbounds [3 x double], ptr %28, i64 0, i64 1
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 1
  %32 = getelementptr inbounds [4 x double], ptr %31, i64 0, i64 1
  store double %30, ptr %32, align 8, !tbaa !9
  %33 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 1
  %34 = getelementptr inbounds [4 x double], ptr %33, i64 0, i64 2
  store double 0.000000e+00, ptr %34, align 16, !tbaa !9
  %35 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 1
  %36 = getelementptr inbounds [4 x double], ptr %35, i64 0, i64 3
  store double 0.000000e+00, ptr %36, align 8, !tbaa !9
  %37 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 2
  %38 = getelementptr inbounds [4 x double], ptr %37, i64 0, i64 0
  store double 0.000000e+00, ptr %38, align 16, !tbaa !9
  %39 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 2
  %40 = getelementptr inbounds [4 x double], ptr %39, i64 0, i64 1
  store double 0.000000e+00, ptr %40, align 8, !tbaa !9
  %41 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 2
  %42 = getelementptr inbounds [4 x double], ptr %41, i64 0, i64 2
  store double 1.000000e+00, ptr %42, align 16, !tbaa !9
  %43 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 2
  %44 = getelementptr inbounds [4 x double], ptr %43, i64 0, i64 3
  store double 0.000000e+00, ptr %44, align 8, !tbaa !9
  %45 = getelementptr inbounds %class.R3Matrix, ptr %4, i32 0, i32 0
  %46 = getelementptr inbounds [3 x [3 x double]], ptr %45, i64 0, i64 0
  %47 = getelementptr inbounds [3 x double], ptr %46, i64 0, i64 2
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 3
  %50 = getelementptr inbounds [4 x double], ptr %49, i64 0, i64 0
  store double %48, ptr %50, align 16, !tbaa !9
  %51 = getelementptr inbounds %class.R3Matrix, ptr %4, i32 0, i32 0
  %52 = getelementptr inbounds [3 x [3 x double]], ptr %51, i64 0, i64 1
  %53 = getelementptr inbounds [3 x double], ptr %52, i64 0, i64 2
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 3
  %56 = getelementptr inbounds [4 x double], ptr %55, i64 0, i64 1
  store double %54, ptr %56, align 8, !tbaa !9
  %57 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 3
  %58 = getelementptr inbounds [4 x double], ptr %57, i64 0, i64 2
  store double 0.000000e+00, ptr %58, align 16, !tbaa !9
  %59 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 3
  %60 = getelementptr inbounds [4 x double], ptr %59, i64 0, i64 3
  store double 1.000000e+00, ptr %60, align 8, !tbaa !9
  %61 = getelementptr inbounds [4 x [4 x double]], ptr %3, i64 0, i64 0
  call void @glMultMatrixd(ptr noundef %61)
  call void @llvm.lifetime.end.p0(i64 128, ptr %3) #3
  ret void
}

declare void @glMultMatrixd(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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, !10, i64 0}
!10 = !{!"double", !7, i64 0}


; 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: 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: mustprogress uwtable
define dso_local void @_ZNK8R3Matrix4DrawEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca [4 x [4 x double]], align 16
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %2) #4
  %3 = load double, ptr %0, align 8, !tbaa !5
  store double %3, ptr %2, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  store double %5, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 32
  store double %9, ptr %10, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %2, i64 40
  store double %12, ptr %13, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %2, i64 48
  %15 = getelementptr inbounds i8, ptr %2, i64 80
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %14, i8 0, i64 32, i1 false)
  store <2 x double> <double 1.000000e+00, double 0.000000e+00>, ptr %15, align 16, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %2, i64 96
  store double %17, ptr %18, align 16, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %2, i64 104
  store double %20, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %2, i64 112
  store <2 x double> <double 0.000000e+00, double 1.000000e+00>, ptr %22, align 16, !tbaa !5
  call void @glMultMatrixd(ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %2) #4
  ret void
}

declare void @glMultMatrixd(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass