; 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 void @XCG_FT_Vector_Polarize(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.XCG_FT_Vector_, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !9
  %11 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %8, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !12
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %14, label %19

14:                                               ; preds = %3
  %15 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %8, i32 0, i32 1
  %16 = load i64, ptr %15, align 8, !tbaa !14
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i32 1, ptr %9, align 4
  br label %47

19:                                               ; preds = %14, %3
  %20 = call i32 @ft_trig_prenorm(ptr noundef %8)
  store i32 %20, ptr %7, align 4, !tbaa !15
  call void @ft_trig_pseudo_polarize(ptr noundef %8)
  %21 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %8, i32 0, i32 0
  %22 = load i64, ptr %21, align 8, !tbaa !12
  %23 = call i64 @ft_trig_downscale(i64 noundef %22)
  %24 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %8, i32 0, i32 0
  store i64 %23, ptr %24, align 8, !tbaa !12
  %25 = load i32, ptr %7, align 4, !tbaa !15
  %26 = icmp sge i32 %25, 0
  br i1 %26, label %27, label %33

27:                                               ; preds = %19
  %28 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %8, i32 0, i32 0
  %29 = load i64, ptr %28, align 8, !tbaa !12
  %30 = load i32, ptr %7, align 4, !tbaa !15
  %31 = zext i32 %30 to i64
  %32 = ashr i64 %29, %31
  br label %41

33:                                               ; preds = %19
  %34 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %8, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !12
  %36 = trunc i64 %35 to i32
  %37 = load i32, ptr %7, align 4, !tbaa !15
  %38 = sub nsw i32 0, %37
  %39 = shl i32 %36, %38
  %40 = zext i32 %39 to i64
  br label %41

41:                                               ; preds = %33, %27
  %42 = phi i64 [ %32, %27 ], [ %40, %33 ]
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %42, ptr %43, align 8, !tbaa !10
  %44 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %8, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !14
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  store i64 %45, ptr %46, align 8, !tbaa !10
  store i32 0, ptr %9, align 4
  br label %47

47:                                               ; preds = %41, %18
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %48 = load i32, ptr %9, align 4
  switch i32 %48, label %50 [
    i32 0, label %49
    i32 1, label %49
  ]

49:                                               ; preds = %47, %47
  ret void

50:                                               ; preds = %47
  unreachable
}

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 void @XCG_FT_Vector_Polarize(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca %struct.XCG_FT_Vector_, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %0, i64 16, i1 false), !tbaa.struct !5
  %5 = load i64, ptr %4, align 8, !tbaa !10
  %6 = icmp eq i64 %5, 0
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  %8 = load i64, ptr %7, align 8
  %9 = icmp eq i64 %8, 0
  %or.cond = select i1 %6, i1 %9, i1 false
  br i1 %or.cond, label %23, label %10

10:                                               ; preds = %3
  %11 = call i32 @ft_trig_prenorm(ptr noundef nonnull %4)
  call void @ft_trig_pseudo_polarize(ptr noundef nonnull %4)
  %12 = load i64, ptr %4, align 8, !tbaa !10
  %13 = call i64 @ft_trig_downscale(i64 noundef %12)
  %14 = zext nneg i32 %11 to i64
  %15 = ashr i64 %13, %14
  %16 = trunc i64 %13 to i32
  %17 = sub nsw i32 0, %11
  %18 = shl i32 %16, %17
  %19 = zext i32 %18 to i64
  %20 = icmp slt i32 %11, 0
  %21 = select i1 %20, i64 %19, i64 %15
  store i64 %21, ptr %1, align 8, !tbaa !6
  %22 = load i64, ptr %7, align 8, !tbaa !12
  store i64 %22, ptr %2, align 8, !tbaa !6
  br label %23

23:                                               ; preds = %3, %10
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  ret void
}

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 = { 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}
!12 = !{!11, !7, i64 8}


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