; LLVM IR from xboot/libcg :: src (xft)

; 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.XCG_FT_Vector_ = type { i64, i64 }

; 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: nounwind uwtable
declare hidden i32 @ft_trig_prenorm(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @ft_trig_pseudo_polarize(ptr noundef) #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

; Function Attrs: nounwind uwtable
declare hidden i64 @ft_trig_downscale(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @XCG_FT_Vector_Length(ptr noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.XCG_FT_Vector_, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !9
  %8 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  %9 = load i64, ptr %8, align 8, !tbaa !12
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %11, label %24

11:                                               ; preds = %1
  %12 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = icmp slt i64 %13, 0
  br i1 %14, label %15, label %19

15:                                               ; preds = %11
  %16 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = sub nsw i64 0, %17
  br label %22

19:                                               ; preds = %11
  %20 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !14
  br label %22

22:                                               ; preds = %19, %15
  %23 = phi i64 [ %18, %15 ], [ %21, %19 ]
  store i64 %23, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %69

24:                                               ; preds = %1
  %25 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %41

28:                                               ; preds = %24
  %29 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  %30 = load i64, ptr %29, align 8, !tbaa !12
  %31 = icmp slt i64 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %28
  %33 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !12
  %35 = sub nsw i64 0, %34
  br label %39

36:                                               ; preds = %28
  %37 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %36, %32
  %40 = phi i64 [ %35, %32 ], [ %38, %36 ]
  store i64 %40, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %69

41:                                               ; preds = %24
  br label %42

42:                                               ; preds = %41
  %43 = call i32 @ft_trig_prenorm(ptr noundef %5)
  store i32 %43, ptr %4, align 4, !tbaa !15
  call void @ft_trig_pseudo_polarize(ptr noundef %5)
  %44 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  %45 = load i64, ptr %44, align 8, !tbaa !12
  %46 = call i64 @ft_trig_downscale(i64 noundef %45)
  %47 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  store i64 %46, ptr %47, align 8, !tbaa !12
  %48 = load i32, ptr %4, align 4, !tbaa !15
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %50, label %61

50:                                               ; preds = %42
  %51 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  %52 = load i64, ptr %51, align 8, !tbaa !12
  %53 = load i32, ptr %4, align 4, !tbaa !15
  %54 = sub nsw i32 %53, 1
  %55 = shl i32 1, %54
  %56 = sext i32 %55 to i64
  %57 = add nsw i64 %52, %56
  %58 = load i32, ptr %4, align 4, !tbaa !15
  %59 = zext i32 %58 to i64
  %60 = ashr i64 %57, %59
  store i64 %60, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %69

61:                                               ; preds = %42
  %62 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %5, i32 0, i32 0
  %63 = load i64, ptr %62, align 8, !tbaa !12
  %64 = trunc i64 %63 to i32
  %65 = load i32, ptr %4, align 4, !tbaa !15
  %66 = sub nsw i32 0, %65
  %67 = shl i32 %64, %66
  %68 = zext i32 %67 to i64
  store i64 %68, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %69

69:                                               ; preds = %61, %50, %39, %22
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %70 = load i64, ptr %2, align 8
  ret i64 %70
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{i64 0, i64 8, !10, i64 8, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"XCG_FT_Vector_", !11, i64 0, !11, i64 8}
!14 = !{!13, !11, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}


; 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.XCG_FT_Vector_ = type { i64, i64 }

; 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: nounwind uwtable
declare hidden i32 @ft_trig_prenorm(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @ft_trig_pseudo_polarize(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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

; Function Attrs: nounwind uwtable
declare hidden i64 @ft_trig_downscale(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @XCG_FT_Vector_Length(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca %struct.XCG_FT_Vector_, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %0, i64 16, i1 false), !tbaa.struct !5
  %3 = load i64, ptr %2, align 8
  %4 = icmp eq i64 %3, 0
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %6 = load i64, ptr %5, align 8
  br i1 %4, label %7, label %9

7:                                                ; preds = %1
  %8 = tail call i64 @llvm.abs.i64(i64 %6, i1 true)
  br label %30

9:                                                ; preds = %1
  %10 = icmp eq i64 %6, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %9
  %12 = tail call i64 @llvm.abs.i64(i64 %3, i1 true)
  br label %30

13:                                               ; preds = %9
  %14 = call i32 @ft_trig_prenorm(ptr noundef nonnull %2)
  call void @ft_trig_pseudo_polarize(ptr noundef nonnull %2)
  %15 = load i64, ptr %2, align 8, !tbaa !10
  %16 = call i64 @ft_trig_downscale(i64 noundef %15)
  %17 = icmp sgt i32 %14, 0
  br i1 %17, label %18, label %25

18:                                               ; preds = %13
  %19 = add nsw i32 %14, -1
  %20 = shl nuw i32 1, %19
  %21 = sext i32 %20 to i64
  %22 = add nsw i64 %16, %21
  %23 = zext nneg i32 %14 to i64
  %24 = ashr i64 %22, %23
  br label %30

25:                                               ; preds = %13
  %26 = trunc i64 %16 to i32
  %27 = sub nsw i32 0, %14
  %28 = shl i32 %26, %27
  %29 = zext i32 %28 to i64
  br label %30

30:                                               ; preds = %25, %18, %11, %7
  %.0 = phi i64 [ %8, %7 ], [ %12, %11 ], [ %24, %18 ], [ %29, %25 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  ret i64 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{i64 0, i64 8, !6, i64 8, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"XCG_FT_Vector_", !7, i64 0, !7, i64 8}


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