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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4agge3arc6vertexEPfS1_(ptr noundef nonnull align 4 dereferenceable(32) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %11 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %12, ptr %8, align 4, !tbaa !13
  %13 = load i32, ptr %8, align 4, !tbaa !13
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %17

15:                                               ; preds = %3
  %16 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 1
  store i32 2, ptr %16, align 4, !tbaa !9
  br label %23

17:                                               ; preds = %3
  %18 = load i32, ptr %8, align 4, !tbaa !13
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = load i32, ptr %8, align 4, !tbaa !13
  store i32 %21, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %68

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22, %15
  %24 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 0
  %25 = load float, ptr %24, align 4, !tbaa !14
  %26 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 6
  %27 = load float, ptr %26, align 4, !tbaa !15
  %28 = fcmp olt float %25, %27
  %29 = zext i1 %28 to i32
  %30 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 6
  %31 = load float, ptr %30, align 4, !tbaa !15
  %32 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 5
  %33 = load float, ptr %32, align 4, !tbaa !16
  %34 = fcmp ogt float %31, %33
  %35 = zext i1 %34 to i32
  %36 = xor i32 %29, %35
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %43

38:                                               ; preds = %23
  %39 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 6
  %40 = load float, ptr %39, align 4, !tbaa !15
  %41 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 0
  store float %40, ptr %41, align 4, !tbaa !14
  %42 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 1
  store i32 0, ptr %42, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %38, %23
  %44 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 2
  %45 = load float, ptr %44, align 4, !tbaa !17
  %46 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 4
  %47 = load float, ptr %46, align 4, !tbaa !18
  %48 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 0
  %49 = load float, ptr %48, align 4, !tbaa !14
  %50 = call noundef float @_ZN4agge3cosEf(float noundef %49)
  %51 = call float @llvm.fmuladd.f32(float %47, float %50, float %45)
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  store float %51, ptr %52, align 4, !tbaa !19
  %53 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 3
  %54 = load float, ptr %53, align 4, !tbaa !20
  %55 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 4
  %56 = load float, ptr %55, align 4, !tbaa !18
  %57 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 0
  %58 = load float, ptr %57, align 4, !tbaa !14
  %59 = call noundef float @_ZN4agge3sinEf(float noundef %58)
  %60 = call float @llvm.fmuladd.f32(float %56, float %59, float %54)
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  store float %60, ptr %61, align 4, !tbaa !19
  %62 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 7
  %63 = load float, ptr %62, align 4, !tbaa !21
  %64 = getelementptr inbounds %"class.agge::arc", ptr %10, i32 0, i32 0
  %65 = load float, ptr %64, align 4, !tbaa !14
  %66 = fadd float %65, %63
  store float %66, ptr %64, align 4, !tbaa !14
  %67 = load i32, ptr %8, align 4, !tbaa !13
  store i32 %67, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %68

68:                                               ; preds = %43, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %69 = load i32, ptr %4, align 4
  ret i32 %69
}

declare noundef float @_ZN4agge3cosEf(float noundef) #3

declare noundef float @_ZN4agge3sinEf(float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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 = { "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 #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++ TBAA"}
!9 = !{!10, !12, i64 4}
!10 = !{!"_ZTSN4agge3arcE", !11, i64 0, !12, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !11, i64 20}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !11, i64 16}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !11, i64 12}
!21 = !{!10, !11, i64 28}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4agge3arc6vertexEPfS1_(ptr nocapture noundef nonnull align 4 dereferenceable(32) %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %5, label %7 [
    i32 1, label %6
    i32 0, label %35
  ]

6:                                                ; preds = %3
  store i32 2, ptr %4, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %3, %6
  %8 = load float, ptr %0, align 4, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load float, ptr %9, align 4, !tbaa !12
  %11 = fcmp olt float %8, %10
  %12 = getelementptr inbounds i8, ptr %0, i64 20
  %13 = load float, ptr %12, align 4, !tbaa !13
  %14 = fcmp ogt float %10, %13
  %15 = xor i1 %11, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %7
  store float %10, ptr %0, align 4, !tbaa !11
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %16, %7
  %18 = phi float [ %10, %16 ], [ %8, %7 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load float, ptr %19, align 4, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load float, ptr %21, align 4, !tbaa !15
  %23 = tail call noundef float @_ZN4agge3cosEf(float noundef %18)
  %24 = tail call float @llvm.fmuladd.f32(float %22, float %23, float %20)
  store float %24, ptr %1, align 4, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %0, i64 12
  %26 = load float, ptr %25, align 4, !tbaa !17
  %27 = load float, ptr %21, align 4, !tbaa !15
  %28 = load float, ptr %0, align 4, !tbaa !11
  %29 = tail call noundef float @_ZN4agge3sinEf(float noundef %28)
  %30 = tail call float @llvm.fmuladd.f32(float %27, float %29, float %26)
  store float %30, ptr %2, align 4, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %0, i64 28
  %32 = load float, ptr %31, align 4, !tbaa !18
  %33 = load float, ptr %0, align 4, !tbaa !11
  %34 = fadd float %32, %33
  store float %34, ptr %0, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %3, %17
  ret i32 %5
}

declare noundef float @_ZN4agge3cosEf(float noundef) local_unnamed_addr #2

declare noundef float @_ZN4agge3sinEf(float noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress 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 = { "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 4}
!6 = !{!"_ZTSN4agge3arcE", !7, i64 0, !10, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!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 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 16}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !7, i64 12}
!18 = !{!6, !7, i64 28}


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