; LLVM IR from xboot/libcg :: src (cg)

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

%struct.cg_matrix_t = type { double, double, double, double, double, double }

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

; Function Attrs: nounwind
declare double @sin(double noundef) #1

; Function Attrs: nounwind
declare double @cos(double noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @cg_matrix_rotate(ptr noundef %0, double noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %15 = load double, ptr %4, align 8, !tbaa !9
  %16 = call double @sin(double noundef %15) #3
  store double %16, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %17 = load double, ptr %4, align 8, !tbaa !9
  %18 = call double @cos(double noundef %17) #3
  store double %18, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %19 = load double, ptr %6, align 8, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.cg_matrix_t, ptr %20, i32 0, i32 0
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = fmul double %19, %22
  store double %23, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %24 = load double, ptr %6, align 8, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.cg_matrix_t, ptr %25, i32 0, i32 1
  %27 = load double, ptr %26, align 8, !tbaa !13
  %28 = fmul double %24, %27
  store double %28, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %29 = load double, ptr %6, align 8, !tbaa !9
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.cg_matrix_t, ptr %30, i32 0, i32 2
  %32 = load double, ptr %31, align 8, !tbaa !14
  %33 = fmul double %29, %32
  store double %33, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %34 = load double, ptr %6, align 8, !tbaa !9
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.cg_matrix_t, ptr %35, i32 0, i32 3
  %37 = load double, ptr %36, align 8, !tbaa !15
  %38 = fmul double %34, %37
  store double %38, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %39 = load double, ptr %5, align 8, !tbaa !9
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.cg_matrix_t, ptr %40, i32 0, i32 0
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = fmul double %39, %42
  store double %43, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %44 = load double, ptr %5, align 8, !tbaa !9
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.cg_matrix_t, ptr %45, i32 0, i32 1
  %47 = load double, ptr %46, align 8, !tbaa !13
  %48 = fmul double %44, %47
  store double %48, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %49 = load double, ptr %5, align 8, !tbaa !9
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.cg_matrix_t, ptr %50, i32 0, i32 2
  %52 = load double, ptr %51, align 8, !tbaa !14
  %53 = fmul double %49, %52
  store double %53, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %54 = load double, ptr %5, align 8, !tbaa !9
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.cg_matrix_t, ptr %55, i32 0, i32 3
  %57 = load double, ptr %56, align 8, !tbaa !15
  %58 = fmul double %54, %57
  store double %58, ptr %14, align 8, !tbaa !9
  %59 = load double, ptr %7, align 8, !tbaa !9
  %60 = load double, ptr %13, align 8, !tbaa !9
  %61 = fadd double %59, %60
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.cg_matrix_t, ptr %62, i32 0, i32 0
  store double %61, ptr %63, align 8, !tbaa !11
  %64 = load double, ptr %8, align 8, !tbaa !9
  %65 = load double, ptr %14, align 8, !tbaa !9
  %66 = fadd double %64, %65
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.cg_matrix_t, ptr %67, i32 0, i32 1
  store double %66, ptr %68, align 8, !tbaa !13
  %69 = load double, ptr %9, align 8, !tbaa !9
  %70 = load double, ptr %11, align 8, !tbaa !9
  %71 = fsub double %69, %70
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.cg_matrix_t, ptr %72, i32 0, i32 2
  store double %71, ptr %73, align 8, !tbaa !14
  %74 = load double, ptr %10, align 8, !tbaa !9
  %75 = load double, ptr %12, align 8, !tbaa !9
  %76 = fsub double %74, %75
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.cg_matrix_t, ptr %77, i32 0, i32 3
  store double %76, ptr %78, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"cg_matrix_t", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}


; 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 nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @cg_matrix_rotate(ptr nocapture noundef %0, double noundef %1) local_unnamed_addr #1 {
  %3 = tail call double @sin(double noundef %1) #2
  %4 = tail call double @cos(double noundef %1) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %7 = insertelement <2 x double> poison, double %4, i64 0
  %8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
  %9 = fmul <2 x double> %8, %6
  %10 = load <2 x double>, ptr %5, align 8, !tbaa !5
  %11 = insertelement <2 x double> poison, double %3, i64 0
  %12 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> zeroinitializer
  %13 = fmul <2 x double> %12, %10
  %14 = fadd <2 x double> %9, %13
  store <2 x double> %14, ptr %0, align 8, !tbaa !5
  %15 = fmul <2 x double> %8, %10
  %16 = fmul <2 x double> %12, %6
  %17 = fsub <2 x double> %15, %16
  store <2 x double> %17, ptr %5, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 = { 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/C++ TBAA"}


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