; LLVM IR from leonmavr/gfx-v4 :: src (geometry)

; 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.node_t = type { %struct.vec2i_t, %struct.vec3u8_t, ptr }
%struct.vec2i_t = type { i32, i32 }
%struct.vec3u8_t = type { i8, i8, i8 }

; Function Attrs: nounwind uwtable
define dso_local void @geo_rotate(ptr noundef %0, float noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.node_t, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %struct.vec2i_t, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !11
  store i32 %12, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.node_t, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.vec2i_t, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !17
  store i32 %16, ptr %6, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %17 = load i32, ptr %5, align 4, !tbaa !16
  %18 = sitofp i32 %17 to double
  %19 = load float, ptr %4, align 4, !tbaa !9
  %20 = fpext float %19 to double
  %21 = fmul double %20, 0x400921FB54411744
  %22 = fdiv double %21, 1.800000e+02
  %23 = call double @cos(double noundef %22) #4
  %24 = load i32, ptr %6, align 4, !tbaa !16
  %25 = sitofp i32 %24 to double
  %26 = load float, ptr %4, align 4, !tbaa !9
  %27 = fpext float %26 to double
  %28 = fmul double %27, 0x400921FB54411744
  %29 = fdiv double %28, 1.800000e+02
  %30 = call double @sin(double noundef %29) #4
  %31 = fmul double %25, %30
  %32 = call double @llvm.fmuladd.f64(double %18, double %23, double %31)
  %33 = call double @llvm.round.f64(double %32)
  %34 = fptosi double %33 to i32
  store i32 %34, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %35 = load i32, ptr %5, align 4, !tbaa !16
  %36 = sub nsw i32 0, %35
  %37 = sitofp i32 %36 to double
  %38 = load float, ptr %4, align 4, !tbaa !9
  %39 = fpext float %38 to double
  %40 = fmul double %39, 0x400921FB54411744
  %41 = fdiv double %40, 1.800000e+02
  %42 = call double @sin(double noundef %41) #4
  %43 = load i32, ptr %6, align 4, !tbaa !16
  %44 = sitofp i32 %43 to double
  %45 = load float, ptr %4, align 4, !tbaa !9
  %46 = fpext float %45 to double
  %47 = fmul double %46, 0x400921FB54411744
  %48 = fdiv double %47, 1.800000e+02
  %49 = call double @cos(double noundef %48) #4
  %50 = fmul double %44, %49
  %51 = call double @llvm.fmuladd.f64(double %37, double %42, double %50)
  %52 = call double @llvm.round.f64(double %51)
  %53 = fptosi double %52 to i32
  store i32 %53, ptr %8, align 4, !tbaa !16
  %54 = load i32, ptr %7, align 4, !tbaa !16
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.node_t, ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds %struct.vec2i_t, ptr %56, i32 0, i32 0
  store i32 %54, ptr %57, align 8, !tbaa !11
  %58 = load i32, ptr %8, align 4, !tbaa !16
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.node_t, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.vec2i_t, ptr %60, i32 0, i32 1
  store i32 %58, ptr %61, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  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: nounwind
declare double @cos(double noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.round.f64(double) #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !14, i64 0}
!12 = !{!"node_t", !13, i64 0, !15, i64 8, !6, i64 16}
!13 = !{!"vec2i_t", !14, i64 0, !14, i64 4}
!14 = !{!"int", !7, i64 0}
!15 = !{!"vec3u8_t", !7, i64 0, !7, i64 1, !7, i64 2}
!16 = !{!14, !14, i64 0}
!17 = !{!12, !14, i64 4}


; 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, argmem: readwrite) uwtable
define dso_local void @geo_rotate(ptr nocapture noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !13
  %6 = fpext float %1 to double
  %7 = fmul double %6, 0x400921FB54411744
  %8 = fdiv double %7, 1.800000e+02
  %9 = tail call double @cos(double noundef %8) #3
  %10 = sitofp i32 %5 to double
  %11 = tail call double @sin(double noundef %8) #3
  %12 = sub nsw i32 0, %3
  %13 = tail call double @sin(double noundef %8) #3
  %14 = tail call double @cos(double noundef %8) #3
  %15 = insertelement <2 x i32> poison, i32 %3, i64 0
  %16 = insertelement <2 x i32> %15, i32 %12, i64 1
  %17 = sitofp <2 x i32> %16 to <2 x double>
  %18 = insertelement <2 x double> poison, double %11, i64 0
  %19 = insertelement <2 x double> %18, double %14, i64 1
  %20 = insertelement <2 x double> poison, double %10, i64 0
  %21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
  %22 = fmul <2 x double> %19, %21
  %23 = insertelement <2 x double> poison, double %9, i64 0
  %24 = insertelement <2 x double> %23, double %13, i64 1
  %25 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %17, <2 x double> %24, <2 x double> %22)
  %26 = tail call <2 x double> @llvm.round.v2f64(<2 x double> %25)
  %27 = fptosi <2 x double> %26 to <2 x i32>
  store <2 x i32> %27, ptr %0, align 8, !tbaa !14
  ret void
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.round.v2f64(<2 x double>) #2

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !8, i64 0}
!6 = !{!"node_t", !7, i64 0, !11, i64 8, !12, i64 16}
!7 = !{!"vec2i_t", !8, i64 0, !8, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"vec3u8_t", !9, i64 0, !9, i64 1, !9, i64 2}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!6, !8, i64 4}
!14 = !{!8, !8, i64 0}


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