; LLVM IR from tyoma/agge :: src/agge/curves.ll (ZN4agge7qbezier6vertexEPfS1_)

; 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.agge::qbezier" = type { float, float, float, float, float, float, float, float, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN4agge7qbezier6vertexEPfS1_(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef %1, ptr noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca [3 x float], align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %11 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 8
  %12 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %12, ptr %7, align 4, !tbaa !13
  %13 = load i32, ptr %7, align 4, !tbaa !13
  switch i32 %13, label %94 [
    i32 1, label %14
    i32 2, label %25
  ]

14:                                               ; preds = %3
  %15 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 0
  %16 = load float, ptr %15, align 4, !tbaa !14
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  store float %16, ptr %17, align 4, !tbaa !15
  %18 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 1
  %19 = load float, ptr %18, align 4, !tbaa !16
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  store float %19, ptr %20, align 4, !tbaa !15
  %21 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 8
  store i32 2, ptr %21, align 4, !tbaa !9
  %22 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 7
  %23 = load float, ptr %22, align 4, !tbaa !17
  %24 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 6
  store float %23, ptr %24, align 4, !tbaa !18
  br label %94

25:                                               ; preds = %3
  %26 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 6
  %27 = load float, ptr %26, align 4, !tbaa !18
  %28 = fcmp olt float %27, 1.000000e+00
  br i1 %28, label %29, label %85

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %30 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 6
  %31 = load float, ptr %30, align 4, !tbaa !18
  %32 = fsub float 1.000000e+00, %31
  store float %32, ptr %8, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #3
  %33 = load float, ptr %8, align 4, !tbaa !15
  %34 = load float, ptr %8, align 4, !tbaa !15
  %35 = fmul float %33, %34
  store float %35, ptr %9, align 4, !tbaa !15
  %36 = getelementptr inbounds float, ptr %9, i64 1
  %37 = load float, ptr %8, align 4, !tbaa !15
  %38 = fmul float 2.000000e+00, %37
  %39 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 6
  %40 = load float, ptr %39, align 4, !tbaa !18
  %41 = fmul float %38, %40
  store float %41, ptr %36, align 4, !tbaa !15
  %42 = getelementptr inbounds float, ptr %9, i64 2
  %43 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 6
  %44 = load float, ptr %43, align 4, !tbaa !18
  %45 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 6
  %46 = load float, ptr %45, align 4, !tbaa !18
  %47 = fmul float %44, %46
  store float %47, ptr %42, align 4, !tbaa !15
  %48 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 0
  %49 = load float, ptr %48, align 4, !tbaa !14
  %50 = getelementptr inbounds [3 x float], ptr %9, i64 0, i64 0
  %51 = load float, ptr %50, align 4, !tbaa !15
  %52 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 2
  %53 = load float, ptr %52, align 4, !tbaa !19
  %54 = getelementptr inbounds [3 x float], ptr %9, i64 0, i64 1
  %55 = load float, ptr %54, align 4, !tbaa !15
  %56 = fmul float %53, %55
  %57 = call float @llvm.fmuladd.f32(float %49, float %51, float %56)
  %58 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 4
  %59 = load float, ptr %58, align 4, !tbaa !20
  %60 = getelementptr inbounds [3 x float], ptr %9, i64 0, i64 2
  %61 = load float, ptr %60, align 4, !tbaa !15
  %62 = call float @llvm.fmuladd.f32(float %59, float %61, float %57)
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  store float %62, ptr %63, align 4, !tbaa !15
  %64 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 1
  %65 = load float, ptr %64, align 4, !tbaa !16
  %66 = getelementptr inbounds [3 x float], ptr %9, i64 0, i64 0
  %67 = load float, ptr %66, align 4, !tbaa !15
  %68 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 3
  %69 = load float, ptr %68, align 4, !tbaa !21
  %70 = getelementptr inbounds [3 x float], ptr %9, i64 0, i64 1
  %71 = load float, ptr %70, align 4, !tbaa !15
  %72 = fmul float %69, %71
  %73 = call float @llvm.fmuladd.f32(float %65, float %67, float %72)
  %74 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 5
  %75 = load float, ptr %74, align 4, !tbaa !22
  %76 = getelementptr inbounds [3 x float], ptr %9, i64 0, i64 2
  %77 = load float, ptr %76, align 4, !tbaa !15
  %78 = call float @llvm.fmuladd.f32(float %75, float %77, float %73)
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  store float %78, ptr %79, align 4, !tbaa !15
  %80 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 7
  %81 = load float, ptr %80, align 4, !tbaa !17
  %82 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 6
  %83 = load float, ptr %82, align 4, !tbaa !18
  %84 = fadd float %83, %81
  store float %84, ptr %82, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %93

85:                                               ; preds = %25
  %86 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 4
  %87 = load float, ptr %86, align 4, !tbaa !20
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  store float %87, ptr %88, align 4, !tbaa !15
  %89 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 5
  %90 = load float, ptr %89, align 4, !tbaa !22
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  store float %90, ptr %91, align 4, !tbaa !15
  %92 = getelementptr inbounds %"class.agge::qbezier", ptr %10, i32 0, i32 8
  store i32 0, ptr %92, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %85, %29
  br label %94

94:                                               ; preds = %93, %14, %3
  %95 = load i32, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %95
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

attributes #0 = { mustprogress 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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 32}
!10 = !{!"_ZTSN4agge7qbezierE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !12, i64 32}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !11, i64 28}
!18 = !{!10, !11, i64 24}
!19 = !{!10, !11, i64 8}
!20 = !{!10, !11, i64 16}
!21 = !{!10, !11, i64 12}
!22 = !{!10, !11, i64 20}


; 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 norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef i32 @_ZN4agge7qbezier6vertexEPfS1_(ptr nocapture noundef nonnull align 4 dereferenceable(36) %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %5, label %49 [
    i32 1, label %6
    i32 2, label %13
  ]

6:                                                ; preds = %3
  %7 = load float, ptr %0, align 4, !tbaa !11
  store float %7, ptr %1, align 4, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load float, ptr %8, align 4, !tbaa !13
  store float %9, ptr %2, align 4, !tbaa !12
  store i32 2, ptr %4, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 28
  %11 = load float, ptr %10, align 4, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  store float %11, ptr %12, align 4, !tbaa !15
  br label %49

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load float, ptr %14, align 4, !tbaa !15
  %16 = fcmp olt float %15, 1.000000e+00
  br i1 %16, label %17, label %44

17:                                               ; preds = %13
  %18 = fsub float 1.000000e+00, %15
  %19 = fmul float %18, %18
  %20 = fmul float %18, 2.000000e+00
  %21 = fmul float %15, %20
  %22 = fmul float %15, %15
  %23 = load float, ptr %0, align 4, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load float, ptr %24, align 4, !tbaa !16
  %26 = fmul float %21, %25
  %27 = tail call float @llvm.fmuladd.f32(float %23, float %19, float %26)
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load float, ptr %28, align 4, !tbaa !17
  %30 = tail call float @llvm.fmuladd.f32(float %29, float %22, float %27)
  store float %30, ptr %1, align 4, !tbaa !12
  %31 = getelementptr inbounds i8, ptr %0, i64 4
  %32 = load float, ptr %31, align 4, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %0, i64 12
  %34 = load float, ptr %33, align 4, !tbaa !18
  %35 = fmul float %21, %34
  %36 = tail call float @llvm.fmuladd.f32(float %32, float %19, float %35)
  %37 = getelementptr inbounds i8, ptr %0, i64 20
  %38 = load float, ptr %37, align 4, !tbaa !19
  %39 = tail call float @llvm.fmuladd.f32(float %38, float %22, float %36)
  store float %39, ptr %2, align 4, !tbaa !12
  %40 = getelementptr inbounds i8, ptr %0, i64 28
  %41 = load float, ptr %40, align 4, !tbaa !14
  %42 = load float, ptr %14, align 4, !tbaa !15
  %43 = fadd float %41, %42
  store float %43, ptr %14, align 4, !tbaa !15
  br label %49

44:                                               ; preds = %13
  %45 = getelementptr inbounds i8, ptr %0, i64 16
  %46 = load float, ptr %45, align 4, !tbaa !17
  store float %46, ptr %1, align 4, !tbaa !12
  %47 = getelementptr inbounds i8, ptr %0, i64 20
  %48 = load float, ptr %47, align 4, !tbaa !19
  store float %48, ptr %2, align 4, !tbaa !12
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %17, %44, %6, %3
  ret i32 %5
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 32}
!6 = !{!"_ZTSN4agge7qbezierE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !10, i64 32}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !7, i64 28}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 16}
!18 = !{!6, !7, i64 12}
!19 = !{!6, !7, i64 20}


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