; LLVM IR from tyoma/agge :: src/agge.text (layout_builder)

; 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.agge::layout_builder::state" = type { float, i32 }
%"class.agge::layout_builder" = type { %"struct.agge::layout_builder::state", ptr, ptr, float, ptr, ptr, ptr }
%"class.agge::range" = type { i64, i64, ptr }

; 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: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4agge14layout_builder18break_current_lineEv(ptr noundef nonnull align 8 dereferenceable(56)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4agge14layout_builder18break_current_lineERKNS0_5stateES3_(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.agge::layout_builder::state", 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
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = getelementptr inbounds %"class.agge::layout_builder", ptr %8, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 8 %9, i64 8, i1 false), !tbaa.struct !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %"class.agge::layout_builder", ptr %8, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !9
  %12 = call noundef zeroext i1 @_ZN4agge14layout_builder18break_current_lineEv(ptr noundef nonnull align 8 dereferenceable(56) %8)
  %13 = getelementptr inbounds %"class.agge::layout_builder", ptr %8, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !9
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.agge::layout_builder::state", ptr %14, i32 0, i32 0
  %16 = load float, ptr %15, align 4, !tbaa !14
  %17 = getelementptr inbounds %"class.agge::layout_builder", ptr %8, i32 0, i32 0
  %18 = getelementptr inbounds %"struct.agge::layout_builder::state", ptr %17, i32 0, i32 0
  %19 = load float, ptr %18, align 8, !tbaa !16
  %20 = fsub float %19, %16
  store float %20, ptr %18, align 8, !tbaa !16
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.agge::layout_builder::state", ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !18
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds %"class.agge::layout_builder", ptr %8, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !19
  %27 = getelementptr inbounds %"class.agge::range", ptr %26, i32 0, i32 0
  store i64 %24, ptr %27, align 8, !tbaa !20
  %28 = getelementptr inbounds %"class.agge::layout_builder", ptr %8, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  %30 = getelementptr inbounds %"class.agge::range", ptr %29, i32 0, i32 1
  store i64 %24, ptr %30, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { mustprogress 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 4, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTSN4agge14layout_builder5stateE", !11, i64 0, !13, i64 4}
!16 = !{!17, !11, i64 0}
!17 = !{!"_ZTSN4agge14layout_builderE", !15, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!18 = !{!15, !13, i64 4}
!19 = !{!17, !6, i64 8}
!20 = !{!21, !22, i64 0}
!21 = !{!"_ZTSN4agge5rangeIKNS_10pod_vectorINS_16positioned_glyphEEEEE", !22, i64 0, !22, i64 8, !6, i64 16}
!22 = !{!"long", !7, i64 0}
!23 = !{!21, !22, i64 8}


; 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: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4agge14layout_builder18break_current_lineEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4agge14layout_builder18break_current_lineERKNS0_5stateES3_(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %2) local_unnamed_addr #1 align 2 {
  %4 = load i64, ptr %0, align 8
  %5 = load i64, ptr %1, align 4
  store i64 %5, ptr %0, align 8
  %6 = tail call noundef zeroext i1 @_ZN4agge14layout_builder18break_current_lineEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
  store i64 %4, ptr %0, align 8
  %7 = load float, ptr %2, align 4, !tbaa !5
  %8 = trunc i64 %4 to i32
  %9 = bitcast i32 %8 to float
  %10 = fsub float %9, %7
  store float %10, ptr %0, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %2, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !14
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  store i64 %13, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  store i64 %13, ptr %16, align 8, !tbaa !19
  ret void
}

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { mustprogress 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" }

!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 0}
!6 = !{!"_ZTSN4agge14layout_builder5stateE", !7, i64 0, !10, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTSN4agge14layout_builderE", !6, i64 0, !13, i64 8, !13, i64 16, !7, i64 24, !13, i64 32, !13, i64 40, !13, i64 48}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!6, !10, i64 4}
!15 = !{!12, !13, i64 8}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTSN4agge5rangeIKNS_10pod_vectorINS_16positioned_glyphEEEEE", !18, i64 0, !18, i64 8, !13, i64 16}
!18 = !{!"long", !8, i64 0}
!19 = !{!17, !18, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass