; LLVM IR from jgaeddert/liquid-dsp :: src/math/tests (math_gamma_autotest)

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

@__const.autotest_gamma.v = external hidden unnamed_addr constant [12 x [2 x float]], align 16
@liquid_autotest_verbose = external global i32, align 4
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_gamma() #0 {
  %1 = alloca float, align 4
  %2 = alloca [12 x [2 x float]], align 16
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store float 0x3EE4F8B580000000, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 96, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.autotest_gamma.v, i64 96, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %54, %0
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = icmp ult i32 %9, 12
  br i1 %10, label %11, label %57

11:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds [12 x [2 x float]], ptr %2, i64 0, i64 %13
  %15 = getelementptr inbounds [2 x float], ptr %14, i64 0, i64 0
  %16 = load float, ptr %15, align 8, !tbaa !5
  store float %16, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds [12 x [2 x float]], ptr %2, i64 0, i64 %18
  %20 = getelementptr inbounds [2 x float], ptr %19, i64 0, i64 1
  %21 = load float, ptr %20, align 4, !tbaa !5
  store float %21, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %22 = load float, ptr %4, align 4, !tbaa !5
  %23 = call float @liquid_gammaf(float noundef %22)
  store float %23, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %24 = load float, ptr %6, align 4, !tbaa !5
  %25 = load float, ptr %5, align 4, !tbaa !5
  %26 = fsub float %24, %25
  %27 = call float @llvm.fabs.f32(float %26)
  %28 = load float, ptr %5, align 4, !tbaa !5
  %29 = call float @llvm.fabs.f32(float %28)
  %30 = fdiv float %27, %29
  store float %30, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %43

33:                                               ; preds = %11
  %34 = load float, ptr %4, align 4, !tbaa !5
  %35 = fpext float %34 to double
  %36 = load float, ptr %6, align 4, !tbaa !5
  %37 = fpext float %36 to double
  %38 = load float, ptr %5, align 4, !tbaa !5
  %39 = fpext float %38 to double
  %40 = load float, ptr %7, align 4, !tbaa !5
  %41 = fpext float %40 to double
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %35, double noundef %37, double noundef %39, double noundef %41)
  br label %43

43:                                               ; preds = %33, %11
  %44 = load float, ptr %7, align 4, !tbaa !5
  %45 = load float, ptr %1, align 4, !tbaa !5
  %46 = fcmp oge float %44, %45
  br i1 %46, label %47, label %52

47:                                               ; preds = %43
  %48 = load float, ptr %7, align 4, !tbaa !5
  %49 = fpext float %48 to double
  %50 = load float, ptr %1, align 4, !tbaa !5
  %51 = fpext float %50 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.1, i32 noundef 66, ptr noundef @.str.2, double noundef %49, ptr noundef @.str.3, ptr noundef @.str.4, double noundef %51)
  br label %53

52:                                               ; preds = %43
  call void (...) @liquid_autotest_passed()
  br label %53

53:                                               ; preds = %52, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  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
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %3, align 4, !tbaa !9
  %56 = add i32 %55, 1
  store i32 %56, ptr %3, align 4, !tbaa !9
  br label %8, !llvm.loop !11

57:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 96, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare float @liquid_gammaf(float noundef) #3

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

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

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #3

declare void @liquid_autotest_passed(...) #3

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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!6, !6, i64 0}
!6 = !{!"float", !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 = distinct !{!11, !12}
!12 = !{!"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"

@__const.autotest_gamma.v = external hidden unnamed_addr constant [12 x [2 x float]], align 16
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_gamma() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %0, %22
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %22 ]
  %2 = getelementptr inbounds [12 x [2 x float]], ptr @__const.autotest_gamma.v, i64 0, i64 %indvars.iv
  %3 = load float, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %2, i64 4
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = tail call float @liquid_gammaf(float noundef %3) #4
  %7 = fsub float %6, %5
  %8 = fdiv float %7, %5
  %9 = tail call float @llvm.fabs.f32(float %8)
  %10 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !9
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %17, label %11

11:                                               ; preds = %1
  %12 = fpext float %3 to double
  %13 = fpext float %6 to double
  %14 = fpext float %5 to double
  %15 = fpext float %9 to double
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %12, double noundef %13, double noundef %14, double noundef %15)
  br label %17

17:                                               ; preds = %11, %1
  %18 = fcmp ult float %9, 0x3EE4F8B580000000
  br i1 %18, label %21, label %19

19:                                               ; preds = %17
  %20 = fpext float %9 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.1, i32 noundef 66, ptr noundef nonnull @.str.2, double noundef %20, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, double noundef 0x3EE4F8B580000000) #4
  br label %22

21:                                               ; preds = %17
  tail call void (...) @liquid_autotest_passed() #4
  br label %22

22:                                               ; preds = %21, %19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 12
  br i1 %exitcond.not, label %23, label %1, !llvm.loop !11

23:                                               ; preds = %22
  ret void
}

declare float @liquid_gammaf(float noundef) local_unnamed_addr #1

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

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

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #1

declare void @liquid_autotest_passed(...) local_unnamed_addr #1

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 = { "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"float", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass