; LLVM IR from Dovyski/opengl-demos :: libs/glm-0.9.9.3/test/gtx/gtx_fast_trigonometry.ll (ZN9taylorCos4testEv)

; 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.glm::vec.2" = type { %union.anon.3 }
%union.anon.3 = type { float }

@.str.17 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [106 x i8], align 1
@__PRETTY_FUNCTION__._ZN9taylorCos4testEv = external hidden unnamed_addr constant [22 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [7 x i8], align 1

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9taylorCos4testEv() #2 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca %"struct.glm::vec.2", align 4
  %8 = alloca %"struct.glm::vec.2", align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store float 0.000000e+00, ptr %2, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %54, %0
  %10 = load float, ptr %2, align 4, !tbaa !9
  %11 = fcmp olt float %10, 1.800000e+02
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %57

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %14 = load float, ptr %2, align 4, !tbaa !9
  %15 = call noundef float @_ZN3glm3absIfEET_S1_(float noundef %14)
  %16 = call noundef float @_ZSt4fmodff(float noundef %15, float noundef 3.600000e+02)
  store float %16, ptr %3, align 4, !tbaa !9
  %17 = load float, ptr %3, align 4, !tbaa !9
  %18 = fcmp oge float %17, 0.000000e+00
  br i1 %18, label %19, label %22

19:                                               ; preds = %13
  %20 = load float, ptr %3, align 4, !tbaa !9
  %21 = fcmp ole float %20, 3.600000e+02
  br label %22

22:                                               ; preds = %19, %13
  %23 = phi i1 [ false, %13 ], [ %21, %19 ]
  br i1 %23, label %24, label %25

24:                                               ; preds = %22
  br label %27

25:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.18, i32 noundef 415, ptr noundef @__PRETTY_FUNCTION__._ZN9taylorCos4testEv) #6
  unreachable

26:                                               ; No predecessors!
  br label %27

27:                                               ; preds = %26, %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %28 = load float, ptr %3, align 4, !tbaa !9
  %29 = call noundef float @_ZN3glm7radiansIfEET_S1_(float noundef %28)
  store float %29, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %30 = load float, ptr %4, align 4, !tbaa !9
  %31 = call noundef float @_ZSt3cosf(float noundef %30)
  store float %31, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %32 = load float, ptr %4, align 4, !tbaa !9
  call void @_ZN3glm3vecILi1EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(4) %8, float noundef %32)
  %33 = call float @_ZN9taylorCos10fastRefCosILi1EfLN3glm9qualifierE0EEENS1_3vecIXT_ET0_XT1_EEERKS5_(ptr noundef nonnull align 4 dereferenceable(4) %8)
  %34 = getelementptr inbounds %"struct.glm::vec.2", ptr %7, i32 0, i32 0
  %35 = getelementptr inbounds %union.anon.3, ptr %34, i32 0, i32 0
  store float %33, ptr %35, align 4
  %36 = getelementptr inbounds %"struct.glm::vec.2", ptr %7, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  store float %37, ptr %6, align 4, !tbaa !9
  %38 = load float, ptr %6, align 4, !tbaa !9
  %39 = load float, ptr %5, align 4, !tbaa !9
  %40 = fsub float %38, %39
  %41 = call noundef float @_ZN3glm3absIfEET_S1_(float noundef %40)
  %42 = fcmp olt float %41, 0x3FB99999A0000000
  %43 = zext i1 %42 to i64
  %44 = select i1 %42, i32 0, i32 1
  %45 = load i32, ptr %1, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %1, align 4, !tbaa !5
  %47 = load i32, ptr %1, align 4, !tbaa !5
  %48 = icmp ne i32 %47, 0
  %49 = xor i1 %48, true
  br i1 %49, label %50, label %51

50:                                               ; preds = %27
  br label %53

51:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.18, i32 noundef 425, ptr noundef @__PRETTY_FUNCTION__._ZN9taylorCos4testEv) #6
  unreachable

52:                                               ; No predecessors!
  br label %53

53:                                               ; preds = %52, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %54

54:                                               ; preds = %53
  %55 = load float, ptr %2, align 4, !tbaa !9
  %56 = fadd float %55, 0x3FB99999A0000000
  store float %56, ptr %2, align 4, !tbaa !9
  br label %9, !llvm.loop !12

57:                                               ; preds = %12
  %58 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret i32 %58
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4fmodff(float noundef, float noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN3glm3absIfEET_S1_(float noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3glm7radiansIfEET_S1_(float noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local float @_ZN9taylorCos10fastRefCosILi1EfLN3glm9qualifierE0EEENS1_3vecIXT_ET0_XT1_EEERKS5_(ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3glm3vecILi1EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(4), float noundef) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #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 = { inlinehint 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 #4 = { noreturn 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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.glm::vec.2" = type { %union.anon.3 }
%union.anon.3 = type { float }

@.str.17 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [106 x i8], align 1
@__PRETTY_FUNCTION__._ZN9taylorCos4testEv = external hidden unnamed_addr constant [22 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9taylorCos4testEv() local_unnamed_addr #2 {
  %1 = alloca %"struct.glm::vec.2", align 4
  br label %3

2:                                                ; preds = %18
  ret i32 0

3:                                                ; preds = %0, %18
  %.01214 = phi float [ 0.000000e+00, %0 ], [ %19, %18 ]
  %4 = call noundef float @_ZN3glm3absIfEET_S1_(float noundef %.01214)
  %5 = call noundef float @_ZSt4fmodff(float noundef %4, float noundef 3.600000e+02)
  %6 = fcmp oge float %5, 0.000000e+00
  %7 = fcmp ole float %5, 3.600000e+02
  %8 = and i1 %6, %7
  br i1 %8, label %10, label %9

9:                                                ; preds = %3
  call void @__assert_fail(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.18, i32 noundef 415, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN9taylorCos4testEv) #5
  unreachable

10:                                               ; preds = %3
  %11 = call noundef float @_ZN3glm7radiansIfEET_S1_(float noundef %5)
  %12 = call noundef float @_ZSt3cosf(float noundef %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @_ZN3glm3vecILi1EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(4) %1, float noundef %11)
  %13 = call float @_ZN9taylorCos10fastRefCosILi1EfLN3glm9qualifierE0EEENS1_3vecIXT_ET0_XT1_EEERKS5_(ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %14 = fsub float %13, %12
  %15 = call noundef float @_ZN3glm3absIfEET_S1_(float noundef %14)
  %16 = fcmp olt float %15, 0x3FB99999A0000000
  br i1 %16, label %18, label %17

17:                                               ; preds = %10
  call void @__assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.18, i32 noundef 425, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN9taylorCos4testEv) #5
  unreachable

18:                                               ; preds = %10
  %19 = fadd float %.01214, 0x3FB99999A0000000
  %20 = fcmp olt float %19, 1.800000e+02
  br i1 %20, label %3, label %2, !llvm.loop !5
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4fmodff(float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN3glm3absIfEET_S1_(float noundef) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3glm7radiansIfEET_S1_(float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local float @_ZN9taylorCos10fastRefCosILi1EfLN3glm9qualifierE0EEENS1_3vecIXT_ET0_XT1_EEERKS5_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3glm3vecILi1EfLNS_9qualifierE0EEC2Ef(ptr noundef nonnull align 4 dereferenceable(4), float noundef) unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #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 = { inlinehint 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 #4 = { noreturn 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 #5 = { noreturn nounwind }
attributes #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass