; 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_Outline_ = type { i32, i32, ptr, ptr, ptr, ptr, i32 }
%struct.XCG_FT_Vector_ = type { i64, i64 }
%struct.XCG_FT_BBox_ = type { i64, i64, 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
define dso_local void @XCG_FT_Outline_Get_CBox(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %94

15:                                               ; preds = %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %94

18:                                               ; preds = %15
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.XCG_FT_Outline_, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  store i64 0, ptr %5, align 8, !tbaa !12
  store i64 0, ptr %6, align 8, !tbaa !12
  store i64 0, ptr %7, align 8, !tbaa !12
  store i64 0, ptr %8, align 8, !tbaa !12
  br label %81

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.XCG_FT_Outline_, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  store ptr %27, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.XCG_FT_Outline_, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %28, i64 %32
  store ptr %33, ptr %10, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %34, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !15
  store i64 %36, ptr %7, align 8, !tbaa !12
  store i64 %36, ptr %5, align 8, !tbaa !12
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %37, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !17
  store i64 %39, ptr %8, align 8, !tbaa !12
  store i64 %39, ptr %6, align 8, !tbaa !12
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %40, i32 1
  store ptr %41, ptr %9, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %77, %24
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = icmp ult ptr %43, %44
  br i1 %45, label %46, label %80

46:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %47, i32 0, i32 0
  %49 = load i64, ptr %48, align 8, !tbaa !15
  store i64 %49, ptr %11, align 8, !tbaa !12
  %50 = load i64, ptr %11, align 8, !tbaa !12
  %51 = load i64, ptr %5, align 8, !tbaa !12
  %52 = icmp slt i64 %50, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %46
  %54 = load i64, ptr %11, align 8, !tbaa !12
  store i64 %54, ptr %5, align 8, !tbaa !12
  br label %55

55:                                               ; preds = %53, %46
  %56 = load i64, ptr %11, align 8, !tbaa !12
  %57 = load i64, ptr %7, align 8, !tbaa !12
  %58 = icmp sgt i64 %56, %57
  br i1 %58, label %59, label %61

59:                                               ; preds = %55
  %60 = load i64, ptr %11, align 8, !tbaa !12
  store i64 %60, ptr %7, align 8, !tbaa !12
  br label %61

61:                                               ; preds = %59, %55
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !17
  store i64 %64, ptr %12, align 8, !tbaa !12
  %65 = load i64, ptr %12, align 8, !tbaa !12
  %66 = load i64, ptr %6, align 8, !tbaa !12
  %67 = icmp slt i64 %65, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %61
  %69 = load i64, ptr %12, align 8, !tbaa !12
  store i64 %69, ptr %6, align 8, !tbaa !12
  br label %70

70:                                               ; preds = %68, %61
  %71 = load i64, ptr %12, align 8, !tbaa !12
  %72 = load i64, ptr %8, align 8, !tbaa !12
  %73 = icmp sgt i64 %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %70
  %75 = load i64, ptr %12, align 8, !tbaa !12
  store i64 %75, ptr %8, align 8, !tbaa !12
  br label %76

76:                                               ; preds = %74, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  br label %77

77:                                               ; preds = %76
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.XCG_FT_Vector_, ptr %78, i32 1
  store ptr %79, ptr %9, align 8, !tbaa !5
  br label %42, !llvm.loop !18

80:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %81

81:                                               ; preds = %80, %23
  %82 = load i64, ptr %5, align 8, !tbaa !12
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.XCG_FT_BBox_, ptr %83, i32 0, i32 0
  store i64 %82, ptr %84, align 8, !tbaa !20
  %85 = load i64, ptr %7, align 8, !tbaa !12
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.XCG_FT_BBox_, ptr %86, i32 0, i32 2
  store i64 %85, ptr %87, align 8, !tbaa !22
  %88 = load i64, ptr %6, align 8, !tbaa !12
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.XCG_FT_BBox_, ptr %89, i32 0, i32 1
  store i64 %88, ptr %90, align 8, !tbaa !23
  %91 = load i64, ptr %8, align 8, !tbaa !12
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.XCG_FT_BBox_, ptr %92, i32 0, i32 3
  store i64 %91, ptr %93, align 8, !tbaa !24
  br label %94

94:                                               ; preds = %81, %15, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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 = { 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 = !{!10, !11, i64 4}
!10 = !{!"XCG_FT_Outline_", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!16, !13, i64 0}
!16 = !{!"XCG_FT_Vector_", !13, i64 0, !13, i64 8}
!17 = !{!16, !13, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !13, i64 0}
!21 = !{!"XCG_FT_BBox_", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!22 = !{!21, !13, i64 16}
!23 = !{!21, !13, i64 8}
!24 = !{!21, !13, i64 24}


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

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @XCG_FT_Outline_Get_CBox(ptr noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %3 = icmp ne ptr %0, null
  %4 = icmp ne ptr %1, null
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %5, label %25

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = sext i32 %7 to i64
  %.idx = shl nsw i64 %12, 4
  %13 = getelementptr inbounds i8, ptr %11, i64 %.idx
  %14 = load i64, ptr %11, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %11, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !15
  %17 = icmp sgt i32 %7, 1
  br i1 %17, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %9
  %.04051 = getelementptr inbounds i8, ptr %11, i64 16
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.04057 = phi ptr [ %.040, %.lr.ph ], [ %.04051, %.lr.ph.preheader ]
  %.056 = phi i64 [ %spec.select, %.lr.ph ], [ %14, %.lr.ph.preheader ]
  %.03455 = phi i64 [ %.135, %.lr.ph ], [ %16, %.lr.ph.preheader ]
  %.03754 = phi i64 [ %.138, %.lr.ph ], [ %14, %.lr.ph.preheader ]
  %.pn53 = phi ptr [ %.04057, %.lr.ph ], [ %11, %.lr.ph.preheader ]
  %.04152 = phi i64 [ %.142, %.lr.ph ], [ %16, %.lr.ph.preheader ]
  %18 = load i64, ptr %.04057, align 8, !tbaa !12
  %spec.select = tail call i64 @llvm.smin.i64(i64 %18, i64 %.056)
  %.138 = tail call i64 @llvm.smax.i64(i64 %18, i64 %.03754)
  %19 = getelementptr inbounds i8, ptr %.pn53, i64 24
  %20 = load i64, ptr %19, align 8, !tbaa !15
  %.135 = tail call i64 @llvm.smin.i64(i64 %20, i64 %.03455)
  %.142 = tail call i64 @llvm.smax.i64(i64 %20, i64 %.04152)
  %.040 = getelementptr inbounds i8, ptr %.04057, i64 16
  %21 = icmp ult ptr %.040, %13
  br i1 %21, label %.lr.ph, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %.lr.ph, %9, %5
  %.243 = phi i64 [ 0, %5 ], [ %16, %9 ], [ %.142, %.lr.ph ]
  %.239 = phi i64 [ 0, %5 ], [ %14, %9 ], [ %.138, %.lr.ph ]
  %.236 = phi i64 [ 0, %5 ], [ %16, %9 ], [ %.135, %.lr.ph ]
  %.2 = phi i64 [ 0, %5 ], [ %14, %9 ], [ %spec.select, %.lr.ph ]
  store i64 %.2, ptr %1, align 8, !tbaa !18
  %22 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 %.239, ptr %22, align 8, !tbaa !20
  %23 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 %.236, ptr %23, align 8, !tbaa !21
  %24 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 %.243, ptr %24, align 8, !tbaa !22
  br label %25

25:                                               ; preds = %.loopexit, %2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #1

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 speculatable willreturn memory(none) }

!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, !7, i64 4}
!6 = !{!"XCG_FT_Outline_", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !14, i64 0}
!13 = !{!"XCG_FT_Vector_", !14, i64 0, !14, i64 8}
!14 = !{!"long", !8, i64 0}
!15 = !{!13, !14, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !14, i64 0}
!19 = !{!"XCG_FT_BBox_", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!20 = !{!19, !14, i64 16}
!21 = !{!19, !14, i64 8}
!22 = !{!19, !14, i64 24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass