; LLVM IR from Stephane-D/SGDK :: src (maths3D)

; 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.Context3D = type { %struct.Vect2D_u16, i16, %struct.Vect3D_f16, i16 }
%struct.Vect2D_u16 = type { i16, i16 }
%struct.Vect3D_f16 = type { i16, i16, i16 }
%struct.Transformation3D = type { i16, ptr, ptr, %struct.Mat3D_f16, %struct.Mat3D_f16, %struct.Vect3D_f16, %struct.Vect3D_f16 }
%struct.Mat3D_f16 = type { %struct.Vect3D_f16, %struct.Vect3D_f16, %struct.Vect3D_f16 }

@context3D = external dso_local global %struct.Context3D, align 2

; Function Attrs: nounwind uwtable
define dso_local void @M3D_resetTransform(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.Transformation3D, ptr %5, i32 0, i32 2
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %7, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Transformation3D, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Vect3D_f16, ptr %11, i32 0, i32 0
  store i16 0, ptr %12, align 2, !tbaa !15
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Vect3D_f16, ptr %13, i32 0, i32 1
  store i16 0, ptr %14, align 2, !tbaa !16
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Vect3D_f16, ptr %15, i32 0, i32 2
  store i16 0, ptr %16, align 2, !tbaa !17
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Vect3D_f16, ptr %17, i32 0, i32 0
  store i16 0, ptr %18, align 2, !tbaa !15
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Vect3D_f16, ptr %19, i32 0, i32 1
  store i16 0, ptr %20, align 2, !tbaa !16
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Vect3D_f16, ptr %21, i32 0, i32 2
  store i16 0, ptr %22, align 2, !tbaa !17
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Transformation3D, ptr %23, i32 0, i32 3
  %25 = getelementptr inbounds %struct.Mat3D_f16, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds %struct.Vect3D_f16, ptr %25, i32 0, i32 0
  store i16 64, ptr %26, align 8, !tbaa !18
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Transformation3D, ptr %27, i32 0, i32 3
  %29 = getelementptr inbounds %struct.Mat3D_f16, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.Vect3D_f16, ptr %29, i32 0, i32 0
  store i16 0, ptr %30, align 2, !tbaa !19
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.Transformation3D, ptr %31, i32 0, i32 3
  %33 = getelementptr inbounds %struct.Mat3D_f16, ptr %32, i32 0, i32 2
  %34 = getelementptr inbounds %struct.Vect3D_f16, ptr %33, i32 0, i32 0
  store i16 0, ptr %34, align 4, !tbaa !20
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Transformation3D, ptr %35, i32 0, i32 3
  %37 = getelementptr inbounds %struct.Mat3D_f16, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.Vect3D_f16, ptr %37, i32 0, i32 1
  store i16 0, ptr %38, align 2, !tbaa !21
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Transformation3D, ptr %39, i32 0, i32 3
  %41 = getelementptr inbounds %struct.Mat3D_f16, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds %struct.Vect3D_f16, ptr %41, i32 0, i32 1
  store i16 64, ptr %42, align 2, !tbaa !22
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Transformation3D, ptr %43, i32 0, i32 3
  %45 = getelementptr inbounds %struct.Mat3D_f16, ptr %44, i32 0, i32 2
  %46 = getelementptr inbounds %struct.Vect3D_f16, ptr %45, i32 0, i32 1
  store i16 0, ptr %46, align 2, !tbaa !23
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Transformation3D, ptr %47, i32 0, i32 3
  %49 = getelementptr inbounds %struct.Mat3D_f16, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.Vect3D_f16, ptr %49, i32 0, i32 2
  store i16 0, ptr %50, align 4, !tbaa !24
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.Transformation3D, ptr %51, i32 0, i32 3
  %53 = getelementptr inbounds %struct.Mat3D_f16, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.Vect3D_f16, ptr %53, i32 0, i32 2
  store i16 0, ptr %54, align 2, !tbaa !25
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Transformation3D, ptr %55, i32 0, i32 3
  %57 = getelementptr inbounds %struct.Mat3D_f16, ptr %56, i32 0, i32 2
  %58 = getelementptr inbounds %struct.Vect3D_f16, ptr %57, i32 0, i32 2
  store i16 64, ptr %58, align 4, !tbaa !26
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Transformation3D, ptr %59, i32 0, i32 4
  %61 = getelementptr inbounds %struct.Mat3D_f16, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.Vect3D_f16, ptr %61, i32 0, i32 0
  store i16 64, ptr %62, align 2, !tbaa !27
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Transformation3D, ptr %63, i32 0, i32 4
  %65 = getelementptr inbounds %struct.Mat3D_f16, ptr %64, i32 0, i32 1
  %66 = getelementptr inbounds %struct.Vect3D_f16, ptr %65, i32 0, i32 0
  store i16 0, ptr %66, align 2, !tbaa !28
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.Transformation3D, ptr %67, i32 0, i32 4
  %69 = getelementptr inbounds %struct.Mat3D_f16, ptr %68, i32 0, i32 2
  %70 = getelementptr inbounds %struct.Vect3D_f16, ptr %69, i32 0, i32 0
  store i16 0, ptr %70, align 2, !tbaa !29
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Transformation3D, ptr %71, i32 0, i32 4
  %73 = getelementptr inbounds %struct.Mat3D_f16, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds %struct.Vect3D_f16, ptr %73, i32 0, i32 1
  store i16 0, ptr %74, align 2, !tbaa !30
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.Transformation3D, ptr %75, i32 0, i32 4
  %77 = getelementptr inbounds %struct.Mat3D_f16, ptr %76, i32 0, i32 1
  %78 = getelementptr inbounds %struct.Vect3D_f16, ptr %77, i32 0, i32 1
  store i16 64, ptr %78, align 2, !tbaa !31
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.Transformation3D, ptr %79, i32 0, i32 4
  %81 = getelementptr inbounds %struct.Mat3D_f16, ptr %80, i32 0, i32 2
  %82 = getelementptr inbounds %struct.Vect3D_f16, ptr %81, i32 0, i32 1
  store i16 0, ptr %82, align 2, !tbaa !32
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.Transformation3D, ptr %83, i32 0, i32 4
  %85 = getelementptr inbounds %struct.Mat3D_f16, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds %struct.Vect3D_f16, ptr %85, i32 0, i32 2
  store i16 0, ptr %86, align 2, !tbaa !33
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.Transformation3D, ptr %87, i32 0, i32 4
  %89 = getelementptr inbounds %struct.Mat3D_f16, ptr %88, i32 0, i32 1
  %90 = getelementptr inbounds %struct.Vect3D_f16, ptr %89, i32 0, i32 2
  store i16 0, ptr %90, align 2, !tbaa !34
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.Transformation3D, ptr %91, i32 0, i32 4
  %93 = getelementptr inbounds %struct.Mat3D_f16, ptr %92, i32 0, i32 2
  %94 = getelementptr inbounds %struct.Vect3D_f16, ptr %93, i32 0, i32 2
  store i16 64, ptr %94, align 2, !tbaa !35
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.Transformation3D, ptr %95, i32 0, i32 5
  %97 = getelementptr inbounds %struct.Vect3D_f16, ptr %96, i32 0, i32 0
  store i16 0, ptr %97, align 4, !tbaa !36
  %98 = load ptr, ptr %2, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.Transformation3D, ptr %98, i32 0, i32 5
  %100 = getelementptr inbounds %struct.Vect3D_f16, ptr %99, i32 0, i32 1
  store i16 0, ptr %100, align 2, !tbaa !37
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.Transformation3D, ptr %101, i32 0, i32 5
  %103 = getelementptr inbounds %struct.Vect3D_f16, ptr %102, i32 0, i32 2
  store i16 64, ptr %103, align 4, !tbaa !38
  %104 = load ptr, ptr %2, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.Transformation3D, ptr %104, i32 0, i32 0
  store i16 0, ptr %105, align 8, !tbaa !39
  %106 = load i16, ptr getelementptr inbounds (%struct.Context3D, ptr @context3D, i32 0, i32 3), align 2, !tbaa !40
  %107 = icmp ne i16 %106, 0
  br i1 %107, label %108, label %112

108:                                              ; preds = %1
  %109 = load ptr, ptr %2, align 8, !tbaa !5
  %110 = load ptr, ptr %2, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.Transformation3D, ptr %110, i32 0, i32 6
  call void @M3D_rotateInv(ptr noundef %109, ptr noundef getelementptr inbounds (%struct.Context3D, ptr @context3D, i32 0, i32 2), ptr noundef %111)
  br label %112

112:                                              ; preds = %108, %1
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  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 uwtable
declare dso_local void @M3D_rotateInv(ptr noundef, ptr noundef, ptr noundef) #0

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

!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, !6, i64 16}
!10 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 42, !13, i64 60, !13, i64 66}
!11 = !{!"short", !7, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 6, !13, i64 12}
!13 = !{!"", !11, i64 0, !11, i64 2, !11, i64 4}
!14 = !{!10, !6, i64 8}
!15 = !{!13, !11, i64 0}
!16 = !{!13, !11, i64 2}
!17 = !{!13, !11, i64 4}
!18 = !{!10, !11, i64 24}
!19 = !{!10, !11, i64 30}
!20 = !{!10, !11, i64 36}
!21 = !{!10, !11, i64 26}
!22 = !{!10, !11, i64 32}
!23 = !{!10, !11, i64 38}
!24 = !{!10, !11, i64 28}
!25 = !{!10, !11, i64 34}
!26 = !{!10, !11, i64 40}
!27 = !{!10, !11, i64 42}
!28 = !{!10, !11, i64 48}
!29 = !{!10, !11, i64 54}
!30 = !{!10, !11, i64 44}
!31 = !{!10, !11, i64 50}
!32 = !{!10, !11, i64 56}
!33 = !{!10, !11, i64 46}
!34 = !{!10, !11, i64 52}
!35 = !{!10, !11, i64 58}
!36 = !{!10, !11, i64 60}
!37 = !{!10, !11, i64 62}
!38 = !{!10, !11, i64 64}
!39 = !{!10, !11, i64 0}
!40 = !{!41, !11, i64 12}
!41 = !{!"", !42, i64 0, !11, i64 4, !13, i64 6, !11, i64 12}
!42 = !{!"", !11, i64 0, !11, i64 2}


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

%struct.Context3D = type { %struct.Vect2D_u16, i16, %struct.Vect3D_f16, i16 }
%struct.Vect2D_u16 = type { i16, i16 }
%struct.Vect3D_f16 = type { i16, i16, i16 }

@context3D = external dso_local global %struct.Context3D, align 2

; Function Attrs: nounwind uwtable
define dso_local void @M3D_resetTransform(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !13
  store i16 0, ptr %3, align 2, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %3, i64 2
  store i16 0, ptr %6, align 2, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %3, i64 4
  store i16 0, ptr %7, align 2, !tbaa !16
  store i16 0, ptr %5, align 2, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %5, i64 2
  store i16 0, ptr %8, align 2, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %5, i64 4
  store i16 0, ptr %9, align 2, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store <8 x i16> <i16 64, i16 0, i16 0, i16 0, i16 64, i16 0, i16 0, i16 0>, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  store <8 x i16> <i16 64, i16 64, i16 0, i16 0, i16 0, i16 64, i16 0, i16 0>, ptr %11, align 4, !tbaa !17
  store <4 x i16> <i16 0, i16 64, i16 0, i16 0>, ptr %12, align 2, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  store i16 64, ptr %13, align 4, !tbaa !18
  store i16 0, ptr %0, align 8, !tbaa !19
  %14 = load i16, ptr getelementptr inbounds (i8, ptr @context3D, i64 12), align 2, !tbaa !20
  %.not = icmp eq i16 %14, 0
  br i1 %.not, label %17, label %15

15:                                               ; preds = %1
  %16 = getelementptr inbounds i8, ptr %0, i64 66
  tail call void @M3D_rotateInv(ptr noundef nonnull %0, ptr noundef nonnull getelementptr inbounds (i8, ptr @context3D, i64 6), ptr noundef nonnull %16)
  br label %17

17:                                               ; preds = %15, %1
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @M3D_rotateInv(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

!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 16}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !11, i64 42, !12, i64 60, !12, i64 66}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"", !12, i64 0, !12, i64 6, !12, i64 12}
!12 = !{!"", !7, i64 0, !7, i64 2, !7, i64 4}
!13 = !{!6, !10, i64 8}
!14 = !{!12, !7, i64 0}
!15 = !{!12, !7, i64 2}
!16 = !{!12, !7, i64 4}
!17 = !{!7, !7, i64 0}
!18 = !{!6, !7, i64 64}
!19 = !{!6, !7, i64 0}
!20 = !{!21, !7, i64 12}
!21 = !{!"", !22, i64 0, !7, i64 4, !12, i64 6, !7, i64 12}
!22 = !{!"", !7, i64 0, !7, i64 2}


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