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

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

@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7fastCos4perfEb(i1 noundef zeroext %0) #0 {
  %2 = alloca i8, align 1
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i64, align 8
  %7 = alloca float, align 4
  %8 = alloca i64, align 8
  %9 = alloca float, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = zext i1 %0 to i8
  store i8 %13, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %14 = call noundef float @_ZN3glm2piIfEET_v()
  %15 = fneg float %14
  store float %15, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %16 = call noundef float @_ZN3glm2piIfEET_v()
  store float %16, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %17 = call i64 @clock() #6
  store i64 %17, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %18 = load float, ptr %3, align 4, !tbaa !9
  store float %18, ptr %7, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %36, %1
  %20 = load float, ptr %7, align 4, !tbaa !9
  %21 = load float, ptr %4, align 4, !tbaa !9
  %22 = fcmp olt float %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %38

24:                                               ; preds = %19
  %25 = load float, ptr %7, align 4, !tbaa !9
  %26 = call noundef float @_ZN3glm7fastCosIfEET_S1_(float noundef %25)
  store float %26, ptr %5, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %24
  %28 = load i8, ptr %2, align 1, !tbaa !5, !range !13, !noundef !14
  %29 = trunc i8 %28 to i1
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = load float, ptr %7, align 4, !tbaa !9
  %32 = call noundef float @_ZN3glm10next_floatIfEET_S1_(float noundef %31)
  br label %36

33:                                               ; preds = %27
  %34 = load float, ptr %7, align 4, !tbaa !9
  %35 = fadd float %34, 0x3FB99999A0000000
  store float %35, ptr %7, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %33, %30
  %37 = phi float [ %32, %30 ], [ %35, %33 ]
  store float %37, ptr %7, align 4, !tbaa !9
  br label %19, !llvm.loop !15

38:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %39 = call i64 @clock() #6
  store i64 %39, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %40 = load float, ptr %3, align 4, !tbaa !9
  store float %40, ptr %9, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %58, %38
  %42 = load float, ptr %9, align 4, !tbaa !9
  %43 = load float, ptr %4, align 4, !tbaa !9
  %44 = fcmp olt float %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %60

46:                                               ; preds = %41
  %47 = load float, ptr %9, align 4, !tbaa !9
  %48 = call noundef float @_ZSt3cosf(float noundef %47)
  store float %48, ptr %5, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %46
  %50 = load i8, ptr %2, align 1, !tbaa !5, !range !13, !noundef !14
  %51 = trunc i8 %50 to i1
  br i1 %51, label %52, label %55

52:                                               ; preds = %49
  %53 = load float, ptr %9, align 4, !tbaa !9
  %54 = call noundef float @_ZN3glm10next_floatIfEET_S1_(float noundef %53)
  br label %58

55:                                               ; preds = %49
  %56 = load float, ptr %9, align 4, !tbaa !9
  %57 = fadd float %56, 0x3FB99999A0000000
  store float %57, ptr %9, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %55, %52
  %59 = phi float [ %54, %52 ], [ %57, %55 ]
  store float %59, ptr %9, align 4, !tbaa !9
  br label %41, !llvm.loop !17

60:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %61 = call i64 @clock() #6
  store i64 %61, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %62 = load i64, ptr %8, align 8, !tbaa !11
  %63 = load i64, ptr %6, align 8, !tbaa !11
  %64 = sub nsw i64 %62, %63
  store i64 %64, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %65 = load i64, ptr %10, align 8, !tbaa !11
  %66 = load i64, ptr %8, align 8, !tbaa !11
  %67 = sub nsw i64 %65, %66
  store i64 %67, ptr %12, align 8, !tbaa !11
  %68 = load i64, ptr %11, align 8, !tbaa !11
  %69 = trunc i64 %68 to i32
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %69)
  %71 = load i64, ptr %12, align 8, !tbaa !11
  %72 = trunc i64 %71 to i32
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %72)
  %74 = load i64, ptr %11, align 8, !tbaa !11
  %75 = load i64, ptr %12, align 8, !tbaa !11
  %76 = icmp sle i64 %74, %75
  %77 = zext i1 %76 to i64
  %78 = select i1 %76, i32 0, i32 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret i32 %78
}

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

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

; Function Attrs: nounwind
declare i64 @clock() #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN3glm7fastCosIfEET_S1_(float noundef) #4

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

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

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

declare i32 @printf(ptr noundef, ...) #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { "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 #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 = !{!6, !6, i64 0}
!6 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7fastCos4perfEb(i1 noundef zeroext %0) local_unnamed_addr #0 {
  %2 = tail call noundef float @_ZN3glm2piIfEET_v()
  %3 = fneg float %2
  %4 = tail call noundef float @_ZN3glm2piIfEET_v()
  %5 = tail call i64 @clock() #5
  %6 = fcmp ogt float %4, %3
  br i1 %6, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %1
  %7 = tail call i64 @clock() #5
  br label %._crit_edge27

.lr.ph:                                           ; preds = %1
  br i1 %0, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %.023.us = phi float [ %9, %.lr.ph.split.us ], [ %3, %.lr.ph ]
  %8 = tail call noundef float @_ZN3glm7fastCosIfEET_S1_(float noundef %.023.us)
  %9 = tail call noundef float @_ZN3glm10next_floatIfEET_S1_(float noundef %.023.us)
  %10 = fcmp olt float %9, %4
  br i1 %10, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us
  %11 = tail call i64 @clock() #5
  br i1 %6, label %.lr.ph26, label %._crit_edge27

.lr.ph26:                                         ; preds = %._crit_edge
  br i1 %0, label %.lr.ph26.split.us, label %.lr.ph26.split

.lr.ph26.split.us:                                ; preds = %.lr.ph26, %.lr.ph26.split.us
  %.02124.us = phi float [ %13, %.lr.ph26.split.us ], [ %3, %.lr.ph26 ]
  %12 = tail call noundef float @_ZSt3cosf(float noundef %.02124.us)
  %13 = tail call noundef float @_ZN3glm10next_floatIfEET_S1_(float noundef %.02124.us)
  %14 = fcmp olt float %13, %4
  br i1 %14, label %.lr.ph26.split.us, label %._crit_edge27, !llvm.loop !7

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %.023 = phi float [ %16, %.lr.ph.split ], [ %3, %.lr.ph ]
  %15 = tail call noundef float @_ZN3glm7fastCosIfEET_S1_(float noundef %.023)
  %16 = fadd float %.023, 0x3FB99999A0000000
  %17 = fcmp olt float %16, %4
  br i1 %17, label %.lr.ph.split, label %._crit_edge, !llvm.loop !5

._crit_edge27:                                    ; preds = %.lr.ph26.split, %.lr.ph26.split.us, %._crit_edge.thread, %._crit_edge
  %18 = phi i64 [ %7, %._crit_edge.thread ], [ %11, %._crit_edge ], [ %11, %.lr.ph26.split.us ], [ %11, %.lr.ph26.split ]
  %19 = tail call i64 @clock() #5
  %20 = sub nsw i64 %18, %5
  %21 = sub nsw i64 %19, %18
  %22 = trunc i64 %20 to i32
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %22)
  %24 = trunc i64 %21 to i32
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %24)
  %.not = icmp sgt i64 %20, %21
  %26 = zext i1 %.not to i32
  ret i32 %26

.lr.ph26.split:                                   ; preds = %.lr.ph26, %.lr.ph26.split
  %.02124 = phi float [ %28, %.lr.ph26.split ], [ %3, %.lr.ph26 ]
  %27 = tail call noundef float @_ZSt3cosf(float noundef %.02124)
  %28 = fadd float %.02124, 0x3FB99999A0000000
  %29 = fcmp olt float %28, %4
  br i1 %29, label %.lr.ph26.split, label %._crit_edge27, !llvm.loop !7
}

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

; Function Attrs: nounwind
declare i64 @clock() local_unnamed_addr #2

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

attributes #0 = { 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 #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 = { 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 #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 = { nofree 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 }

!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"}
!7 = distinct !{!7, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass