; LLVM IR from DanEngelbrecht/longtail :: cmd/lib/minifb/ext/minifb/src (MiniFB_internal)

; 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.SWindowData = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, float, float, float, float, ptr, i32, i32, i32, i32, i32, float, float, [8 x i8], [512 x i8], i32, i8, i8, i8 }

; Function Attrs: nounwind uwtable
define dso_local void @calc_dst_factor(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.SWindowData, ptr %7, i32 0, i32 14
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %3
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.SWindowData, ptr %13, i32 0, i32 14
  store i32 %12, ptr %14, align 8, !tbaa !11
  br label %15

15:                                               ; preds = %11, %3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.SWindowData, ptr %16, i32 0, i32 12
  %18 = load i32, ptr %17, align 8, !tbaa !15
  %19 = uitofp i32 %18 to float
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = uitofp i32 %20 to float
  %22 = fdiv float %19, %21
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.SWindowData, ptr %23, i32 0, i32 16
  store float %22, ptr %24, align 8, !tbaa !16
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.SWindowData, ptr %25, i32 0, i32 14
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = uitofp i32 %27 to float
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = uitofp i32 %29 to float
  %31 = fdiv float %28, %30
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.SWindowData, ptr %32, i32 0, i32 18
  store float %31, ptr %33, align 8, !tbaa !17
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.SWindowData, ptr %34, i32 0, i32 15
  %36 = load i32, ptr %35, align 4, !tbaa !18
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %42

38:                                               ; preds = %15
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.SWindowData, ptr %40, i32 0, i32 15
  store i32 %39, ptr %41, align 4, !tbaa !18
  br label %42

42:                                               ; preds = %38, %15
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.SWindowData, ptr %43, i32 0, i32 13
  %45 = load i32, ptr %44, align 4, !tbaa !19
  %46 = uitofp i32 %45 to float
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = uitofp i32 %47 to float
  %49 = fdiv float %46, %48
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.SWindowData, ptr %50, i32 0, i32 17
  store float %49, ptr %51, align 4, !tbaa !20
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.SWindowData, ptr %52, i32 0, i32 15
  %54 = load i32, ptr %53, align 4, !tbaa !18
  %55 = uitofp i32 %54 to float
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = uitofp i32 %56 to float
  %58 = fdiv float %55, %57
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.SWindowData, ptr %59, i32 0, i32 19
  store float %58, ptr %60, align 4, !tbaa !21
  ret void
}

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

!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, !10, i64 96}
!12 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !13, i64 104, !13, i64 108, !13, i64 112, !13, i64 116, !6, i64 120, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !13, i64 148, !13, i64 152, !7, i64 156, !7, i64 164, !10, i64 676, !14, i64 680, !14, i64 681, !14, i64 682}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !10, i64 88}
!16 = !{!12, !13, i64 104}
!17 = !{!12, !13, i64 112}
!18 = !{!12, !10, i64 100}
!19 = !{!12, !10, i64 92}
!20 = !{!12, !13, i64 108}
!21 = !{!12, !13, i64 116}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @calc_dst_factor(ptr nocapture noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 96
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %8

7:                                                ; preds = %3
  store i32 %1, ptr %4, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %7, %3
  %9 = phi i32 [ %1, %7 ], [ %5, %3 ]
  %10 = getelementptr inbounds i8, ptr %0, i64 88
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = uitofp i32 %11 to float
  %13 = uitofp i32 %1 to float
  %14 = fdiv float %12, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 104
  store float %14, ptr %15, align 8, !tbaa !14
  %16 = uitofp i32 %9 to float
  %17 = fdiv float %16, %13
  %18 = getelementptr inbounds i8, ptr %0, i64 112
  store float %17, ptr %18, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 100
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %8
  store i32 %2, ptr %19, align 4, !tbaa !16
  br label %23

23:                                               ; preds = %22, %8
  %24 = phi i32 [ %2, %22 ], [ %20, %8 ]
  %25 = getelementptr inbounds i8, ptr %0, i64 92
  %26 = load i32, ptr %25, align 4, !tbaa !17
  %27 = uitofp i32 %26 to float
  %28 = uitofp i32 %2 to float
  %29 = fdiv float %27, %28
  %30 = getelementptr inbounds i8, ptr %0, i64 108
  store float %29, ptr %30, align 4, !tbaa !18
  %31 = uitofp i32 %24 to float
  %32 = fdiv float %31, %28
  %33 = getelementptr inbounds i8, ptr %0, i64 116
  store float %32, ptr %33, align 4, !tbaa !19
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !10, i64 96}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !7, i64 120, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !11, i64 148, !11, i64 152, !8, i64 156, !8, i64 164, !10, i64 676, !12, i64 680, !12, i64 681, !12, i64 682}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!"_Bool", !8, i64 0}
!13 = !{!6, !10, i64 88}
!14 = !{!6, !11, i64 104}
!15 = !{!6, !11, i64 112}
!16 = !{!6, !10, i64 100}
!17 = !{!6, !10, i64 92}
!18 = !{!6, !11, i64 108}
!19 = !{!6, !11, i64 116}


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