; LLVM IR from PyCee/NUS_library :: src/model (NUS_keyframe)

; 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.NUS_keyframe = type { ptr }
%struct.NUS_quaternion = type { double, double, double, double }
%struct.NUS_vector = type { double, double, double }
%struct.NUS_keyframe_joint = type { %struct.NUS_quaternion, %struct.NUS_vector, %struct.NUS_vector }

; Function Attrs: nounwind uwtable
define dso_local void @nus_keyframe_lerp(ptr noundef %0, ptr %1, ptr %2, i32 noundef %3, float noundef %4) #0 {
  %6 = alloca %struct.NUS_keyframe, align 8
  %7 = alloca %struct.NUS_keyframe, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.NUS_quaternion, align 8
  %13 = alloca %struct.NUS_vector, align 8
  %14 = alloca %struct.NUS_vector, align 8
  %15 = getelementptr inbounds %struct.NUS_keyframe, ptr %6, i32 0, i32 0
  store ptr %1, ptr %15, align 8
  %16 = getelementptr inbounds %struct.NUS_keyframe, ptr %7, i32 0, i32 0
  store ptr %2, ptr %16, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store float %4, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %86, %5
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp ult i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %89

22:                                               ; preds = %17
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.NUS_keyframe, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %25, i64 %27
  %29 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %28, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #4
  %30 = getelementptr inbounds %struct.NUS_keyframe, ptr %6, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %31, i64 %33
  %35 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.NUS_keyframe, ptr %7, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %37, i64 %39
  %41 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %40, i32 0, i32 0
  %42 = load float, ptr %10, align 4, !tbaa !11
  %43 = fpext float %42 to double
  call void @nus_quaternion_lerp(ptr dead_on_unwind writable sret(%struct.NUS_quaternion) align 8 %12, ptr noundef byval(%struct.NUS_quaternion) align 8 %35, ptr noundef byval(%struct.NUS_quaternion) align 8 %41, double noundef %43)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr align 8 %12, i64 32, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #4
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.NUS_keyframe, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %46, i64 %48
  %50 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %49, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #4
  %51 = getelementptr inbounds %struct.NUS_keyframe, ptr %6, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = load i32, ptr %11, align 4, !tbaa !9
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.NUS_keyframe, ptr %7, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %61, i32 0, i32 1
  %63 = load float, ptr %10, align 4, !tbaa !11
  %64 = fpext float %63 to double
  call void @nus_vector_lerp(ptr dead_on_unwind writable sret(%struct.NUS_vector) align 8 %13, ptr noundef byval(%struct.NUS_vector) align 8 %56, ptr noundef byval(%struct.NUS_vector) align 8 %62, double noundef %64)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %50, ptr align 8 %13, i64 24, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #4
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.NUS_keyframe, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %67, i64 %69
  %71 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %70, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #4
  %72 = getelementptr inbounds %struct.NUS_keyframe, ptr %6, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !13
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %73, i64 %75
  %77 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %76, i32 0, i32 2
  %78 = getelementptr inbounds %struct.NUS_keyframe, ptr %7, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !13
  %80 = load i32, ptr %11, align 4, !tbaa !9
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %79, i64 %81
  %83 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %82, i32 0, i32 2
  %84 = load float, ptr %10, align 4, !tbaa !11
  %85 = fpext float %84 to double
  call void @nus_vector_lerp(ptr dead_on_unwind writable sret(%struct.NUS_vector) align 8 %14, ptr noundef byval(%struct.NUS_vector) align 8 %77, ptr noundef byval(%struct.NUS_vector) align 8 %83, double noundef %85)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %71, ptr align 8 %14, i64 24, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #4
  br label %86

86:                                               ; preds = %22
  %87 = load i32, ptr %11, align 4, !tbaa !9
  %88 = add i32 %87, 1
  store i32 %88, ptr %11, align 4, !tbaa !9
  br label %17, !llvm.loop !19

89:                                               ; preds = %21
  ret void
}

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

declare void @nus_quaternion_lerp(ptr dead_on_unwind writable sret(%struct.NUS_quaternion) align 8, ptr noundef byval(%struct.NUS_quaternion) align 8, ptr noundef byval(%struct.NUS_quaternion) align 8, double noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

declare void @nus_vector_lerp(ptr dead_on_unwind writable sret(%struct.NUS_vector) align 8, ptr noundef byval(%struct.NUS_vector) align 8, ptr noundef byval(%struct.NUS_vector) align 8, double noundef) #2

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 = { "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: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"NUS_keyframe", !6, i64 0}
!15 = !{i64 0, i64 8, !16, i64 8, i64 8, !16, i64 16, i64 8, !16, i64 24, i64 8, !16}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{i64 0, i64 8, !16, i64 8, i64 8, !16, i64 16, i64 8, !16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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.NUS_quaternion = type { double, double, double, double }
%struct.NUS_vector = type { double, double, double }
%struct.NUS_keyframe_joint = type { %struct.NUS_quaternion, %struct.NUS_vector, %struct.NUS_vector }

; Function Attrs: nounwind uwtable
define dso_local void @nus_keyframe_lerp(ptr nocapture noundef readonly %0, ptr %1, ptr %2, i32 noundef %3, float noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.NUS_quaternion, align 8
  %7 = alloca %struct.NUS_vector, align 8
  %8 = alloca %struct.NUS_vector, align 8
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %9 = fpext float %4 to double
  %wide.trip.count = zext i32 %3 to i64
  br label %10

._crit_edge:                                      ; preds = %10, %5
  ret void

10:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %11 = load ptr, ptr %0, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %11, i64 %indvars.iv
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #4
  %13 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %1, i64 %indvars.iv
  %14 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %2, i64 %indvars.iv
  call void @nus_quaternion_lerp(ptr dead_on_unwind nonnull writable sret(%struct.NUS_quaternion) align 8 %6, ptr noundef byval(%struct.NUS_quaternion) align 8 %13, ptr noundef byval(%struct.NUS_quaternion) align 8 %14, double noundef %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(32) %6, i64 32, i1 false), !tbaa.struct !10
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %15, i64 %indvars.iv, i32 1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #4
  %17 = getelementptr inbounds i8, ptr %13, i64 32
  %18 = getelementptr inbounds i8, ptr %14, i64 32
  call void @nus_vector_lerp(ptr dead_on_unwind nonnull writable sret(%struct.NUS_vector) align 8 %7, ptr noundef nonnull byval(%struct.NUS_vector) align 8 %17, ptr noundef nonnull byval(%struct.NUS_vector) align 8 %18, double noundef %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef nonnull align 8 dereferenceable(24) %7, i64 24, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #4
  %19 = load ptr, ptr %0, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.NUS_keyframe_joint, ptr %19, i64 %indvars.iv, i32 2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #4
  %21 = getelementptr inbounds i8, ptr %13, i64 56
  %22 = getelementptr inbounds i8, ptr %14, i64 56
  call void @nus_vector_lerp(ptr dead_on_unwind nonnull writable sret(%struct.NUS_vector) align 8 %8, ptr noundef nonnull byval(%struct.NUS_vector) align 8 %21, ptr noundef nonnull byval(%struct.NUS_vector) align 8 %22, double noundef %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef nonnull align 8 dereferenceable(24) %8, i64 24, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !14
}

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

declare void @nus_quaternion_lerp(ptr dead_on_unwind writable sret(%struct.NUS_quaternion) align 8, ptr noundef byval(%struct.NUS_quaternion) align 8, ptr noundef byval(%struct.NUS_quaternion) align 8, double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

declare void @nus_vector_lerp(ptr dead_on_unwind writable sret(%struct.NUS_vector) align 8, ptr noundef byval(%struct.NUS_vector) align 8, ptr noundef byval(%struct.NUS_vector) align 8, double noundef) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"NUS_keyframe", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{i64 0, i64 8, !11, i64 8, i64 8, !11, i64 16, i64 8, !11, i64 24, i64 8, !11}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{i64 0, i64 8, !11, i64 8, i64 8, !11, i64 16, i64 8, !11}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass