; LLVM IR from libtcod/libtcod :: src/libtcod (tileset_truetype)

; 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.BBox = type { i32, i32, i32, i32 }
%struct.FontLoader = type { ptr, float, %struct.BBox, ptr, ptr, ptr, i32, i32, i32, float, float }
%struct.TCOD_Tileset = type { i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @bbox_width(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @get_glyph_shift(ptr noalias noundef %0, i32 noundef %1, ptr noalias noundef %2, ptr noalias noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.BBox, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.FontLoader, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = call { i64, i64 } @get_glyph_bbox(ptr noundef %12, i32 noundef %13, float noundef 1.000000e+00)
  %15 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  %16 = extractvalue { i64, i64 } %14, 0
  store i64 %16, ptr %15, align 4
  %17 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  %18 = extractvalue { i64, i64 } %14, 1
  store i64 %18, ptr %17, align 4
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.FontLoader, ptr %19, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds %struct.TCOD_Tileset, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !16
  %24 = sitofp i32 %23 to float
  %25 = call i32 @bbox_width(ptr noundef %9)
  %26 = sitofp i32 %25 to float
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.FontLoader, ptr %27, i32 0, i32 1
  %29 = load float, ptr %28, align 8, !tbaa !18
  %30 = fneg float %26
  %31 = call float @llvm.fmuladd.f32(float %30, float %29, float %24)
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.FontLoader, ptr %32, i32 0, i32 9
  %34 = load float, ptr %33, align 4, !tbaa !19
  %35 = fmul float %31, %34
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  store float %35, ptr %36, align 4, !tbaa !20
  %37 = getelementptr inbounds %struct.BBox, ptr %9, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !21
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.FontLoader, ptr %39, i32 0, i32 6
  %41 = load i32, ptr %40, align 8, !tbaa !22
  %42 = add nsw i32 %38, %41
  %43 = sitofp i32 %42 to float
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.FontLoader, ptr %44, i32 0, i32 1
  %46 = load float, ptr %45, align 8, !tbaa !18
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.FontLoader, ptr %47, i32 0, i32 3
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = getelementptr inbounds %struct.TCOD_Tileset, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !23
  %52 = sitofp i32 %51 to float
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.FontLoader, ptr %53, i32 0, i32 6
  %55 = load i32, ptr %54, align 8, !tbaa !22
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.FontLoader, ptr %56, i32 0, i32 7
  %58 = load i32, ptr %57, align 4, !tbaa !24
  %59 = sub nsw i32 %55, %58
  %60 = sitofp i32 %59 to float
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.FontLoader, ptr %61, i32 0, i32 1
  %63 = load float, ptr %62, align 8, !tbaa !18
  %64 = fneg float %60
  %65 = call float @llvm.fmuladd.f32(float %64, float %63, float %52)
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.FontLoader, ptr %66, i32 0, i32 10
  %68 = load float, ptr %67, align 8, !tbaa !25
  %69 = fmul float %65, %68
  %70 = fptosi float %69 to i32
  %71 = sitofp i32 %70 to float
  %72 = call float @llvm.fmuladd.f32(float %43, float %46, float %71)
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  store float %72, ptr %73, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden { i64, i64 } @get_glyph_bbox(ptr noundef, i32 noundef, float noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"FontLoader", !6, i64 0, !13, i64 8, !14, i64 12, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !13, i64 68, !13, i64 72}
!13 = !{!"float", !7, i64 0}
!14 = !{!"BBox", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!15 = !{!12, !6, i64 32}
!16 = !{!17, !10, i64 0}
!17 = !{!"TCOD_Tileset", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60}
!18 = !{!12, !13, i64 8}
!19 = !{!12, !13, i64 68}
!20 = !{!13, !13, i64 0}
!21 = !{!14, !10, i64 4}
!22 = !{!12, !10, i64 56}
!23 = !{!17, !10, i64 4}
!24 = !{!12, !10, i64 60}
!25 = !{!12, !13, i64 72}


; 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.BBox = type { i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @bbox_width(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @get_glyph_shift(ptr noalias nocapture noundef readonly %0, i32 noundef %1, ptr noalias nocapture noundef writeonly %2, ptr noalias nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = alloca %struct.BBox, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = tail call { i64, i64 } @get_glyph_bbox(ptr noundef %6, i32 noundef %1, float noundef 1.000000e+00)
  %8 = extractvalue { i64, i64 } %7, 0
  store i64 %8, ptr %5, align 8
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  %10 = extractvalue { i64, i64 } %7, 1
  store i64 %10, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = load i32, ptr %12, align 8, !tbaa !14
  %14 = sitofp i32 %13 to float
  %15 = call i32 @bbox_width(ptr noundef nonnull %5)
  %16 = sitofp i32 %15 to float
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load float, ptr %17, align 8, !tbaa !16
  %19 = fneg float %16
  %20 = call float @llvm.fmuladd.f32(float %19, float %18, float %14)
  %21 = getelementptr inbounds i8, ptr %0, i64 68
  %22 = load float, ptr %21, align 4, !tbaa !17
  %23 = fmul float %20, %22
  store float %23, ptr %2, align 4, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %5, i64 4
  %25 = load i32, ptr %24, align 4, !tbaa !19
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  %27 = load i32, ptr %26, align 8, !tbaa !20
  %28 = add nsw i32 %27, %25
  %29 = sitofp i32 %28 to float
  %30 = getelementptr inbounds i8, ptr %12, i64 4
  %31 = load i32, ptr %30, align 4, !tbaa !21
  %32 = sitofp i32 %31 to float
  %33 = getelementptr inbounds i8, ptr %0, i64 60
  %34 = load i32, ptr %33, align 4, !tbaa !22
  %35 = sub nsw i32 %27, %34
  %36 = sitofp i32 %35 to float
  %37 = fneg float %36
  %38 = call float @llvm.fmuladd.f32(float %37, float %18, float %32)
  %39 = getelementptr inbounds i8, ptr %0, i64 72
  %40 = load float, ptr %39, align 8, !tbaa !23
  %41 = fmul float %40, %38
  %42 = fptosi float %41 to i32
  %43 = sitofp i32 %42 to float
  %44 = call float @llvm.fmuladd.f32(float %29, float %18, float %43)
  store float %44, ptr %3, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden { i64, i64 } @get_glyph_bbox(ptr noundef, i32 noundef, float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"FontLoader", !7, i64 0, !10, i64 8, !11, i64 12, !7, i64 32, !7, i64 40, !7, i64 48, !12, i64 56, !12, i64 60, !12, i64 64, !10, i64 68, !10, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"BBox", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !7, i64 32}
!14 = !{!15, !12, i64 0}
!15 = !{!"TCOD_Tileset", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !7, i64 24, !12, i64 32, !7, i64 40, !7, i64 48, !12, i64 56, !12, i64 60}
!16 = !{!6, !10, i64 8}
!17 = !{!6, !10, i64 68}
!18 = !{!10, !10, i64 0}
!19 = !{!11, !12, i64 4}
!20 = !{!6, !12, i64 56}
!21 = !{!15, !12, i64 4}
!22 = !{!6, !12, i64 60}
!23 = !{!6, !10, i64 72}


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