; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/freetype-src/src/base (fttrigon)

; 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.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: 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) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @ft_trig_prenorm(ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @FT_Vector_Length(ptr noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.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
  %8 = icmp ne ptr %7, null
  br i1 %8, label %10, label %9

9:                                                ; preds = %1
  store i64 0, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %73

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %11, i64 16, i1 false), !tbaa.struct !9
  %12 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !12
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %15, label %28

15:                                               ; preds = %10
  %16 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = icmp slt i64 %17, 0
  br i1 %18, label %19, label %23

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

23:                                               ; preds = %15
  %24 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %23, %19
  %27 = phi i64 [ %22, %19 ], [ %25, %23 ]
  store i64 %27, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %73

28:                                               ; preds = %10
  %29 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !14
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %32, label %45

32:                                               ; preds = %28
  %33 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !12
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !12
  %39 = sub nsw i64 0, %38
  br label %43

40:                                               ; preds = %32
  %41 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  %42 = load i64, ptr %41, align 8, !tbaa !12
  br label %43

43:                                               ; preds = %40, %36
  %44 = phi i64 [ %39, %36 ], [ %42, %40 ]
  store i64 %44, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %73

45:                                               ; preds = %28
  br label %46

46:                                               ; preds = %45
  %47 = call i32 @ft_trig_prenorm(ptr noundef %5)
  store i32 %47, ptr %4, align 4, !tbaa !15
  call void @ft_trig_pseudo_polarize(ptr noundef %5)
  %48 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  %49 = load i64, ptr %48, align 8, !tbaa !12
  %50 = call i64 @ft_trig_downscale(i64 noundef %49)
  %51 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  store i64 %50, ptr %51, align 8, !tbaa !12
  %52 = load i32, ptr %4, align 4, !tbaa !15
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %54, label %65

54:                                               ; preds = %46
  %55 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  %56 = load i64, ptr %55, align 8, !tbaa !12
  %57 = load i32, ptr %4, align 4, !tbaa !15
  %58 = sub nsw i32 %57, 1
  %59 = zext i32 %58 to i64
  %60 = shl i64 1, %59
  %61 = add nsw i64 %56, %60
  %62 = load i32, ptr %4, align 4, !tbaa !15
  %63 = zext i32 %62 to i64
  %64 = ashr i64 %61, %63
  store i64 %64, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %73

65:                                               ; preds = %46
  %66 = getelementptr inbounds %struct.FT_Vector_, ptr %5, i32 0, i32 0
  %67 = load i64, ptr %66, align 8, !tbaa !12
  %68 = trunc i64 %67 to i32
  %69 = load i32, ptr %4, align 4, !tbaa !15
  %70 = sub nsw i32 0, %69
  %71 = shl i32 %68, %70
  %72 = zext i32 %71 to i64
  store i64 %72, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %73

73:                                               ; preds = %65, %54, %43, %26, %9
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %74 = load i64, ptr %2, align 8
  ret i64 %74
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 }

!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 = !{!"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.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: 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) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @ft_trig_prenorm(ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @FT_Vector_Length(ptr noundef readonly %0) local_unnamed_addr #2 {
  %2 = alloca %struct.FT_Vector_, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %31, label %3

3:                                                ; preds = %1
  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
  %4 = load i64, ptr %2, align 8
  %5 = icmp eq i64 %4, 0
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = load i64, ptr %6, align 8
  br i1 %5, label %8, label %10

8:                                                ; preds = %3
  %9 = tail call i64 @llvm.abs.i64(i64 %7, i1 true)
  br label %31

10:                                               ; preds = %3
  %11 = icmp eq i64 %7, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %10
  %13 = tail call i64 @llvm.abs.i64(i64 %4, i1 true)
  br label %31

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

19:                                               ; preds = %14
  %20 = add nsw i32 %15, -1
  %21 = zext nneg i32 %20 to i64
  %22 = shl nuw i64 1, %21
  %23 = add nsw i64 %17, %22
  %24 = zext nneg i32 %15 to i64
  %25 = ashr i64 %23, %24
  br label %31

26:                                               ; preds = %14
  %27 = trunc i64 %17 to i32
  %28 = sub nsw i32 0, %15
  %29 = shl i32 %27, %28
  %30 = zext i32 %29 to i64
  br label %31

31:                                               ; preds = %1, %26, %19, %12, %8
  %.0 = phi i64 [ %9, %8 ], [ %13, %12 ], [ %25, %19 ], [ %30, %26 ], [ 0, %1 ]
  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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 = !{!"FT_Vector_", !7, i64 0, !7, i64 8}


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